fide.rlg 106 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804
  1. Sun Aug 18 18:00:52 2002 run on Windows
  2. %***********************************************************************
  3. %***** *****
  4. %***** Package F I D E - Test Examples Ver. 1.1.2 May 29,1995 *****
  5. %***** *****
  6. %***********************************************************************
  7. %***********************************************************************
  8. %***** *****
  9. %***** T e s t Examples --- Module E X P R E S *****
  10. %***** *****
  11. %***********************************************************************
  12. let cos th**2=1 - sin th**2,
  13. cos fi**2=1 - sin fi**2;
  14. factor df;
  15. on rat;
  16. for all x,y let diff(x,y)=df(x,y);
  17. depend u,r,th,fi;
  18. depend v,r,th,fi;
  19. depend f,r,th,fi;
  20. depend w,r,th,fi;
  21. % Spherical coordinate system
  22. scalefactors 3,r*sin th*cos fi,r*sin th*sin fi,r*cos th,r,th,fi;
  23. tensor a1,a2,a3,a4,a5;
  24. vectors u,v;
  25. dyads w;
  26. a1:=grad f;
  27. a1:= ( df(f,r) ,
  28. df(f,th)
  29. ---------- ,
  30. r
  31. df(f,fi)
  32. ----------- )
  33. sin(th)*r
  34. a2:=div u;
  35. df(u(3),fi) df(u(2),th) cos(th)*u(2) + 2*sin(th)*u(1)
  36. a2:=------------- + ------------- + df(u(1),r) + -------------------------------
  37. sin(th)*r r sin(th)*r
  38. a3:=curl v;
  39. df(v(3),th) - df(v(2),fi) cos(th)*v(3)
  40. a3:= ( ------------- + ---------------- + -------------- ,
  41. r sin(th)*r sin(th)*r
  42. df(v(1),fi) - v(3)
  43. - df(v(3),r) + ------------- + --------- ,
  44. sin(th)*r r
  45. - df(v(1),th) v(2)
  46. df(v(2),r) + ---------------- + ------ )
  47. r r
  48. a4:=lapl v;
  49. - 2*df(v(3),fi) - 2*df(v(2),th) df(v(1),fi,2)
  50. a4:= ( ------------------ + ------------------ + --------------- + df(v(1),r,2)
  51. 2 2 2 2
  52. sin(th)*r r sin(th) *r
  53. 2*df(v(1),r) df(v(1),th,2) df(v(1),th)*cos(th)
  54. + -------------- + --------------- + ---------------------
  55. r 2 2
  56. r sin(th)*r
  57. 2*(cos(th)*v(2) + sin(th)*v(1))
  58. - --------------------------------- ,
  59. 2
  60. sin(th)*r
  61. - 2*df(v(3),fi)*cos(th) df(v(2),fi,2)
  62. -------------------------- + --------------- + df(v(2),r,2)
  63. 2 2 2 2
  64. sin(th) *r sin(th) *r
  65. 2*df(v(2),r) df(v(2),th,2) df(v(2),th)*cos(th)
  66. + -------------- + --------------- + ---------------------
  67. r 2 2
  68. r sin(th)*r
  69. 2*df(v(1),th) - v(2)
  70. + --------------- + ------------- ,
  71. 2 2 2
  72. r sin(th) *r
  73. df(v(3),fi,2) 2*df(v(3),r) df(v(3),th,2)
  74. --------------- + df(v(3),r,2) + -------------- + ---------------
  75. 2 2 r 2
  76. sin(th) *r r
  77. df(v(3),th)*cos(th) 2*df(v(2),fi)*cos(th) 2*df(v(1),fi)
  78. + --------------------- + ----------------------- + ---------------
  79. 2 2 2 2
  80. sin(th)*r sin(th) *r sin(th)*r
  81. - v(3)
  82. + ------------- )
  83. 2 2
  84. sin(th) *r
  85. a3:=2*a3+a4;
  86. - 2*df(v(3),fi) 2*df(v(3),th) - 2*df(v(2),fi)
  87. a3:= ( ------------------ + --------------- + ------------------
  88. 2 r sin(th)*r
  89. sin(th)*r
  90. - 2*df(v(2),th) df(v(1),fi,2) 2*df(v(1),r)
  91. + ------------------ + --------------- + df(v(1),r,2) + --------------
  92. 2 2 2 r
  93. r sin(th) *r
  94. df(v(1),th,2) df(v(1),th)*cos(th)
  95. + --------------- + ---------------------
  96. 2 2
  97. r sin(th)*r
  98. 2*(cos(th)*v(3)*r - cos(th)*v(2) - sin(th)*v(1))
  99. + -------------------------------------------------- ,
  100. 2
  101. sin(th)*r
  102. - 2*df(v(3),fi)*cos(th) df(v(2),fi,2)
  103. -------------------------- - 2*df(v(3),r) + ---------------
  104. 2 2 2 2
  105. sin(th) *r sin(th) *r
  106. 2*df(v(2),r) df(v(2),th,2)
  107. + df(v(2),r,2) + -------------- + ---------------
  108. r 2
  109. r
  110. df(v(2),th)*cos(th) 2*df(v(1),fi) 2*df(v(1),th)
  111. + --------------------- + --------------- + ---------------
  112. 2 sin(th)*r 2
  113. sin(th)*r r
  114. 2
  115. - 2*sin(th) *v(3)*r - v(2)
  116. + ----------------------------- ,
  117. 2 2
  118. sin(th) *r
  119. df(v(3),fi,2) 2*df(v(3),r) df(v(3),th,2)
  120. --------------- + df(v(3),r,2) + -------------- + ---------------
  121. 2 2 r 2
  122. sin(th) *r r
  123. df(v(3),th)*cos(th) 2*df(v(2),fi)*cos(th)
  124. + --------------------- + ----------------------- + 2*df(v(2),r)
  125. 2 2 2
  126. sin(th)*r sin(th) *r
  127. 2
  128. 2*df(v(1),fi) - 2*df(v(1),th) 2*sin(th) *v(2)*r - v(3)
  129. + --------------- + ------------------ + -------------------------- )
  130. 2 r 2 2
  131. sin(th)*r sin(th) *r
  132. a5:=lapl f;
  133. df(f,fi,2) 2*df(f,r) df(f,th,2) df(f,th)*cos(th)
  134. a5:=------------- + df(f,r,2) + ----------- + ------------ + ------------------
  135. 2 2 r 2 2
  136. sin(th) *r r sin(th)*r
  137. a1:=a1+div w;
  138. df(w(3,1),fi) df(w(2,1),th)
  139. a1:= ( --------------- + --------------- + df(w(1,1),r) + df(f,r)
  140. sin(th)*r r
  141. cos(th)*w(2,1) - sin(th)*w(3,3) - sin(th)*w(2,2) + 2*sin(th)*w(1,1)
  142. + ---------------------------------------------------------------------
  143. sin(th)*r
  144. ,
  145. df(w(3,2),fi) df(w(2,2),th) df(f,th)
  146. --------------- + --------------- + df(w(1,2),r) + ---------- +
  147. sin(th)*r r r
  148. - cos(th)*w(3,3) + cos(th)*w(2,2) + sin(th)*w(2,1) + 2*sin(th)*w(1,2)
  149. ------------------------------------------------------------------------
  150. sin(th)*r
  151. ,
  152. df(w(3,3),fi) df(w(2,3),th) df(f,fi)
  153. --------------- + --------------- + df(w(1,3),r) + -----------
  154. sin(th)*r r sin(th)*r
  155. cos(th)*w(3,2) + cos(th)*w(2,3) + sin(th)*w(3,1) + 2*sin(th)*w(1,3)
  156. + ---------------------------------------------------------------------
  157. sin(th)*r
  158. )
  159. a1:=u.dyad((a,0,1),(1,b,3),(0,c,d));
  160. a1:= ( u(2) + u(1)*a ,
  161. u(3)*c + u(2)*b ,
  162. u(3)*d + 3*u(2) + u(1) )
  163. a2:=vect(a,b,c);
  164. a2:= ( a ,
  165. b ,
  166. c )
  167. a1.a2;
  168. 2 2
  169. u(3)*b*c + u(3)*c*d + u(2)*a + u(2)*b + 3*u(2)*c + u(1)*a + u(1)*c
  170. % Scalar product
  171. u.v;
  172. u(3)*v(3) + u(2)*v(2) + u(1)*v(1)
  173. % Vector product
  174. u?v;
  175. ( - u(3)*v(2) + u(2)*v(3) ,
  176. u(3)*v(1) - u(1)*v(3) ,
  177. - u(2)*v(1) + u(1)*v(2) )
  178. % Dyadic
  179. u&v;
  180. ( ( u(1)*v(1) ,
  181. u(1)*v(2) ,
  182. u(1)*v(3) ) ,
  183. ( u(2)*v(1) ,
  184. u(2)*v(2) ,
  185. u(2)*v(3) ) ,
  186. ( u(3)*v(1) ,
  187. u(3)*v(2) ,
  188. u(3)*v(3) ) )
  189. % Directional derivative
  190. dirdf(u,v);
  191. df(v(1),fi)*u(3) df(v(1),th)*u(2)
  192. ( ------------------ + df(v(1),r)*u(1) + ------------------
  193. sin(th)*r r
  194. u(3)*v(3) + u(2)*v(2)
  195. - ----------------------- ,
  196. r
  197. df(v(2),fi)*u(3) df(v(2),th)*u(2)
  198. ------------------ + df(v(2),r)*u(1) + ------------------
  199. sin(th)*r r
  200. - cos(th)*u(3)*v(3) + sin(th)*u(2)*v(1)
  201. + ------------------------------------------ ,
  202. sin(th)*r
  203. df(v(3),fi)*u(3) df(v(3),th)*u(2)
  204. ------------------ + df(v(3),r)*u(1) + ------------------
  205. sin(th)*r r
  206. u(3)*(cos(th)*v(2) + sin(th)*v(1))
  207. + ------------------------------------ )
  208. sin(th)*r
  209. clear a1,a2,a3,a4,a5,u,v,w;
  210. for all x,y clear diff(x,y);
  211. clear cos th**2,
  212. cos fi**2;
  213. remfac df;
  214. off rat;
  215. scalefactors 3,x,y,z,x,y,z;
  216. %***********************************************************************
  217. %***** *****
  218. %***** T e s t Examples --- Module I I M E T *****
  219. %***** *****
  220. %***********************************************************************
  221. % Example I.1 - 1-D Lagrangian Hydrodynamics
  222. off exp;
  223. factor diff;
  224. on rat,eqfu;
  225. % Declare which indexes will be given to coordinates
  226. coordinates x,t into j,m;
  227. % Declares uniform grid in x coordinate
  228. grid uniform,x;
  229. % Declares dependencies of functions on coordinates
  230. dependence eta(t,x),v(t,x),eps(t,x),p(t,x);
  231. % Declares p as known function
  232. given p;
  233. same eta,v,p;
  234. iim a, eta,diff(eta,t)-eta*diff(v,x)=0,
  235. v,diff(v,t)+eta/ro*diff(p,x)=0,
  236. eps,diff(eps,t)+eta*p/ro*diff(v,x)=0;
  237. *****************************
  238. ***** Program ***** IIMET Ver 1.1.2
  239. *****************************
  240. Partial Differential Equations
  241. ==============================
  242. diff(eta,t) - diff(v,x)*eta = 0
  243. diff(p,x)*eta
  244. --------------- + diff(v,t) = 0
  245. ro
  246. diff(v,x)*eta*p
  247. diff(eps,t) + ----------------- = 0
  248. ro
  249. Backtracking needed in grid optimalization
  250. 0 interpolations are needed in x coordinate
  251. Equation for eta variable is integrated in half grid point
  252. Equation for v variable is integrated in half grid point
  253. Equation for eps variable is integrated in half grid point
  254. 0 interpolations are needed in t coordinate
  255. Equation for eta variable is integrated in half grid point
  256. Equation for v variable is integrated in half grid point
  257. Equation for eps variable is integrated in half grid point
  258. Equations after Discretization Using IIM :
  259. ==========================================
  260. (4*(eta(j,m + 1) - eta(j,m) - eta(j + 1,m) + eta(j + 1,m + 1))*hx - (
  261. (eta(j + 1,m + 1) + eta(j,m + 1))*(v(j + 1,m + 1) - v(j,m + 1))
  262. + (eta(j + 1,m) + eta(j,m))*(v(j + 1,m) - v(j,m)))*(ht(m + 1) + ht(m)))/(4
  263. *(ht(m + 1) + ht(m))*hx) = 0
  264. (4*(v(j,m + 1) - v(j,m) - v(j + 1,m) + v(j + 1,m + 1))*hx*ro + (
  265. (eta(j + 1,m + 1) + eta(j,m + 1))*(p(j + 1,m + 1) - p(j,m + 1))
  266. + (eta(j + 1,m) + eta(j,m))*(p(j + 1,m) - p(j,m)))*(ht(m + 1) + ht(m)))/(4
  267. *(ht(m + 1) + ht(m))*hx*ro) = 0
  268. (4*(eps(j,m + 1) - eps(j,m) - eps(j + 1,m) + eps(j + 1,m + 1))*hx*ro + (
  269. (eta(j + 1,m + 1)*p(j + 1,m + 1) + eta(j,m + 1)*p(j,m + 1))
  270. *(v(j + 1,m + 1) - v(j,m + 1))
  271. + (eta(j + 1,m)*p(j + 1,m) + eta(j,m)*p(j,m))*(v(j + 1,m) - v(j,m)))
  272. *(ht(m + 1) + ht(m)))/(4*(ht(m + 1) + ht(m))*hx*ro) = 0
  273. clear a;
  274. clearsame;
  275. cleargiven;
  276. %***********************************************************************
  277. % Example I.2 - How other functions (here sin, cos) can be used in
  278. % discretized terms
  279. diffunc sin,cos;
  280. difmatch all,diff(u*sin x,x),u=one,2,(u(i+1)*sin x(i+1)-u(i-1)
  281. *sin x(i-1))/(dim1+dip1),
  282. u=half,0,(u(i+1/2)*sin x(i+1/2)-u(i-1/2)*sin x(i-1/2))
  283. /di;
  284. difmatch all,cos x*diff(u,x,2),u=one,0,cos x i*(u(i+1)-2*u(i)+u(i-1))
  285. /di^2,
  286. u=half,3,(u(i+3/2)-u(i+1/2))/dip2/2 -
  287. (u(i-1/2)-u(i-3/2))/dim2/2;
  288. off exp;
  289. coordinates x,t into j,m;
  290. grid uniform,x,t;
  291. dependence u(x,t),v(x,t);
  292. iim a,u,diff(u,t)+diff(u,x)+cos x*diff(v,x,2)=0,
  293. v,diff(v,t)+diff(sin x*u,x)=0;
  294. *****************************
  295. ***** Program ***** IIMET Ver 1.1.2
  296. *****************************
  297. Partial Differential Equations
  298. ==============================
  299. diff(u,t) + diff(u,x) + diff(v,x,2)*cos(x) = 0
  300. diff(sin(x)*u,x) + diff(v,t) = 0
  301. 0 interpolations are needed in x coordinate
  302. Equation for u variable is integrated in half grid point
  303. Equation for v variable is integrated in half grid point
  304. 0 interpolations are needed in t coordinate
  305. Equation for u variable is integrated in half grid point
  306. Equation for v variable is integrated in half grid point
  307. Equations after Discretization Using IIM :
  308. ==========================================
  309. 2*j + 1 2*j + 1 2*j + 3
  310. - ((2*(v(---------,m + 1) + v(---------,m)) - v(---------,m)
  311. 2 2 2
  312. 2*j + 3 2*j - 1 2*j - 1
  313. - v(---------,m + 1) - v(---------,m) - v(---------,m + 1))
  314. 2 2 2
  315. 2*j + 1
  316. *cos(x(---------))*ht + (
  317. 2
  318. (u(j,m + 1) + u(j,m) - u(j + 1,m) - u(j + 1,m + 1))*ht
  319. 2
  320. - (u(j,m + 1) - u(j,m) - u(j + 1,m) + u(j + 1,m + 1))*hx)*hx)/(2*ht*hx )
  321. = 0
  322. ( - ((u(j,m + 1) + u(j,m))*sin(x(j))*ht
  323. 2*j + 1 2*j + 1
  324. - 2*(v(---------,m + 1) - v(---------,m))*hx)
  325. 2 2
  326. + (u(j + 1,m + 1) + u(j + 1,m))*sin(x(j + 1))*ht)/(2*ht*hx) = 0
  327. clear a;
  328. %***********************************************************************
  329. % Example I.3 - Schrodinger equation
  330. factor diff;
  331. coordinates t,x into m,j;
  332. grid uniform,x,t;
  333. dependence ur(x,t),ui(x,t);
  334. same ui,ur;
  335. iim a,ur,-diff(ui,t)+1/2*diff(ur,x,2)+(ur**2+ui**2)*ur=0,
  336. ui,diff(ur,t)+1/2*diff(ui,x,2)+(ur**2+ui**2)*ui=0;
  337. *****************************
  338. ***** Program ***** IIMET Ver 1.1.2
  339. *****************************
  340. Partial Differential Equations
  341. ==============================
  342. diff(ur,x,2) 2 2
  343. - diff(ui,t) + -------------- = - ur*(ui + ur )
  344. 2
  345. diff(ui,x,2) 2 2
  346. -------------- + diff(ur,t) = - ui*(ui + ur )
  347. 2
  348. 0 interpolations are needed in t coordinate
  349. Equation for ur variable is integrated in half grid point
  350. Equation for ui variable is integrated in half grid point
  351. 0 interpolations are needed in x coordinate
  352. Equation for ur variable is integrated in one grid point
  353. Equation for ui variable is integrated in one grid point
  354. Equations after Discretization Using IIM :
  355. ==========================================
  356. ((ur(m,j + 1) - 2*ur(m,j) + ur(m,j - 1) - 2*ur(m + 1,j) + ur(m + 1,j + 1)
  357. 2 2
  358. + ur(m + 1,j - 1))*ht - 4*(ui(m + 1,j) - ui(m,j))*hx )/(4*ht*hx ) =
  359. 3 3 2 2
  360. ur(m + 1,j) + ur(m,j) + ui(m,j) *ur(m,j) + ui(m + 1,j) *ur(m + 1,j)
  361. - -----------------------------------------------------------------------
  362. 2
  363. ((ui(m,j + 1) - 2*ui(m,j) + ui(m,j - 1) - 2*ui(m + 1,j) + ui(m + 1,j + 1)
  364. 2 2
  365. + ui(m + 1,j - 1))*ht + 4*(ur(m + 1,j) - ur(m,j))*hx )/(4*ht*hx ) =
  366. 2 2 2 2
  367. (ui(m + 1,j) + ur(m + 1,j) )*ui(m + 1,j) + (ui(m,j) + ur(m,j) )*ui(m,j)
  368. - ---------------------------------------------------------------------------
  369. 2
  370. clear a;
  371. clearsame;
  372. %***********************************************************************
  373. % Example I.4 - Vector calculus in p.d.e. input
  374. % cooperation with expres module
  375. % 2-D hydrodynamics
  376. scalefactors 2,x,y,x,y;
  377. vectors u;
  378. off exp,twogrid;
  379. on eqfu;
  380. factor diff,ht,hx,hy;
  381. coordinates x,y,t into j,i,m;
  382. grid uniform,x,y,t;
  383. dependence n(t,x,y),u(t,x,y),p(t,x,y);
  384. iim a,n,diff(n,t)+u.grad n+n*div u=0,
  385. u,m*n*(diff(u,t)+u.grad u)+grad p=vect(0,0),
  386. p,3/2*(diff(p,t)+u.grad p)+5/2*p*div u=0;
  387. *****************************
  388. ***** Program ***** IIMET Ver 1.1.2
  389. *****************************
  390. Partial Differential Equations
  391. ==============================
  392. diff(n,t) + diff(n,x)*u1 + diff(n,y)*u2 + diff(u1,x)*n + diff(u2,y)*n = 0
  393. diff(p,x) + diff(u1,t)*m*n + diff(u1,x)*m*n*u1 + diff(u1,y)*m*n*u2 = 0
  394. diff(p,y) + diff(u2,t)*m*n + diff(u2,x)*m*n*u1 + diff(u2,y)*m*n*u2 = 0
  395. 3*diff(p,t) 3*diff(p,x)*u1 3*diff(p,y)*u2 5*diff(u1,x)*p
  396. ------------- + ---------------- + ---------------- + ----------------
  397. 2 2 2 2
  398. 5*diff(u2,y)*p
  399. + ---------------- = 0
  400. 2
  401. 0 interpolations are needed in x coordinate
  402. Equation for n variable is integrated in half grid point
  403. Equation for u1 variable is integrated in half grid point
  404. Equation for u2 variable is integrated in half grid point
  405. Equation for p variable is integrated in half grid point
  406. 0 interpolations are needed in y coordinate
  407. Equation for n variable is integrated in half grid point
  408. Equation for u1 variable is integrated in half grid point
  409. Equation for u2 variable is integrated in half grid point
  410. Equation for p variable is integrated in half grid point
  411. 0 interpolations are needed in t coordinate
  412. Equation for n variable is integrated in half grid point
  413. Equation for u1 variable is integrated in half grid point
  414. Equation for u2 variable is integrated in half grid point
  415. Equation for p variable is integrated in half grid point
  416. Equations after Discretization Using IIM :
  417. ==========================================
  418. -1 -1
  419. (hy *hx *(n(j + 1,i + 1,m + 1)*u1(j + 1,i + 1,m + 1)*hy
  420. + n(j + 1,i + 1,m + 1)*u2(j + 1,i + 1,m + 1)*hx
  421. + n(j + 1,i + 1,m)*u1(j + 1,i + 1,m)*hy
  422. + n(j + 1,i + 1,m)*u2(j + 1,i + 1,m)*hx
  423. + n(j + 1,i,m + 1)*u1(j + 1,i,m + 1)*hy
  424. - n(j + 1,i,m + 1)*u2(j + 1,i,m + 1)*hx
  425. + n(j + 1,i,m)*u1(j + 1,i,m)*hy - n(j + 1,i,m)*u2(j + 1,i,m)*hx
  426. - n(j,i + 1,m + 1)*u1(j,i + 1,m + 1)*hy
  427. + n(j,i + 1,m + 1)*u2(j,i + 1,m + 1)*hx
  428. - n(j,i + 1,m)*u1(j,i + 1,m)*hy + n(j,i + 1,m)*u2(j,i + 1,m)*hx
  429. - n(j,i,m + 1)*u1(j,i,m + 1)*hy - n(j,i,m + 1)*u2(j,i,m + 1)*hx
  430. -1
  431. - n(j,i,m)*u1(j,i,m)*hy - n(j,i,m)*u2(j,i,m)*hx))/4 + (ht *(
  432. n(j,i,m + 1) - n(j,i,m) - n(j,i + 1,m) + n(j,i + 1,m + 1) - n(j + 1,i,m)
  433. + n(j + 1,i,m + 1) - n(j + 1,i + 1,m) + n(j + 1,i + 1,m + 1)))/4 = 0
  434. -1
  435. (hx *((n(j + 1,i,m + 1)*u1(j + 1,i,m + 1) + n(j,i,m + 1)*u1(j,i,m + 1))
  436. *(u1(j + 1,i,m + 1) - u1(j,i,m + 1)) +
  437. (n(j + 1,i,m)*u1(j + 1,i,m) + n(j,i,m)*u1(j,i,m))
  438. *(u1(j + 1,i,m) - u1(j,i,m)) +
  439. (n(j + 1,i + 1,m)*u1(j + 1,i + 1,m) + n(j,i + 1,m)*u1(j,i + 1,m))
  440. *(u1(j + 1,i + 1,m) - u1(j,i + 1,m)) + (
  441. n(j + 1,i + 1,m + 1)*u1(j + 1,i + 1,m + 1)
  442. + n(j,i + 1,m + 1)*u1(j,i + 1,m + 1))
  443. -1 -1 -1
  444. *(u1(j + 1,i + 1,m + 1) - u1(j,i + 1,m + 1)))*m)/8 + (hy *hx *ht *(((
  445. (n(j,i + 1,m + 1) + n(j,i + 1,m))
  446. *(u1(j,i + 1,m + 1) - u1(j,i + 1,m))
  447. + (n(j,i,m + 1) + n(j,i,m))*(u1(j,i,m + 1) - u1(j,i,m)) +
  448. (n(j + 1,i,m + 1) + n(j + 1,i,m))
  449. *(u1(j + 1,i,m + 1) - u1(j + 1,i,m)) +
  450. (n(j + 1,i + 1,m + 1) + n(j + 1,i + 1,m))
  451. *(u1(j + 1,i + 1,m + 1) - u1(j + 1,i + 1,m)))*hx*m + 2*(
  452. p(j + 1,i,m + 1) + p(j + 1,i,m) + p(j + 1,i + 1,m)
  453. + p(j + 1,i + 1,m + 1)
  454. - (p(j,i,m + 1) + p(j,i,m) + p(j,i + 1,m) + p(j,i + 1,m + 1)))*ht)
  455. *hy + ((n(j,i + 1,m + 1)*u2(j,i + 1,m + 1) + n(j,i,m + 1)*u2(j,i,m + 1))
  456. *(u1(j,i + 1,m + 1) - u1(j,i,m + 1)) +
  457. (n(j,i + 1,m)*u2(j,i + 1,m) + n(j,i,m)*u2(j,i,m))
  458. *(u1(j,i + 1,m) - u1(j,i,m)) +
  459. (n(j + 1,i + 1,m)*u2(j + 1,i + 1,m) + n(j + 1,i,m)*u2(j + 1,i,m))
  460. *(u1(j + 1,i + 1,m) - u1(j + 1,i,m)) + (
  461. n(j + 1,i + 1,m + 1)*u2(j + 1,i + 1,m + 1)
  462. + n(j + 1,i,m + 1)*u2(j + 1,i,m + 1))
  463. *(u1(j + 1,i + 1,m + 1) - u1(j + 1,i,m + 1)))*ht*hx*m))/8 = 0
  464. -1 -1
  465. (hy *hx *(((n(j + 1,i,m + 1)*u1(j + 1,i,m + 1) + n(j,i,m + 1)*u1(j,i,m + 1))
  466. *(u2(j + 1,i,m + 1) - u2(j,i,m + 1)) +
  467. (n(j + 1,i,m)*u1(j + 1,i,m) + n(j,i,m)*u1(j,i,m))
  468. *(u2(j + 1,i,m) - u2(j,i,m)) +
  469. (n(j + 1,i + 1,m)*u1(j + 1,i + 1,m) + n(j,i + 1,m)*u1(j,i + 1,m))
  470. *(u2(j + 1,i + 1,m) - u2(j,i + 1,m)) + (
  471. n(j + 1,i + 1,m + 1)*u1(j + 1,i + 1,m + 1)
  472. + n(j,i + 1,m + 1)*u1(j,i + 1,m + 1))
  473. *(u2(j + 1,i + 1,m + 1) - u2(j,i + 1,m + 1)))*hy + (
  474. (n(j,i + 1,m + 1)*u2(j,i + 1,m + 1) + n(j,i,m + 1)*u2(j,i,m + 1))
  475. *(u2(j,i + 1,m + 1) - u2(j,i,m + 1)) +
  476. (n(j,i + 1,m)*u2(j,i + 1,m) + n(j,i,m)*u2(j,i,m))
  477. *(u2(j,i + 1,m) - u2(j,i,m)) +
  478. (n(j + 1,i + 1,m)*u2(j + 1,i + 1,m) + n(j + 1,i,m)*u2(j + 1,i,m))
  479. *(u2(j + 1,i + 1,m) - u2(j + 1,i,m)) + (
  480. n(j + 1,i + 1,m + 1)*u2(j + 1,i + 1,m + 1)
  481. + n(j + 1,i,m + 1)*u2(j + 1,i,m + 1))
  482. -1
  483. *(u2(j + 1,i + 1,m + 1) - u2(j + 1,i,m + 1)))*hx)*m)/8 + ( - hy
  484. -1
  485. *ht *(2*(p(j,i,m + 1) + p(j,i,m) - p(j,i + 1,m) - p(j,i + 1,m + 1)
  486. + p(j + 1,i,m) + p(j + 1,i,m + 1) - p(j + 1,i + 1,m)
  487. - p(j + 1,i + 1,m + 1))*ht - ((n(j,i + 1,m + 1) + n(j,i + 1,m))
  488. *(u2(j,i + 1,m + 1) - u2(j,i + 1,m))
  489. + (n(j,i,m + 1) + n(j,i,m))*(u2(j,i,m + 1) - u2(j,i,m)) +
  490. (n(j + 1,i,m + 1) + n(j + 1,i,m))
  491. *(u2(j + 1,i,m + 1) - u2(j + 1,i,m)) +
  492. (n(j + 1,i + 1,m + 1) + n(j + 1,i + 1,m))
  493. *(u2(j + 1,i + 1,m + 1) - u2(j + 1,i + 1,m)))*hy*m))/8 = 0
  494. -1 -1
  495. (hy *hx *(3*((p(j + 1,i,m + 1) - p(j,i,m + 1))
  496. *(u1(j + 1,i,m + 1) + u1(j,i,m + 1))
  497. + (p(j + 1,i,m) - p(j,i,m))*(u1(j + 1,i,m) + u1(j,i,m)) +
  498. (p(j + 1,i + 1,m) - p(j,i + 1,m))
  499. *(u1(j + 1,i + 1,m) + u1(j,i + 1,m)) +
  500. (p(j + 1,i + 1,m + 1) - p(j,i + 1,m + 1))
  501. *(u1(j + 1,i + 1,m + 1) + u1(j,i + 1,m + 1)))*hy + 2*(
  502. 4*p(j + 1,i + 1,m + 1)*u2(j + 1,i + 1,m + 1)
  503. - p(j + 1,i + 1,m + 1)*u2(j + 1,i,m + 1)
  504. + 4*p(j + 1,i + 1,m)*u2(j + 1,i + 1,m)
  505. - p(j + 1,i + 1,m)*u2(j + 1,i,m)
  506. + p(j + 1,i,m + 1)*u2(j + 1,i + 1,m + 1)
  507. - 4*p(j + 1,i,m + 1)*u2(j + 1,i,m + 1)
  508. + p(j + 1,i,m)*u2(j + 1,i + 1,m) - 4*p(j + 1,i,m)*u2(j + 1,i,m)
  509. + 4*p(j,i + 1,m + 1)*u2(j,i + 1,m + 1)
  510. - p(j,i + 1,m + 1)*u2(j,i,m + 1) + 4*p(j,i + 1,m)*u2(j,i + 1,m)
  511. - p(j,i + 1,m)*u2(j,i,m) + p(j,i,m + 1)*u2(j,i + 1,m + 1)
  512. - 4*p(j,i,m + 1)*u2(j,i,m + 1) + p(j,i,m)*u2(j,i + 1,m)
  513. - 4*p(j,i,m)*u2(j,i,m))*hx + 5*(
  514. (p(j + 1,i,m + 1) + p(j,i,m + 1))
  515. *(u1(j + 1,i,m + 1) - u1(j,i,m + 1))
  516. + (p(j + 1,i,m) + p(j,i,m))*(u1(j + 1,i,m) - u1(j,i,m)) +
  517. (p(j + 1,i + 1,m) + p(j,i + 1,m))
  518. *(u1(j + 1,i + 1,m) - u1(j,i + 1,m)) +
  519. (p(j + 1,i + 1,m + 1) + p(j,i + 1,m + 1))
  520. -1
  521. *(u1(j + 1,i + 1,m + 1) - u1(j,i + 1,m + 1)))*hy))/16 + (3*ht *(
  522. p(j,i,m + 1) - p(j,i,m) - p(j,i + 1,m) + p(j,i + 1,m + 1) - p(j + 1,i,m)
  523. + p(j + 1,i,m + 1) - p(j + 1,i + 1,m) + p(j + 1,i + 1,m + 1)))/8 = 0
  524. clear a,u;
  525. %***********************************************************************
  526. % Example I.5 - 1-D hydrodynamics up to 3-rd moments (heat flow)
  527. coordinates x,t into j,m;
  528. grid uniform,x,t;
  529. dependence n(x,t),u(x,t),tt(x,t),p(x,t),q(x,t);
  530. iim a, n,diff(n,t)+u*diff(n,x)+diff(u,x)=0,
  531. u,n*m*(diff(u,t)+u*diff(u,x))+k*diff(n*tt,x)+diff(p,x)=0,
  532. tt,3/2*k*n*(diff(tt,t)+u*diff(tt,x))+n*k*tt*diff(u,x)+1/2*p
  533. *diff(u,x)+diff(q,x)=0,
  534. p,diff(p,t)+u*diff(p,x)+p*diff(u,x)+n*k*tt*diff(u,x)+2/5*diff(q,x)
  535. =0,
  536. q,diff(q,t)+u*diff(q,x)+q*diff(u,x)+5/2*n*k**2*tt/m*diff(tt,x)+n*k
  537. *tt*diff(p,x)-p*diff(p,x)=0;
  538. *****************************
  539. ***** Program ***** IIMET Ver 1.1.2
  540. *****************************
  541. Partial Differential Equations
  542. ==============================
  543. diff(n,t) + diff(n,x)*u + diff(u,x) = 0
  544. diff(n*tt,x)*k + diff(p,x) + diff(u,t)*m*n + diff(u,x)*m*n*u = 0
  545. 3*diff(tt,t)*k*n 3*diff(tt,x)*k*n*u
  546. diff(q,x) + ------------------ + --------------------
  547. 2 2
  548. diff(u,x)*(2*k*n*tt + p)
  549. + -------------------------- = 0
  550. 2
  551. 2*diff(q,x)
  552. diff(p,t) + diff(p,x)*u + ------------- + diff(u,x)*(k*n*tt + p) = 0
  553. 5
  554. 2
  555. 5*diff(tt,x)*k *n*tt
  556. diff(p,x)*(k*n*tt - p) + diff(q,t) + diff(q,x)*u + ----------------------
  557. 2*m
  558. + diff(u,x)*q = 0
  559. 0 interpolations are needed in x coordinate
  560. Equation for n variable is integrated in half grid point
  561. Equation for u variable is integrated in half grid point
  562. Equation for tt variable is integrated in half grid point
  563. Equation for p variable is integrated in half grid point
  564. Equation for q variable is integrated in half grid point
  565. 0 interpolations are needed in t coordinate
  566. Equation for n variable is integrated in half grid point
  567. Equation for u variable is integrated in half grid point
  568. Equation for tt variable is integrated in half grid point
  569. Equation for p variable is integrated in half grid point
  570. Equation for q variable is integrated in half grid point
  571. Equations after Discretization Using IIM :
  572. ==========================================
  573. -1
  574. (hx *((n(j + 1,m + 1) - n(j,m + 1))*(u(j + 1,m + 1) + u(j,m + 1))
  575. + (n(j + 1,m) - n(j,m))*(u(j + 1,m) + u(j,m))
  576. + 2*(u(j + 1,m + 1) + u(j + 1,m) - (u(j,m + 1) + u(j,m)))))/4
  577. -1
  578. ht *(n(j,m + 1) - n(j,m) - n(j + 1,m) + n(j + 1,m + 1))
  579. + ---------------------------------------------------------- = 0
  580. 2
  581. -1
  582. ( - hx *(n(j,m + 1)*tt(j,m + 1) + n(j,m)*tt(j,m) - n(j + 1,m)*tt(j + 1,m)
  583. -1 -1
  584. - n(j + 1,m + 1)*tt(j + 1,m + 1))*k)/2 + (hx *ht *((
  585. (n(j + 1,m + 1) + n(j + 1,m))*(u(j + 1,m + 1) - u(j + 1,m))
  586. + (n(j,m + 1) + n(j,m))*(u(j,m + 1) - u(j,m)))*hx*m
  587. + 2*(p(j + 1,m + 1) + p(j + 1,m) - (p(j,m + 1) + p(j,m)))*ht + (
  588. (n(j + 1,m + 1)*u(j + 1,m + 1) + n(j,m + 1)*u(j,m + 1))
  589. *(u(j + 1,m + 1) - u(j,m + 1))
  590. + (n(j + 1,m)*u(j + 1,m) + n(j,m)*u(j,m))*(u(j + 1,m) - u(j,m)))*ht*m)
  591. )/4 = 0
  592. -1
  593. (hx *((n(j + 1,m + 1)*tt(j + 1,m + 1) + n(j,m + 1)*tt(j,m + 1))
  594. *(u(j + 1,m + 1) - u(j,m + 1))
  595. + (n(j + 1,m)*tt(j + 1,m) + n(j,m)*tt(j,m))*(u(j + 1,m) - u(j,m)))*k)/4
  596. -1 -1
  597. + (hx *ht *(((p(j + 1,m + 1) + p(j,m + 1))*(u(j + 1,m + 1) - u(j,m + 1))
  598. + (p(j + 1,m) + p(j,m))*(u(j + 1,m) - u(j,m))
  599. + 4*(q(j + 1,m + 1) + q(j + 1,m) - (q(j,m + 1) + q(j,m))))*ht +
  600. 3*((n(j + 1,m + 1) + n(j + 1,m))*(tt(j + 1,m + 1) - tt(j + 1,m))
  601. + (n(j,m + 1) + n(j,m))*(tt(j,m + 1) - tt(j,m)))*hx*k + 3*(
  602. (n(j + 1,m + 1)*u(j + 1,m + 1) + n(j,m + 1)*u(j,m + 1))
  603. *(tt(j + 1,m + 1) - tt(j,m + 1)) +
  604. (n(j + 1,m)*u(j + 1,m) + n(j,m)*u(j,m))*(tt(j + 1,m) - tt(j,m))
  605. )*ht*k))/8 = 0
  606. -1
  607. (hx *(5*((n(j + 1,m + 1)*tt(j + 1,m + 1) + n(j,m + 1)*tt(j,m + 1))
  608. *(u(j + 1,m + 1) - u(j,m + 1))
  609. + (n(j + 1,m)*tt(j + 1,m) + n(j,m)*tt(j,m))*(u(j + 1,m) - u(j,m)))*k
  610. + 2*(5*p(j + 1,m + 1)*u(j + 1,m + 1) + 5*p(j + 1,m)*u(j + 1,m)
  611. - 5*p(j,m + 1)*u(j,m + 1) - 5*p(j,m)*u(j,m) + 2*q(j + 1,m + 1)
  612. + 2*q(j + 1,m) - 2*q(j,m + 1) - 2*q(j,m))))/20
  613. -1
  614. ht *(p(j,m + 1) - p(j,m) - p(j + 1,m) + p(j + 1,m + 1))
  615. + ---------------------------------------------------------- = 0
  616. 2
  617. -1
  618. ( - hx *(2*((p(j + 1,m + 1) + p(j,m + 1))*(p(j + 1,m + 1) - p(j,m + 1))
  619. + (p(j + 1,m) + p(j,m))*(p(j + 1,m) - p(j,m)) - 2*(
  620. q(j + 1,m + 1)*u(j + 1,m + 1) + q(j + 1,m)*u(j + 1,m)
  621. - q(j,m + 1)*u(j,m + 1) - q(j,m)*u(j,m)))*m - 5*(
  622. (n(j + 1,m + 1)*tt(j + 1,m + 1) + n(j,m + 1)*tt(j,m + 1))
  623. *(tt(j + 1,m + 1) - tt(j,m + 1)) +
  624. (n(j + 1,m)*tt(j + 1,m) + n(j,m)*tt(j,m))*(tt(j + 1,m) - tt(j,m)))
  625. 2
  626. *k - 2*((n(j + 1,m + 1)*tt(j + 1,m + 1) + n(j,m + 1)*tt(j,m + 1))
  627. *(p(j + 1,m + 1) - p(j,m + 1))
  628. + (n(j + 1,m)*tt(j + 1,m) + n(j,m)*tt(j,m))*(p(j + 1,m) - p(j,m)))
  629. *k*m))/(8*m)
  630. -1
  631. ht *(q(j,m + 1) - q(j,m) - q(j + 1,m) + q(j + 1,m + 1))
  632. + ---------------------------------------------------------- = 0
  633. 2
  634. clear a;
  635. remfac diff,ht,hx,hy;
  636. on exp;
  637. off rat;
  638. %***********************************************************************
  639. %***** *****
  640. %***** T e s t Examples --- Module A P P R O X *****
  641. %***** *****
  642. %***********************************************************************
  643. % Example A.1
  644. coordinates x,t into j,n;
  645. maxorder t=2,x=3;
  646. functions u,v;
  647. approx( (u(n+1/2)-u(n-1/2))/ht=(v(n+1/2,j+1/2)-v(n+1/2,j-1/2)
  648. +v(n-1/2,j+1/2)-v(n-1/2,j-1/2))/(2*hx) );
  649. Difference scheme approximates differential equation df(u,t)=df(v,x)
  650. with orders of approximation:
  651. 2
  652. hx
  653. 2
  654. ht
  655. % Example A.2
  656. maxorder t=3,x=3;
  657. approx( (u(n+1)-u(n))/ht=(u(n+1,j+1/2)-u(n+1,j-1/2)
  658. +u(n,j+1/2)-u(n,j-1/2))/(2*hx) );
  659. Difference scheme approximates differential equation df(u,t)=df(u,x)
  660. with orders of approximation:
  661. 2
  662. hx
  663. ht
  664. % Example A.3
  665. maxorder t=2,x=3;
  666. center t=1/2;
  667. approx( (u(n+1)-u(n))/ht=(v(n+1,j+1/2)-v(n+1,j-1/2)
  668. +v(n,j+1/2)-v(n,j-1/2))/(2*hx) );
  669. Difference scheme approximates differential equation df(u,t)=df(v,x)
  670. with orders of approximation:
  671. 2
  672. hx
  673. 2
  674. ht
  675. % Example A.4
  676. approx( u(n+1)/ht=(v(n+1,j+1/2)-v(n+1,j-1/2)
  677. +v(n,j+1/2)-v(n,j-1/2))/(2*hx) );
  678. Reformulate difference scheme, grid steps remain in denominators
  679. Difference scheme approximates differential equation 0=df(v,x)
  680. with orders of approximation:
  681. 2
  682. hx
  683. -1
  684. ht
  685. % Example A.5
  686. maxorder t=3,x=3;
  687. approx( (u(n+1)-u(n))/ht=(u(n+1,j+1/2)-u(n+1,j-1/2))/hx);
  688. Difference scheme approximates differential equation df(u,t)=df(u,x)
  689. with orders of approximation:
  690. 2
  691. hx
  692. ht
  693. % Example A.6
  694. approx( (u(n+1)-u(n))/ht=(u(n+1/2,j+1/2)-u(n+1/2,j-1/2))/hx);
  695. Difference scheme approximates differential equation df(u,t)=df(u,x)
  696. with orders of approximation:
  697. 2
  698. hx
  699. 2
  700. ht
  701. % Example A.7;
  702. maxorder x=4;
  703. approx((u(n+1)-u(n))/ht=(u(n+1/2,j+1)-2*u(n+1/2,j)+u(n+1/2,j-1))/hx**2);
  704. Difference scheme approximates differential equation df(u,t)=df(u,x,2)
  705. with orders of approximation:
  706. 2
  707. hx
  708. 2
  709. ht
  710. %***********************************************************************
  711. %***** *****
  712. %***** T e s t Examples --- Module C H A R P O L *****
  713. %***** *****
  714. %***********************************************************************
  715. % Example C.1
  716. coordinates t,x into i,j;
  717. grid uniform,t,x;
  718. let cos ax**2=1-sin ax**2;
  719. unfunc u,v;
  720. matrix aa(1,2),bb(2,2);
  721. aa(1,1):=(u(i+1)-u(i))/ht+(v(j+1)-v(j))/hx$
  722. aa(1,2):=(v(i+1)-v(i))/ht+(u(j+1/2)-u(j-1/2))/hx$
  723. bb:=ampmat aa;
  724. kx*hx
  725. ax := -------
  726. 2
  727. [hx 0 ]
  728. h1 := [ ]
  729. [0 hx]
  730. [ hx 2*sin(ax)*ht*( - i*cos(ax) + sin(ax))]
  731. h0 := [ ]
  732. [ - 2*i*sin(ax)*ht hx ]
  733. [ 2*sin(ax)*ht*( - i*cos(ax) + sin(ax)) ]
  734. [ 1 ---------------------------------------]
  735. [ hx ]
  736. bb := [ ]
  737. [ - 2*i*sin(ax)*ht ]
  738. [------------------- 1 ]
  739. [ hx ]
  740. bb:=denotemat bb;
  741. [ 1 ai12*i + ar12]
  742. bb := [ ]
  743. [ai21*i 1 ]
  744. factor lam;
  745. pol:=charpol bb;
  746. 2
  747. pol := lam - 2*lam + ai12*ai21 - i*ai21*ar12 + 1
  748. prdenot;
  749. 2
  750. 2*sin(ax) *ht
  751. ar12 := ---------------
  752. hx
  753. - 2*cos(ax)*sin(ax)*ht
  754. ai12 := -------------------------
  755. hx
  756. - 2*sin(ax)*ht
  757. ai21 := -----------------
  758. hx
  759. cleardenot;
  760. clear aa,bb,pol;
  761. %***********************************************************************
  762. % Example C.2 : Reprint Vorozcov, Ganza, Mazurik: Simvolno-cislennyj
  763. % interfejs. v zadacach ..., Novosibirsk 1986, p.47.
  764. unfunc u;
  765. matrix aa(1,1),bb(1,1);
  766. aa(1,1):=(u(i+1)-u(i))/ht+a*(u(j)-u(j-1))/hx$
  767. bb:=ampmat aa;
  768. ax := kx*hx
  769. h1 := [hx]
  770. h0 := [cos(ax)*a*ht - i*sin(ax)*a*ht - a*ht + hx]
  771. [ cos(ax)*a*ht - i*sin(ax)*a*ht - a*ht + hx ]
  772. bb := [-------------------------------------------]
  773. [ hx ]
  774. bb:=denotemat bb;
  775. bb := [ai11*i + ar11]
  776. pol:=charpol bb;
  777. pol := lam - i*ai11 - ar11
  778. prdenot;
  779. cos(ax)*a*ht - a*ht + hx
  780. ar11 := --------------------------
  781. hx
  782. - sin(ax)*a*ht
  783. ai11 := -----------------
  784. hx
  785. cleardenot;
  786. clear aa,bb,pol;
  787. %***********************************************************************
  788. % Example C.3 : Reprint Vorozcov, Ganza, Mazurik: Simvolno-cislennyj
  789. % interfejs. v zadacach ..., Novosibirsk 1986, p.52.
  790. coordinates t,x into m,j;
  791. unfunc u,r;
  792. matrix aa(1,2),bb(2,2);
  793. aa(1,1):=(r(m+1)-r(m))/ht+u0*(r(m+1,j+1)-r(m+1,j-1))/2/hx
  794. +r0*(u(m+1,j+1)-u(m+1,j-1))/2/hx$
  795. aa(1,2):=(u(m+1)-u(m))/ht+u0*(u(m+1,j+1)-u(m+1,j-1))/2/hx
  796. +c0**2/r0*(r(m,j+1)-u(m,j-1))/2/hx$
  797. bb:=ampmat aa;
  798. ax := kx*hx
  799. [ i*sin(ax)*ht*r0 i*sin(ax)*ht*u0 + hx]
  800. h1 := [ ]
  801. [2*r0*(i*sin(ax)*ht*u0 + hx) 0 ]
  802. h0 := mat((0,hx),
  803. 2 2
  804. (cos(ax)*c0 *ht - i*sin(ax)*c0 *ht + 2*hx*r0,
  805. 2
  806. c0 *ht*( - cos(ax) - i*sin(ax))))
  807. 2 2
  808. - i*cos(ax)*c0 *ht - sin(ax)*c0 *ht - 2*i*hx*r0
  809. bb := mat((--------------------------------------------------,
  810. 2*r0*(sin(ax)*ht*u0 - i*hx)
  811. 2
  812. c0 *ht*(i*cos(ax) - sin(ax))
  813. ------------------------------),
  814. 2*r0*(sin(ax)*ht*u0 - i*hx)
  815. 2 2
  816. sin(ax)*ht*(i*cos(ax)*c0 *ht + sin(ax)*c0 *ht + 2*i*hx*r0)
  817. (------------------------------------------------------------,(
  818. 2 2 2 2
  819. 2*(sin(ax) *ht *u0 - 2*i*sin(ax)*ht*hx*u0 - hx )
  820. 2 2 2 2 2
  821. - i*cos(ax)*sin(ax)*c0 *ht + sin(ax) *c0 *ht
  822. 2
  823. - 2*i*sin(ax)*ht*hx*u0 - 2*hx )/(2
  824. 2 2 2 2
  825. *(sin(ax) *ht *u0 - 2*i*sin(ax)*ht*hx*u0 - hx ))))
  826. bb:=denotemat bb;
  827. [ai11*i + ar11 ai12*i + ar12]
  828. bb := [ ]
  829. [ai21*i + ar21 ai22*i + ar22]
  830. pol:=charpol bb;
  831. 2
  832. pol := lam + lam*( - i*ai11 - i*ai22 - ar11 - ar22) - ai11*ai22 + i*ai11*ar22
  833. + ai12*ai21 - i*ai12*ar21 - i*ai21*ar12 + i*ai22*ar11 + ar11*ar22
  834. - ar12*ar21
  835. prdenot;
  836. 2
  837. - c0
  838. ar11 := ---------
  839. 2*r0*u0
  840. 2 2
  841. - cos(ax)*c0 *ht*u0 - c0 *hx - 2*hx*r0*u0
  842. ai11 := --------------------------------------------
  843. 2*r0*u0*(sin(ax)*ht*u0 - hx*i)
  844. 2
  845. - c0
  846. ar12 := ---------
  847. 2*r0*u0
  848. 2
  849. c0 *(cos(ax)*ht*u0 - hx)
  850. ai12 := --------------------------------
  851. 2*r0*u0*(sin(ax)*ht*u0 - hx*i)
  852. 2 2 2
  853. sin(ax) *c0 *ht
  854. ar21 := ----------------------------
  855. 2 2 2 2
  856. 2*(sin(ax) *ht *u0 - hx )
  857. 2 2 3 2 2 2
  858. ai21 := (sin(ax)*ht*(cos(ax)*sin(ax) *c0 *ht *u0 - cos(ax)*c0 *ht*hx
  859. 2 2 2 2 2 2 3
  860. + 2*sin(ax) *c0 *ht *hx*u0 + 2*sin(ax) *ht *hx*r0*u0 - 2*hx *r0))/
  861. 4 4 4 3 3 3 2 2 2 2
  862. (2*(sin(ax) *ht *u0 - 2*sin(ax) *ht *hx*i*u0 - 2*sin(ax) *ht *hx *u0
  863. 3 4
  864. + 2*sin(ax)*ht*hx *i*u0 + hx ))
  865. 2 2 2 2
  866. sin(ax) *c0 *ht - 2*hx
  867. ar22 := ----------------------------
  868. 2 2 2 2
  869. 2*(sin(ax) *ht *u0 - hx )
  870. 2 2 3 2 2 2
  871. ai22 := (sin(ax)*ht*( - cos(ax)*sin(ax) *c0 *ht *u0 + cos(ax)*c0 *ht*hx
  872. 2 2 2 2 2 3 3
  873. + 2*sin(ax) *c0 *ht *hx*u0 - 2*sin(ax) *ht *hx*u0 - 2*hx *u0))/(2*
  874. 4 4 4 3 3 3 2 2 2 2
  875. (sin(ax) *ht *u0 - 2*sin(ax) *ht *hx*i*u0 - 2*sin(ax) *ht *hx *u0
  876. 3 4
  877. + 2*sin(ax)*ht*hx *i*u0 + hx ))
  878. cleardenot;
  879. clear aa,bb,pol;
  880. %***********************************************************************
  881. % Example C.4 : Richtmyer, Morton: Difference methods for initial value
  882. % problems, &10.3. p.262
  883. coordinates t,x into n,j;
  884. unfunc v,w;
  885. matrix aa(1,2),bb(2,2);
  886. aa(1,1):=(v(n+1)-v(n))/ht-c*(w(j+1/2)-w(j-1/2)+
  887. w(n+1,j+1/2)-w(n+1,j-1/2))/(2*hx)$
  888. aa(1,2):=(w(n+1,j-1/2)-w(n,j-1/2))/ht-c*(v(n+1,j)-v(n+1,j-1)+
  889. v(j)-v(j-1))/(2*hx)$
  890. bb:=ampmat aa;
  891. kx*hx
  892. ax := -------
  893. 2
  894. [ hx - i*sin(ax)*c*ht ]
  895. h1 := [ ]
  896. [sin(ax)*c*ht*( - i*cos(ax) - sin(ax)) hx*(cos(ax) - i*sin(ax))]
  897. [ hx i*sin(ax)*c*ht ]
  898. h0 := [ ]
  899. [sin(ax)*c*ht*(i*cos(ax) + sin(ax)) hx*(cos(ax) - i*sin(ax))]
  900. [ 2 2 2 2 ]
  901. [ - sin(ax) *c *ht + hx 2*i*sin(ax)*c*ht*hx ]
  902. [-------------------------- ----------------------- ]
  903. [ 2 2 2 2 2 2 2 2 ]
  904. [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
  905. bb := [ ]
  906. [ 2 2 2 2 ]
  907. [ 2*i*sin(ax)*c*ht*hx - sin(ax) *c *ht + hx ]
  908. [ ----------------------- --------------------------]
  909. [ 2 2 2 2 2 2 2 2 ]
  910. [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
  911. bb:=denotemat bb;
  912. [ ar11 ai12*i]
  913. bb := [ ]
  914. [ai21*i ar22 ]
  915. pol:=charpol bb;
  916. 2
  917. pol := lam - lam*(ar11 + ar22) + ai12*ai21 + ar11*ar22
  918. prdenot;
  919. 2 2 2 2
  920. - sin(ax) *c *ht + hx
  921. ar11 := --------------------------
  922. 2 2 2 2
  923. sin(ax) *c *ht + hx
  924. 2*sin(ax)*c*ht*hx
  925. ai12 := -----------------------
  926. 2 2 2 2
  927. sin(ax) *c *ht + hx
  928. 2*sin(ax)*c*ht*hx
  929. ai21 := -----------------------
  930. 2 2 2 2
  931. sin(ax) *c *ht + hx
  932. 2 2 2 2
  933. - sin(ax) *c *ht + hx
  934. ar22 := --------------------------
  935. 2 2 2 2
  936. sin(ax) *c *ht + hx
  937. cleardenot;
  938. clear aa,bb,pol;
  939. %***********************************************************************
  940. % Example C.5: Mazurik: Algoritmy resenia zadaci..., Preprint no.24-85,
  941. % AN USSR SO, Inst. teor. i prikl. mechaniky, p.34
  942. coordinates t,x,y into n,m,k;
  943. grid uniform,t,x,y;
  944. unfunc u1,u2,u3;
  945. matrix aa(1,3),bb(3,3);
  946. aa(1,1):=(u1(n+1)-u1(n))/ht+c/2*((-u1(m-1)+2*u1(m)-u1(m+1))/hx +
  947. (u2(m+1)-u2(m-1))/hx - (u1(k-1)-2*u1(k)+u1(k+1))/hy +
  948. (u3(k+1)-u3(k-1))/hy)$
  949. aa(1,2):=(u2(n+1)-u2(n))/ht+c/2*((u1(m+1)-u1(m-1))/hx -
  950. (u2(m-1)-2*u2(m)+u2(m+1))/hx)$
  951. aa(1,3):=(u3(n+1)-u3(n))/ht + c/2*((u1(k+1)-u1(k-1))/hy -
  952. (u3(k-1)-2*u3(k)+u3(k+1))/hy)$
  953. off prfourmat;
  954. bb:=ampmat aa;
  955. ax := kx*hx
  956. ay := ky*hy
  957. cos(ax)*c*ht*hy + cos(ay)*c*ht*hx - c*ht*hx - c*ht*hy + hx*hy
  958. bb := mat((---------------------------------------------------------------,
  959. hx*hy
  960. - i*sin(ax)*c*ht - i*sin(ay)*c*ht
  961. -------------------,-------------------),
  962. hx hy
  963. - i*sin(ax)*c*ht cos(ax)*c*ht - c*ht + hx
  964. (-------------------,--------------------------,0),
  965. hx hx
  966. - i*sin(ay)*c*ht cos(ay)*c*ht - c*ht + hy
  967. (-------------------,0,--------------------------))
  968. hy hy
  969. pol:=charpol bb;
  970. 3 2 2 2
  971. pol := (lam *hx *hy + lam *hx*hy*( - 2*cos(ax)*c*ht*hy - 2*cos(ay)*c*ht*hx
  972. + 2*c*ht*hx + 2*c*ht*hy - 3*hx*hy) + lam*(
  973. 2 2 2 2
  974. 3*cos(ax)*cos(ay)*c *ht *hx*hy - 3*cos(ax)*c *ht *hx*hy
  975. 2 2 2 2 2 2 2 2
  976. - 2*cos(ax)*c *ht *hy + 4*cos(ax)*c*ht*hx*hy + cos(ay) *c *ht *hx
  977. 2 2 2 2 2
  978. - 2*cos(ay)*c *ht *hx - 3*cos(ay)*c *ht *hx*hy
  979. 2 2 2 2 2 2 2 2
  980. + 4*cos(ay)*c*ht*hx *hy + sin(ay) *c *ht *hx + c *ht *hx
  981. 2 2 2 2 2 2 2
  982. + 3*c *ht *hx*hy + 2*c *ht *hy - 4*c*ht*hx *hy - 4*c*ht*hx*hy
  983. 2 2 2 3 3
  984. + 3*hx *hy ) - cos(ax)*cos(ay) *c *ht *hx
  985. 3 3 3 3
  986. + 2*cos(ax)*cos(ay)*c *ht *hx + 2*cos(ax)*cos(ay)*c *ht *hy
  987. 2 2 2 3 3
  988. - 3*cos(ax)*cos(ay)*c *ht *hx*hy - cos(ax)*sin(ay) *c *ht *hx
  989. 3 3 3 3 2 2
  990. - cos(ax)*c *ht *hx - 2*cos(ax)*c *ht *hy + 3*cos(ax)*c *ht *hx*hy
  991. 2 2 2 2 2 3 3
  992. + 2*cos(ax)*c *ht *hy - 2*cos(ax)*c*ht*hx*hy + cos(ay) *c *ht *hx
  993. 2 2 2 2 3 3 3 3
  994. - cos(ay) *c *ht *hx - 2*cos(ay)*c *ht *hx - 2*cos(ay)*c *ht *hy
  995. 2 2 2 2 2 2
  996. + 2*cos(ay)*c *ht *hx + 3*cos(ay)*c *ht *hx*hy - 2*cos(ay)*c*ht*hx *hy
  997. 2 3 3 2 2 2 2 3 3 3 3
  998. + sin(ay) *c *ht *hx - sin(ay) *c *ht *hx + c *ht *hx + 2*c *ht *hy
  999. 2 2 2 2 2 2 2 2 2
  1000. - c *ht *hx - 3*c *ht *hx*hy - 2*c *ht *hy + 2*c*ht*hx *hy
  1001. 2 2 2 2 2
  1002. + 2*c*ht*hx*hy - hx *hy )/(hx *hy )
  1003. let
  1004. cos ax=cos ax2**2-sin ax2**2,
  1005. cos ay=cos ay2**2-sin ay2**2,
  1006. sin ax=2*sin ax2*cos ax2,
  1007. sin ay=2*sin ay2*cos ay2,
  1008. cos ax2**2=1-sin ax2**2,
  1009. cos ay2**2=1-sin ay2**2,
  1010. sin ax2=s1,
  1011. sin ay2=s2,
  1012. hx=c*ht/cap1,
  1013. hy=c*ht/cap2;
  1014. order s1,s2;
  1015. pol:=pol;
  1016. 3 2 2 2 2 2
  1017. pol := lam + lam *(4*s1 *cap1 + 4*s2 *cap2 - 3) + lam*(12*s1 *s2 *cap1*cap2
  1018. 2 2 2 2 2 2
  1019. + 4*s1 *cap1 - 8*s1 *cap1 + 4*s2 *cap2 - 8*s2 *cap2 + 3)
  1020. 2 2 2 2 2 2 2 2
  1021. + 8*s1 *s2 *cap1 *cap2 + 8*s1 *s2 *cap1*cap2 - 12*s1 *s2 *cap1*cap2
  1022. 2 2 2 2 2 2
  1023. - 4*s1 *cap1 + 4*s1 *cap1 - 4*s2 *cap2 + 4*s2 *cap2 - 1
  1024. clear cos ax,cos ay,sin ax,sin ay,cos ax2**2,cos ay2**2,sin ax2,sin ay2,
  1025. hx,hy;
  1026. pol:=complexpol pol;
  1027. 2 2
  1028. If 8*s1 *s2 *cap1*cap2*(cap1 + cap2) = 0 and 0
  1029. = 0 , a root of the polynomial is equal to 1.
  1030. 3 2 2 2 2 2
  1031. pol := lam + lam *(4*s1 *cap1 + 4*s2 *cap2 - 3) + lam*(12*s1 *s2 *cap1*cap2
  1032. 2 2 2 2 2 2
  1033. + 4*s1 *cap1 - 8*s1 *cap1 + 4*s2 *cap2 - 8*s2 *cap2 + 3)
  1034. 2 2 2 2 2 2 2 2
  1035. + 8*s1 *s2 *cap1 *cap2 + 8*s1 *s2 *cap1*cap2 - 12*s1 *s2 *cap1*cap2
  1036. 2 2 2 2 2 2
  1037. - 4*s1 *cap1 + 4*s1 *cap1 - 4*s2 *cap2 + 4*s2 *cap2 - 1
  1038. pol1:=hurw pol;
  1039. 3 2 2 2 2 2 2
  1040. pol1 := 8*lam *s1 *s2 *cap1*cap2*(cap1 + cap2) + 8*lam *( - 3*s1 *s2 *cap1 *cap2
  1041. 2 2 2 2 2 2 2 2 2
  1042. - 3*s1 *s2 *cap1*cap2 + 3*s1 *s2 *cap1*cap2 + s1 *cap1 + s2 *cap2
  1043. 2 2 2 2 2 2
  1044. ) + 8*lam*(3*s1 *s2 *cap1 *cap2 + 3*s1 *s2 *cap1*cap2
  1045. 2 2 2 2 2 2 2
  1046. - 6*s1 *s2 *cap1*cap2 - 2*s1 *cap1 + 2*s1 *cap1 - 2*s2 *cap2
  1047. 2 2 2 2 2 2 2
  1048. + 2*s2 *cap2) + 8*( - s1 *s2 *cap1 *cap2 - s1 *s2 *cap1*cap2
  1049. 2 2 2 2 2 2 2
  1050. + 3*s1 *s2 *cap1*cap2 + s1 *cap1 - 2*s1 *cap1 + s2 *cap2
  1051. 2
  1052. - 2*s2 *cap2 + 1)
  1053. denotid cp;
  1054. pol:=denotepol pol;
  1055. 3 2
  1056. pol := lam + lam *cpr02 + lam*cpr01 + cpr00
  1057. prdenot;
  1058. 2 2 2 2 2 2 2 2
  1059. cpr00 := 8*s1 *s2 *cap1 *cap2 + 8*s1 *s2 *cap1*cap2 - 12*s1 *s2 *cap1*cap2
  1060. 2 2 2 2 2 2
  1061. - 4*s1 *cap1 + 4*s1 *cap1 - 4*s2 *cap2 + 4*s2 *cap2 - 1
  1062. cpr01 :=
  1063. 2 2 2 2 2 2 2 2
  1064. 12*s1 *s2 *cap1*cap2 + 4*s1 *cap1 - 8*s1 *cap1 + 4*s2 *cap2 - 8*s2 *cap2 + 3
  1065. 2 2
  1066. cpr02 := 4*s1 *cap1 + 4*s2 *cap2 - 3
  1067. cleardenot;
  1068. clear aa,bb,pol,pol1;
  1069. %***********************************************************************
  1070. % Example C.6 : Lax-Wendrov (V. Ganzha)
  1071. coordinates t,x,y into n,m,k;
  1072. grid uniform,t,x,y;
  1073. let cos ax**2=1-sin ax**2,
  1074. cos ay**2=1-sin ay**2;
  1075. unfunc u1,u2,u3,u4;
  1076. matrix aa(1,4),bb(4,4);
  1077. aa(1,1):=4*(u1(n+1)-u1(n))/ht+
  1078. (w*(u1(m+2)-u1(m-2)+u1(m+1,k+1)+u1(m+1,k-1)-
  1079. u1(m-1,k+1)-u1(m-1,k-1))+p*(u2(m+2)-u2(m-2)+u2(m+1,k+1)+
  1080. u2(m+1,k-1)-u2(m-1,k+1)-u2(m-1,k-1))+
  1081. v*(u1(m+1,k+1)+u1(m-1,k+1)-
  1082. u1(m+1,k-1)-u1(m-1,k-1)+u1(k+2)-u1(k-2))+p*(u3(m+1,k+1)+
  1083. u3(m-1,k+1)-u3(m+1,k-1)-u3(m-1,k-1)+u3(k+2)-u3(k-2)))/hx+ht*
  1084. (2*w**2*(-u1(m+2)+2*u1(m)-u1(m-2))+4*w*p*(-u2(m+2)+2*u2(m)-
  1085. u2(m-2))+2*(-u4(m+2)+2*u4(m)-u4(m-2))+2*v**2*(-u1(k+2)+
  1086. 2*u1(k)-u1(k-2))+4*v*p*(u3(k+2)+2*u3(k)-u3(k-2))+2*(-u4(k+2)+
  1087. 2*u4(k)-u4(k-2))+4*w*v*(-u1(m+1,k+1)+u1(m+1,k-1)+u1(m-1,k+1)-
  1088. u1(m-1,k-1))+4*p*v*(-u2(m+1,k+1)+u2(m+1,k-1)+u2(m-1,k+1)-
  1089. u2(m-1,k-1))+4*w*p*(-u3(m+1,k+1)+u3(m+1,k-1)+u3(m-1,k+1)-
  1090. u3(m-1,k-1)))/hx/hx$
  1091. aa(1,2):=4*p*(u2(n+1)-u2(n))/ht+
  1092. (w*p*(u2(m+2)-u2(m-2)+u2(m+1,k+1)+
  1093. u2(m+1,k-1)-u2(m-1,k+1)-u2(m-1,k-1))+u4(m+2)-u4(m-2)+
  1094. u4(m+1,k+1)+
  1095. u4(m+1,k-1)-u4(m-1,k+1)-u4(m-1,k-1)+
  1096. p*v*(u2(m+1,k+1)+u2(m-1,k+1)+
  1097. u2(k+2)-u2(k-2)-u2(m+1,k-1)-u2(m-1,k-1)))/hx+ht*(2*w**2*p*
  1098. (-u2(m+2)+2*u2(m)-u2(m-2))+2*p*c**2*(-u2(m+2)+2*u2(m)-u2(m-2))
  1099. +4*w*(-u4(m+2)+2*u4(m)-u4(m-2))+2*p*v**2*(-u2(k+2)+2*u2(k)-
  1100. u2(k-2))+4*w*p*v*(-u2(m+1,k+1)+u2(m+1,k-1)+u2(m-1,k+1)-
  1101. u2(m-1,k-1))+2*p*c**2*(-u3(m+1,k+1)+u3(m+1,k-1)+u3(m-1,k+1)
  1102. -u3(m-1,k-1))+4*v*(-u4(m+1,k+1)+u4(m+1,k-1)+u4(m-1,k+1)-
  1103. u4(m-1,k-1)))/hx/hx$
  1104. aa(1,3):=4*p*(u3(n+1)-u3(n))/ht+(w*p*(u3(m+2)-u3(m-2)+u3(m+1,k+1)+
  1105. u3(m+1,k-1)-u3(m-1,k+1)-u3(m-1,k-1))+u4(k+2)-u4(k-2)+
  1106. u4(m+1,k+1)-u4(m+1,k-1)+u4(m-1,k+1)-u4(m-1,k-1)+
  1107. p*v*(u3(m+1,k+1)+u3(m-1,k+1)+u3(k+2)-u3(k-2)-u3(m+1,k-1)-
  1108. u3(m-1,k-1)))/hx+ht*(2*w**2*p*(-u3(m+2)+2*u3(m)-u3(m-2))+
  1109. 2*p*c**2*(-u3(k+2)+2*u3(k)-u3(k-2))+4*v*(-u4(k+2)+
  1110. 2*u4(k)-u4(k-2))+2*p*v**2*(-u3(k+2)+2*u3(k)-u3(k-2))+
  1111. 4*w*p*v*(-u3(m+1,k+1)+u3(m+1,k-1)+u3(m-1,k+1)-
  1112. u3(m-1,k-1))+2*p*c**2*(-u2(m+1,k+1)+u2(m+1,k-1)+
  1113. u2(m-1,k+1)-u2(m-1,k-1))+4*w*(u4(m+1,k+1)+u4(m+1,k-1)+
  1114. u4(m-1,k+1)-u4(m-1,k-1)))/hx/hx$
  1115. aa(1,4):=4*(u4(n+1)-u4(n))/ht+(p*c**2*(u2(m+2)-u2(m-2)+u2(m+1,k+1)+
  1116. u2(m+1,k-1)-u2(m-1,k+1)-u2(m-1,k-1))+w*(u4(m+2)-
  1117. u4(m-2)+u4(m+1,k+1)+u4(m+1,k-1)-u4(m-1,k+1)-u4(m-1,k-1))+
  1118. +p*c**2*(u3(m+1,k+1)+u3(m-1,k+1)-u3(m+1,k-1)-
  1119. u3(m-1,k-1)+u3(k+2)-u3(k-2))+v*(u4(m+1,k+1)+u4(m-1,k+1)-
  1120. u4(m+1,k-1)-u4(m-1,k-1)+u4(k+2)-u4(k-2)))/hx+ht*
  1121. (2*w**2*(-u4(m+2)+2*u4(m)-u4(m-2))+4*w*p*c**2*(-u2(m+2)+
  1122. 2*u2(m)-u2(m-2))+2*c**2*(-u4(m+2)+2*u4(m)-u4(m-2))+
  1123. 4*p*v*c**2*(-u3(k+2)+2*u3(k)-u3(k-2))+2*c**2*(-u4(k+2)+
  1124. 2*u4(k)-u4(k-2))+2*v**2*(-u4(k+2)+2*u4(k)-u4(k-2))+
  1125. 4*p*v*c**2*(-u2(m+1,k+1)+u2(m+1,k-1)+u2(m-1,k+1)-
  1126. u2(m-1,k-1))+4*w*p*c**2*(-u3(m+1,k+1)+u3(m+1,k-1)+
  1127. u3(m-1,k+1)-u3(m-1,k-1))+4*w*v*(-u4(m+1,k+1)+
  1128. u4(m+1,k-1)+u4(m-1,k+1)-u4(m-1,k-1)))/hx/hx$
  1129. bb:=ampmat aa;
  1130. ax := kx*hx
  1131. ay := ky*hy
  1132. bb := mat((( - i*cos(ax)*sin(ax)*ht*hx*w - i*cos(ax)*sin(ay)*ht*hx*v
  1133. - i*cos(ay)*sin(ax)*ht*hx*w - i*cos(ay)*sin(ay)*ht*hx*v
  1134. 2 2 2 2 2 2 2
  1135. - 2*sin(ax) *ht *w - 4*sin(ax)*sin(ay)*ht *v*w - 2*sin(ay) *ht *v
  1136. 2 2
  1137. + hx )/hx ,(sin(ax)*ht*p*( - i*cos(ax)*hx - i*cos(ay)*hx
  1138. 2
  1139. - 4*sin(ax)*ht*w - 4*sin(ay)*ht*v))/hx ,(ht*p*(
  1140. - i*cos(ax)*sin(ay)*hx - 4*i*cos(ay)*sin(ay)*ht*v
  1141. 2
  1142. - i*cos(ay)*sin(ay)*hx - 4*sin(ax)*sin(ay)*ht*w - 2*ht*v))/hx
  1143. 2 2 2
  1144. - 2*ht *(sin(ax) + sin(ay) )
  1145. ,--------------------------------),
  1146. 2
  1147. hx
  1148. (0,( - i*cos(ax)*sin(ax)*ht*hx*w - i*cos(ax)*sin(ay)*ht*hx*v
  1149. - i*cos(ay)*sin(ax)*ht*hx*w - i*cos(ay)*sin(ay)*ht*hx*v
  1150. 2 2 2 2 2 2
  1151. - 2*sin(ax) *c *ht - 2*sin(ax) *ht *w
  1152. 2 2 2 2 2 2
  1153. - 4*sin(ax)*sin(ay)*ht *v*w - 2*sin(ay) *ht *v + hx )/hx ,
  1154. 2 2
  1155. - 2*sin(ax)*sin(ay)*c *ht
  1156. -----------------------------,(sin(ax)*ht*( - i*cos(ax)*hx
  1157. 2
  1158. hx
  1159. 2
  1160. - i*cos(ay)*hx - 4*sin(ax)*ht*w - 4*sin(ay)*ht*v))/(hx *p)),
  1161. 2 2
  1162. - 2*sin(ax)*sin(ay)*c *ht
  1163. (0,-----------------------------,( - i*cos(ax)*sin(ax)*ht*hx*w
  1164. 2
  1165. hx
  1166. - i*cos(ax)*sin(ay)*ht*hx*v - i*cos(ay)*sin(ax)*ht*hx*w
  1167. 2 2 2
  1168. - i*cos(ay)*sin(ay)*ht*hx*v - 2*sin(ax) *ht *w
  1169. 2 2 2 2
  1170. - 4*sin(ax)*sin(ay)*ht *v*w - 2*sin(ay) *c *ht
  1171. 2 2 2 2 2
  1172. - 2*sin(ay) *ht *v + hx )/hx ,(ht*( - 2*cos(ax)*cos(ay)*ht*w
  1173. - 2*i*cos(ax)*sin(ay)*ht*w - i*cos(ax)*sin(ay)*hx
  1174. - 2*i*cos(ay)*sin(ax)*ht*w - i*cos(ay)*sin(ay)*hx
  1175. 2 2
  1176. - 2*sin(ax)*sin(ay)*ht*w - 4*sin(ay) *ht*v))/(hx *p)),
  1177. 2
  1178. (0,(sin(ax)*c *ht*p*( - i*cos(ax)*hx - i*cos(ay)*hx - 4*sin(ax)*ht*w
  1179. 2 2
  1180. - 4*sin(ay)*ht*v))/hx ,(sin(ay)*c *ht*p*( - i*cos(ax)*hx
  1181. 2
  1182. - i*cos(ay)*hx - 4*sin(ax)*ht*w - 4*sin(ay)*ht*v))/hx ,(
  1183. - i*cos(ax)*sin(ax)*ht*hx*w - i*cos(ax)*sin(ay)*ht*hx*v
  1184. - i*cos(ay)*sin(ax)*ht*hx*w - i*cos(ay)*sin(ay)*ht*hx*v
  1185. 2 2 2 2 2 2
  1186. - 2*sin(ax) *c *ht - 2*sin(ax) *ht *w
  1187. 2 2 2 2
  1188. - 4*sin(ax)*sin(ay)*ht *v*w - 2*sin(ay) *c *ht
  1189. 2 2 2 2 2
  1190. - 2*sin(ay) *ht *v + hx )/hx ))
  1191. let
  1192. sin(ax)=s1,
  1193. cos(ax)=c1,
  1194. sin(ay)=s2,
  1195. cos(ay)=c2,
  1196. w=k1*hx/ht,
  1197. v=k2*hx/ht,
  1198. c=k3*hx/ht,
  1199. ht=r1*hx;
  1200. denotid a;
  1201. bb:=denotemat bb;
  1202. [ai11*i + ar11 ai12*i + ar12 ai13*i + ar13 ar14 ]
  1203. [ ]
  1204. [ 0 ai22*i + ar22 ar23 ai24*i + ar24]
  1205. bb := [ ]
  1206. [ 0 ar32 ai33*i + ar33 ai34*i + ar34]
  1207. [ ]
  1208. [ 0 ai42*i + ar42 ai43*i + ar43 ai44*i + ar44]
  1209. clear sin ax,cos ax,sin ay,cos ay,w,v,c,ht;
  1210. pol:=charpol bb;
  1211. 4 3
  1212. pol := lam + lam
  1213. *( - i*ai11 - i*ai22 - i*ai33 - i*ai44 - ar11 - ar22 - ar33 - ar44) +
  1214. 2
  1215. lam *( - ai11*ai22 - ai11*ai33 - ai11*ai44 + i*ai11*ar22 + i*ai11*ar33
  1216. + i*ai11*ar44 - ai22*ai33 - ai22*ai44 + i*ai22*ar11 + i*ai22*ar33
  1217. + i*ai22*ar44 + ai24*ai42 - i*ai24*ar42 - ai33*ai44 + i*ai33*ar11
  1218. + i*ai33*ar22 + i*ai33*ar44 + ai34*ai43 - i*ai34*ar43
  1219. - i*ai42*ar24 - i*ai43*ar34 + i*ai44*ar11 + i*ai44*ar22
  1220. + i*ai44*ar33 + ar11*ar22 + ar11*ar33 + ar11*ar44 + ar22*ar33
  1221. + ar22*ar44 - ar23*ar32 - ar24*ar42 + ar33*ar44 - ar34*ar43) + lam
  1222. *(i*ai11*ai22*ai33 + i*ai11*ai22*ai44 + ai11*ai22*ar33 + ai11*ai22*ar44
  1223. - i*ai11*ai24*ai42 - ai11*ai24*ar42 + i*ai11*ai33*ai44
  1224. + ai11*ai33*ar22 + ai11*ai33*ar44 - i*ai11*ai34*ai43 - ai11*ai34*ar43
  1225. - ai11*ai42*ar24 - ai11*ai43*ar34 + ai11*ai44*ar22 + ai11*ai44*ar33
  1226. - i*ai11*ar22*ar33 - i*ai11*ar22*ar44 + i*ai11*ar23*ar32
  1227. + i*ai11*ar24*ar42 - i*ai11*ar33*ar44 + i*ai11*ar34*ar43
  1228. + i*ai22*ai33*ai44 + ai22*ai33*ar11 + ai22*ai33*ar44
  1229. - i*ai22*ai34*ai43 - ai22*ai34*ar43 - ai22*ai43*ar34 + ai22*ai44*ar11
  1230. + ai22*ai44*ar33 - i*ai22*ar11*ar33 - i*ai22*ar11*ar44
  1231. - i*ai22*ar33*ar44 + i*ai22*ar34*ar43 - i*ai24*ai33*ai42
  1232. - ai24*ai33*ar42 - ai24*ai42*ar11 - ai24*ai42*ar33 + ai24*ai43*ar32
  1233. + i*ai24*ar11*ar42 - i*ai24*ar32*ar43 + i*ai24*ar33*ar42
  1234. - ai33*ai42*ar24 + ai33*ai44*ar11 + ai33*ai44*ar22 - i*ai33*ar11*ar22
  1235. - i*ai33*ar11*ar44 - i*ai33*ar22*ar44 + i*ai33*ar24*ar42
  1236. + ai34*ai42*ar23 - ai34*ai43*ar11 - ai34*ai43*ar22 + i*ai34*ar11*ar43
  1237. + i*ai34*ar22*ar43 - i*ai34*ar23*ar42 + i*ai42*ar11*ar24
  1238. - i*ai42*ar23*ar34 + i*ai42*ar24*ar33 + i*ai43*ar11*ar34
  1239. + i*ai43*ar22*ar34 - i*ai43*ar24*ar32 - i*ai44*ar11*ar22
  1240. - i*ai44*ar11*ar33 - i*ai44*ar22*ar33 + i*ai44*ar23*ar32
  1241. - ar11*ar22*ar33 - ar11*ar22*ar44 + ar11*ar23*ar32 + ar11*ar24*ar42
  1242. - ar11*ar33*ar44 + ar11*ar34*ar43 - ar22*ar33*ar44 + ar22*ar34*ar43
  1243. + ar23*ar32*ar44 - ar23*ar34*ar42 - ar24*ar32*ar43 + ar24*ar33*ar42)
  1244. + ai11*ai22*ai33*ai44 - i*ai11*ai22*ai33*ar44 - ai11*ai22*ai34*ai43
  1245. + i*ai11*ai22*ai34*ar43 + i*ai11*ai22*ai43*ar34 - i*ai11*ai22*ai44*ar33
  1246. - ai11*ai22*ar33*ar44 + ai11*ai22*ar34*ar43 - ai11*ai24*ai33*ai42
  1247. + i*ai11*ai24*ai33*ar42 + i*ai11*ai24*ai42*ar33 - i*ai11*ai24*ai43*ar32
  1248. - ai11*ai24*ar32*ar43 + ai11*ai24*ar33*ar42 + i*ai11*ai33*ai42*ar24
  1249. - i*ai11*ai33*ai44*ar22 - ai11*ai33*ar22*ar44 + ai11*ai33*ar24*ar42
  1250. - i*ai11*ai34*ai42*ar23 + i*ai11*ai34*ai43*ar22 + ai11*ai34*ar22*ar43
  1251. - ai11*ai34*ar23*ar42 - ai11*ai42*ar23*ar34 + ai11*ai42*ar24*ar33
  1252. + ai11*ai43*ar22*ar34 - ai11*ai43*ar24*ar32 - ai11*ai44*ar22*ar33
  1253. + ai11*ai44*ar23*ar32 + i*ai11*ar22*ar33*ar44 - i*ai11*ar22*ar34*ar43
  1254. - i*ai11*ar23*ar32*ar44 + i*ai11*ar23*ar34*ar42 + i*ai11*ar24*ar32*ar43
  1255. - i*ai11*ar24*ar33*ar42 - i*ai22*ai33*ai44*ar11 - ai22*ai33*ar11*ar44
  1256. + i*ai22*ai34*ai43*ar11 + ai22*ai34*ar11*ar43 + ai22*ai43*ar11*ar34
  1257. - ai22*ai44*ar11*ar33 + i*ai22*ar11*ar33*ar44 - i*ai22*ar11*ar34*ar43
  1258. + i*ai24*ai33*ai42*ar11 + ai24*ai33*ar11*ar42 + ai24*ai42*ar11*ar33
  1259. - ai24*ai43*ar11*ar32 + i*ai24*ar11*ar32*ar43 - i*ai24*ar11*ar33*ar42
  1260. + ai33*ai42*ar11*ar24 - ai33*ai44*ar11*ar22 + i*ai33*ar11*ar22*ar44
  1261. - i*ai33*ar11*ar24*ar42 - ai34*ai42*ar11*ar23 + ai34*ai43*ar11*ar22
  1262. - i*ai34*ar11*ar22*ar43 + i*ai34*ar11*ar23*ar42 + i*ai42*ar11*ar23*ar34
  1263. - i*ai42*ar11*ar24*ar33 - i*ai43*ar11*ar22*ar34 + i*ai43*ar11*ar24*ar32
  1264. + i*ai44*ar11*ar22*ar33 - i*ai44*ar11*ar23*ar32 + ar11*ar22*ar33*ar44
  1265. - ar11*ar22*ar34*ar43 - ar11*ar23*ar32*ar44 + ar11*ar23*ar34*ar42
  1266. + ar11*ar24*ar32*ar43 - ar11*ar24*ar33*ar42
  1267. denotid cp;
  1268. pol:=denotepol pol;
  1269. 4 3 2
  1270. pol := lam + lam *(cpi03*i + cpr03) + lam *(cpi02*i + cpr02)
  1271. + lam*(cpi01*i + cpr01) + cpi00*i + cpr00
  1272. pol:=complexpol pol;
  1273. If cpr00 + cpr01 + cpr02 + cpr03 + 1 = 0 and cpi00 + cpi01 + cpi02 + cpi03
  1274. = 0 , a root of the polynomial is equal to 1.
  1275. 8 7 6 2 2
  1276. pol := lam + 2*lam *cpr03 + lam *(cpi03 + 2*cpr02 + cpr03 )
  1277. 5
  1278. + 2*lam *(cpi02*cpi03 + cpr01 + cpr02*cpr03)
  1279. 4 2 2
  1280. + lam *(2*cpi01*cpi03 + cpi02 + 2*cpr00 + 2*cpr01*cpr03 + cpr02 )
  1281. 3
  1282. + 2*lam *(cpi00*cpi03 + cpi01*cpi02 + cpr00*cpr03 + cpr01*cpr02)
  1283. 2 2 2
  1284. + lam *(2*cpi00*cpi02 + cpi01 + 2*cpr00*cpr02 + cpr01 )
  1285. 2 2
  1286. + 2*lam*(cpi00*cpi01 + cpr00*cpr01) + cpi00 + cpr00
  1287. denotid rp;
  1288. pol:=denotepol pol;
  1289. 8 7 6 5 4 3
  1290. pol := lam + lam *rpr07 + lam *rpr06 + lam *rpr05 + lam *rpr04 + lam *rpr03
  1291. 2
  1292. + lam *rpr02 + lam*rpr01 + rpr00
  1293. prdenot;
  1294. 2 2 2 2
  1295. ar11 := - 2*s1 *k1 - 4*s1*s2*k1*k2 - 2*s2 *k2 + 1
  1296. ai11 := - (s1*c1*k1 + s1*c2*k1 + s2*c1*k2 + s2*c2*k2)
  1297. ar12 := - 4*s1*p*r1*(s1*k1 + s2*k2)
  1298. ai12 := - s1*p*r1*(c1 + c2)
  1299. ar13 := 2*p*r1*( - 2*s1*s2*k1 - k2)
  1300. ai13 := s2*p*r1*( - c1 - 4*c2*k2 - c2)
  1301. 2 2 2
  1302. ar14 := - 2*r1 *(s1 + s2 )
  1303. 2 2 2 2 2 2
  1304. ar22 := - 2*s1 *k1 - 2*s1 *k3 - 4*s1*s2*k1*k2 - 2*s2 *k2 + 1
  1305. ai22 := - (s1*c1*k1 + s1*c2*k1 + s2*c1*k2 + s2*c2*k2)
  1306. 2
  1307. ar23 := - 2*s1*s2*k3
  1308. - 4*s1*r1*(s1*k1 + s2*k2)
  1309. ar24 := ----------------------------
  1310. p
  1311. - s1*r1*(c1 + c2)
  1312. ai24 := --------------------
  1313. p
  1314. 2
  1315. ar32 := - 2*s1*s2*k3
  1316. 2 2 2 2 2 2
  1317. ar33 := - 2*s1 *k1 - 4*s1*s2*k1*k2 - 2*s2 *k2 - 2*s2 *k3 + 1
  1318. ai33 := - (s1*c1*k1 + s1*c2*k1 + s2*c1*k2 + s2*c2*k2)
  1319. 2
  1320. 2*r1*( - s1*s2*k1 - 2*s2 *k2 - c1*c2*k1)
  1321. ar34 := ------------------------------------------
  1322. p
  1323. r1*( - 2*s1*c2*k1 - 2*s2*c1*k1 - s2*c1 - s2*c2)
  1324. ai34 := -------------------------------------------------
  1325. p
  1326. 2
  1327. - 4*s1*k3 *p*(s1*k1 + s2*k2)
  1328. ar42 := -------------------------------
  1329. r1
  1330. 2
  1331. - s1*k3 *p*(c1 + c2)
  1332. ai42 := -----------------------
  1333. r1
  1334. 2
  1335. - 4*s2*k3 *p*(s1*k1 + s2*k2)
  1336. ar43 := -------------------------------
  1337. r1
  1338. 2
  1339. - s2*k3 *p*(c1 + c2)
  1340. ai43 := -----------------------
  1341. r1
  1342. 2 2 2 2 2 2 2 2
  1343. ar44 := - 2*s1 *k1 - 2*s1 *k3 - 4*s1*s2*k1*k2 - 2*s2 *k2 - 2*s2 *k3 + 1
  1344. ai44 := - (s1*c1*k1 + s1*c2*k1 + s2*c1*k2 + s2*c2*k2)
  1345. cpr00 := ai11*ai22*ai33*ai44 - ai11*ai22*ai34*ai43 - ai11*ai22*ar33*ar44
  1346. + ai11*ai22*ar34*ar43 - ai11*ai24*ai33*ai42 - ai11*ai24*ar32*ar43
  1347. + ai11*ai24*ar33*ar42 - ai11*ai33*ar22*ar44 + ai11*ai33*ar24*ar42
  1348. + ai11*ai34*ar22*ar43 - ai11*ai34*ar23*ar42 - ai11*ai42*ar23*ar34
  1349. + ai11*ai42*ar24*ar33 + ai11*ai43*ar22*ar34 - ai11*ai43*ar24*ar32
  1350. - ai11*ai44*ar22*ar33 + ai11*ai44*ar23*ar32 - ai22*ai33*ar11*ar44
  1351. + ai22*ai34*ar11*ar43 + ai22*ai43*ar11*ar34 - ai22*ai44*ar11*ar33
  1352. + ai24*ai33*ar11*ar42 + ai24*ai42*ar11*ar33 - ai24*ai43*ar11*ar32
  1353. + ai33*ai42*ar11*ar24 - ai33*ai44*ar11*ar22 - ai34*ai42*ar11*ar23
  1354. + ai34*ai43*ar11*ar22 + ar11*ar22*ar33*ar44 - ar11*ar22*ar34*ar43
  1355. - ar11*ar23*ar32*ar44 + ar11*ar23*ar34*ar42 + ar11*ar24*ar32*ar43
  1356. - ar11*ar24*ar33*ar42
  1357. cpi00 := - ai11*ai22*ai33*ar44 + ai11*ai22*ai34*ar43 + ai11*ai22*ai43*ar34
  1358. - ai11*ai22*ai44*ar33 + ai11*ai24*ai33*ar42 + ai11*ai24*ai42*ar33
  1359. - ai11*ai24*ai43*ar32 + ai11*ai33*ai42*ar24 - ai11*ai33*ai44*ar22
  1360. - ai11*ai34*ai42*ar23 + ai11*ai34*ai43*ar22 + ai11*ar22*ar33*ar44
  1361. - ai11*ar22*ar34*ar43 - ai11*ar23*ar32*ar44 + ai11*ar23*ar34*ar42
  1362. + ai11*ar24*ar32*ar43 - ai11*ar24*ar33*ar42 - ai22*ai33*ai44*ar11
  1363. + ai22*ai34*ai43*ar11 + ai22*ar11*ar33*ar44 - ai22*ar11*ar34*ar43
  1364. + ai24*ai33*ai42*ar11 + ai24*ar11*ar32*ar43 - ai24*ar11*ar33*ar42
  1365. + ai33*ar11*ar22*ar44 - ai33*ar11*ar24*ar42 - ai34*ar11*ar22*ar43
  1366. + ai34*ar11*ar23*ar42 + ai42*ar11*ar23*ar34 - ai42*ar11*ar24*ar33
  1367. - ai43*ar11*ar22*ar34 + ai43*ar11*ar24*ar32 + ai44*ar11*ar22*ar33
  1368. - ai44*ar11*ar23*ar32
  1369. cpr01 := ai11*ai22*ar33 + ai11*ai22*ar44 - ai11*ai24*ar42 + ai11*ai33*ar22
  1370. + ai11*ai33*ar44 - ai11*ai34*ar43 - ai11*ai42*ar24 - ai11*ai43*ar34
  1371. + ai11*ai44*ar22 + ai11*ai44*ar33 + ai22*ai33*ar11 + ai22*ai33*ar44
  1372. - ai22*ai34*ar43 - ai22*ai43*ar34 + ai22*ai44*ar11 + ai22*ai44*ar33
  1373. - ai24*ai33*ar42 - ai24*ai42*ar11 - ai24*ai42*ar33 + ai24*ai43*ar32
  1374. - ai33*ai42*ar24 + ai33*ai44*ar11 + ai33*ai44*ar22 + ai34*ai42*ar23
  1375. - ai34*ai43*ar11 - ai34*ai43*ar22 - ar11*ar22*ar33 - ar11*ar22*ar44
  1376. + ar11*ar23*ar32 + ar11*ar24*ar42 - ar11*ar33*ar44 + ar11*ar34*ar43
  1377. - ar22*ar33*ar44 + ar22*ar34*ar43 + ar23*ar32*ar44 - ar23*ar34*ar42
  1378. - ar24*ar32*ar43 + ar24*ar33*ar42
  1379. cpi01 := ai11*ai22*ai33 + ai11*ai22*ai44 - ai11*ai24*ai42 + ai11*ai33*ai44
  1380. - ai11*ai34*ai43 - ai11*ar22*ar33 - ai11*ar22*ar44 + ai11*ar23*ar32
  1381. + ai11*ar24*ar42 - ai11*ar33*ar44 + ai11*ar34*ar43 + ai22*ai33*ai44
  1382. - ai22*ai34*ai43 - ai22*ar11*ar33 - ai22*ar11*ar44 - ai22*ar33*ar44
  1383. + ai22*ar34*ar43 - ai24*ai33*ai42 + ai24*ar11*ar42 - ai24*ar32*ar43
  1384. + ai24*ar33*ar42 - ai33*ar11*ar22 - ai33*ar11*ar44 - ai33*ar22*ar44
  1385. + ai33*ar24*ar42 + ai34*ar11*ar43 + ai34*ar22*ar43 - ai34*ar23*ar42
  1386. + ai42*ar11*ar24 - ai42*ar23*ar34 + ai42*ar24*ar33 + ai43*ar11*ar34
  1387. + ai43*ar22*ar34 - ai43*ar24*ar32 - ai44*ar11*ar22 - ai44*ar11*ar33
  1388. - ai44*ar22*ar33 + ai44*ar23*ar32
  1389. cpr02 := - ai11*ai22 - ai11*ai33 - ai11*ai44 - ai22*ai33 - ai22*ai44
  1390. + ai24*ai42 - ai33*ai44 + ai34*ai43 + ar11*ar22 + ar11*ar33
  1391. + ar11*ar44 + ar22*ar33 + ar22*ar44 - ar23*ar32 - ar24*ar42
  1392. + ar33*ar44 - ar34*ar43
  1393. cpi02 := ai11*ar22 + ai11*ar33 + ai11*ar44 + ai22*ar11 + ai22*ar33 + ai22*ar44
  1394. - ai24*ar42 + ai33*ar11 + ai33*ar22 + ai33*ar44 - ai34*ar43
  1395. - ai42*ar24 - ai43*ar34 + ai44*ar11 + ai44*ar22 + ai44*ar33
  1396. cpr03 := - (ar11 + ar22 + ar33 + ar44)
  1397. cpi03 := - (ai11 + ai22 + ai33 + ai44)
  1398. 2 2
  1399. rpr00 := cpi00 + cpr00
  1400. rpr01 := 2*(cpi00*cpi01 + cpr00*cpr01)
  1401. 2 2
  1402. rpr02 := 2*cpi00*cpi02 + cpi01 + 2*cpr00*cpr02 + cpr01
  1403. rpr03 := 2*(cpi00*cpi03 + cpi01*cpi02 + cpr00*cpr03 + cpr01*cpr02)
  1404. 2 2
  1405. rpr04 := 2*cpi01*cpi03 + cpi02 + 2*cpr00 + 2*cpr01*cpr03 + cpr02
  1406. rpr05 := 2*(cpi02*cpi03 + cpr01 + cpr02*cpr03)
  1407. 2 2
  1408. rpr06 := cpi03 + 2*cpr02 + cpr03
  1409. rpr07 := 2*cpr03
  1410. cleardenot;
  1411. clear aa,bb,pol;
  1412. %***********************************************************************
  1413. %***** *****
  1414. %***** T e s t Examples --- Module H U R W P *****
  1415. %***** *****
  1416. %***********************************************************************
  1417. % Example H.1
  1418. x0:=lam-1;
  1419. x0 := lam - 1
  1420. x1:=lam-(ar+i*ai);
  1421. x1 := lam - (ai*i + ar)
  1422. x2:=lam-(br+i*bi);
  1423. x2 := lam - (bi*i + br)
  1424. x3:=lam-(cr+i*ci);
  1425. x3 := lam - (ci*i + cr)
  1426. hurwitzp x1;
  1427. Necessary and sufficient conditions are:
  1428. - ar > 0
  1429. cond
  1430. % Example H.2
  1431. x:=hurw(x0*x1);
  1432. x := 2*lam*( - ai*i - ar + 1) + 2*(ai*i + ar + 1)
  1433. hurwitzp x;
  1434. Necessary and sufficient conditions are:
  1435. 2 2
  1436. 4*( - ai - ar + 1) > 0
  1437. cond
  1438. % Example H.3
  1439. x:=(x1*x2);
  1440. 2
  1441. x := lam - lam*(ai*i + ar + bi*i + br) - ai*bi + ai*br*i + ar*bi*i + ar*br
  1442. hurwitzp x;
  1443. Necessary and sufficient conditions are:
  1444. - (ar + br) > 0
  1445. 2 2 2 2
  1446. ar*br*(ai - 2*ai*bi + ar + 2*ar*br + bi + br ) > 0
  1447. cond
  1448. % Example H.4
  1449. x:=(x1*x2*x3);
  1450. 3 2
  1451. x := lam - lam *(ai*i + ar + bi*i + br + ci*i + cr) + lam*( - ai*bi + ai*br*i
  1452. - ai*ci + ai*cr*i + ar*bi*i + ar*br + ar*ci*i + ar*cr - bi*ci + bi*cr*i
  1453. + br*ci*i + br*cr) + ai*bi*ci*i + ai*bi*cr + ai*br*ci - ai*br*cr*i
  1454. + ar*bi*ci - ar*bi*cr*i - ar*br*ci*i - ar*br*cr
  1455. hurwitzp x;
  1456. Necessary and sufficient conditions are:
  1457. - (ar + br + cr) > 0
  1458. 2 2 3 3
  1459. ai *ar*br + ai *ar*cr - 2*ai*ar*bi*br - 2*ai*ar*ci*cr + ar *br + ar *cr
  1460. 2 2 2 2 2 2 3 2
  1461. + 2*ar *br + 4*ar *br*cr + 2*ar *cr + ar*bi *br + ar*br + 4*ar*br *cr
  1462. 2 2 3 2 3
  1463. + 4*ar*br*cr + ar*ci *cr + ar*cr + bi *br*cr - 2*bi*br*ci*cr + br *cr
  1464. 2 2 2 3
  1465. + 2*br *cr + br*ci *cr + br*cr > 0
  1466. 4 2 4 4 2 4 4 2 4 2
  1467. ar*br*cr*( - ai *bi + 2*ai *bi*ci - ai *br - 2*ai *br*cr - ai *ci - ai *cr
  1468. 3 3 3 2 3 2 3
  1469. + 2*ai *bi - 2*ai *bi *ci + 2*ai *bi*br + 4*ai *bi*br*cr
  1470. 3 2 3 2 3 2 3
  1471. - 2*ai *bi*ci + 2*ai *bi*cr + 2*ai *br *ci + 4*ai *br*ci*cr
  1472. 3 3 3 2 2 2 2 2 2
  1473. + 2*ai *ci + 2*ai *ci*cr - 2*ai *ar *bi + 4*ai *ar *bi*ci
  1474. 2 2 2 2 2 2 2 2 2 2 2
  1475. - 2*ai *ar *br - 4*ai *ar *br*cr - 2*ai *ar *ci - 2*ai *ar *cr
  1476. 2 2 2 2 2
  1477. - 2*ai *ar*bi *br - 2*ai *ar*bi *cr + 4*ai *ar*bi*br*ci
  1478. 2 2 3 2 2
  1479. + 4*ai *ar*bi*ci*cr - 2*ai *ar*br - 6*ai *ar*br *cr
  1480. 2 2 2 2 2 2 2 3
  1481. - 2*ai *ar*br*ci - 6*ai *ar*br*cr - 2*ai *ar*ci *cr - 2*ai *ar*cr
  1482. 2 4 2 3 2 2 2 2 2
  1483. - ai *bi - 2*ai *bi *ci - 2*ai *bi *br - 2*ai *bi *br*cr
  1484. 2 2 2 2 2 2 2 2 2
  1485. + 6*ai *bi *ci - 2*ai *bi *cr - 2*ai *bi*br *ci - 8*ai *bi*br*ci*cr
  1486. 2 3 2 2 2 4 2 3
  1487. - 2*ai *bi*ci - 2*ai *bi*ci*cr - ai *br - 2*ai *br *cr
  1488. 2 2 2 2 2 2 2 2 2 3
  1489. - 2*ai *br *ci - 2*ai *br *cr - 2*ai *br*ci *cr - 2*ai *br*cr
  1490. 2 4 2 2 2 2 4 2 3 2 2
  1491. - ai *ci - 2*ai *ci *cr - ai *cr + 2*ai*ar *bi - 2*ai*ar *bi *ci
  1492. 2 2 2 2 2
  1493. + 2*ai*ar *bi*br + 4*ai*ar *bi*br*cr - 2*ai*ar *bi*ci
  1494. 2 2 2 2 2
  1495. + 2*ai*ar *bi*cr + 2*ai*ar *br *ci + 4*ai*ar *br*ci*cr
  1496. 2 3 2 2 3 2
  1497. + 2*ai*ar *ci + 2*ai*ar *ci*cr + 4*ai*ar*bi *cr + 4*ai*ar*bi *br*ci
  1498. 2 2 2
  1499. - 8*ai*ar*bi *ci*cr + 4*ai*ar*bi*br *cr - 8*ai*ar*bi*br*ci
  1500. 2 2 3
  1501. + 8*ai*ar*bi*br*cr + 4*ai*ar*bi*ci *cr + 4*ai*ar*bi*cr
  1502. 3 2 3
  1503. + 4*ai*ar*br *ci + 8*ai*ar*br *ci*cr + 4*ai*ar*br*ci
  1504. 2 4 3 2 3 2
  1505. + 4*ai*ar*br*ci*cr + 2*ai*bi *ci - 2*ai*bi *ci + 2*ai*bi *cr
  1506. 2 2 2 2 3
  1507. + 4*ai*bi *br *ci + 4*ai*bi *br*ci*cr - 2*ai*bi *ci
  1508. 2 2 2 2 2 2
  1509. - 2*ai*bi *ci*cr - 2*ai*bi*br *ci + 2*ai*bi*br *cr
  1510. 2 3 4 2 2
  1511. + 4*ai*bi*br*ci *cr + 4*ai*bi*br*cr + 2*ai*bi*ci + 4*ai*bi*ci *cr
  1512. 4 4 3 2 3
  1513. + 2*ai*bi*cr + 2*ai*br *ci + 4*ai*br *ci*cr + 2*ai*br *ci
  1514. 2 2 4 2 4 4 2 4
  1515. + 2*ai*br *ci*cr - ar *bi + 2*ar *bi*ci - ar *br - 2*ar *br*cr
  1516. 4 2 4 2 3 2 3 2 3
  1517. - ar *ci - ar *cr - 2*ar *bi *br - 2*ar *bi *cr + 4*ar *bi*br*ci
  1518. 3 3 3 3 2 3 2
  1519. + 4*ar *bi*ci*cr - 2*ar *br - 6*ar *br *cr - 2*ar *br*ci
  1520. 3 2 3 2 3 3 2 4 2 3
  1521. - 6*ar *br*cr - 2*ar *ci *cr - 2*ar *cr - ar *bi + 2*ar *bi *ci
  1522. 2 2 2 2 2 2 2 2 2 2 2
  1523. - 2*ar *bi *br - 6*ar *bi *br*cr - 2*ar *bi *ci - 2*ar *bi *cr
  1524. 2 2 2 2 3
  1525. + 2*ar *bi*br *ci + 8*ar *bi*br*ci*cr + 2*ar *bi*ci
  1526. 2 2 2 4 2 3 2 2 2
  1527. + 2*ar *bi*ci*cr - ar *br - 6*ar *br *cr - 2*ar *br *ci
  1528. 2 2 2 2 2 2 3 2 4
  1529. - 10*ar *br *cr - 6*ar *br*ci *cr - 6*ar *br*cr - ar *ci
  1530. 2 2 2 2 4 4 3
  1531. - 2*ar *ci *cr - ar *cr - 2*ar*bi *cr + 4*ar*bi *ci*cr
  1532. 2 2 2 2 2 2
  1533. - 4*ar*bi *br *cr - 2*ar*bi *br*ci - 6*ar*bi *br*cr
  1534. 2 2 2 3 2 3
  1535. - 2*ar*bi *ci *cr - 2*ar*bi *cr + 4*ar*bi*br *ci*cr + 4*ar*bi*br*ci
  1536. 2 4 3 2 3 2
  1537. + 4*ar*bi*br*ci*cr - 2*ar*br *cr - 2*ar*br *ci - 6*ar*br *cr
  1538. 2 2 2 3 4 2 2
  1539. - 6*ar*br *ci *cr - 6*ar*br *cr - 2*ar*br*ci - 4*ar*br*ci *cr
  1540. 4 4 2 4 2 3 3 3 2
  1541. - 2*ar*br*cr - bi *ci - bi *cr + 2*bi *ci + 2*bi *ci*cr
  1542. 2 2 2 2 2 2 2 2 2 3
  1543. - 2*bi *br *ci - 2*bi *br *cr - 2*bi *br*ci *cr - 2*bi *br*cr
  1544. 2 4 2 2 2 2 4 2 3 2 2
  1545. - bi *ci - 2*bi *ci *cr - bi *cr + 2*bi*br *ci + 2*bi*br *ci*cr
  1546. 4 2 4 2 3 2 3 3 2 4
  1547. - br *ci - br *cr - 2*br *ci *cr - 2*br *cr - br *ci
  1548. 2 2 2 2 4
  1549. - 2*br *ci *cr - br *cr ) > 0
  1550. cond
  1551. clear x,x0,x1,x2,x3;
  1552. %***********************************************************************
  1553. %***** *****
  1554. %***** T e s t Examples --- Module L I N B A N D *****
  1555. %***** *****
  1556. %***********************************************************************
  1557. on evallhseqp;
  1558. % So both sides of equations evaluate.
  1559. % Example L.1
  1560. operator v;
  1561. off echo;
  1562. dimension u(200),v(200),acof(200,3),arhs(200),xl(200,3)
  1563. dx=5.0e-2
  1564. x=0.1
  1565. do 25001 i=1,101
  1566. v(i)=x**2/2.0
  1567. x=x+dx
  1568. 25001 continue
  1569. iacof=200
  1570. iarhs=200
  1571. n=1
  1572. ad(n)=1.0
  1573. aucd(n)=0.0
  1574. arhs(n)=v(1)
  1575. n=n+1
  1576. alcd(n)=1.0
  1577. ad(n)=-2.0
  1578. aucd(n)=1.0
  1579. arhs(n)=v(3)-(2.0*v(2))+v(1)
  1580. do 25002 k=3,99,1
  1581. n=n+1
  1582. alcd(n)=1.0
  1583. ad(n)=-2.0
  1584. aucd(n)=1.0
  1585. arhs(n)=v(k-1)+v(k+1)-(2.0*v(k))
  1586. 25002 continue
  1587. n=n+1
  1588. alcd(n)=1.0
  1589. ad(n)=-2.0
  1590. aucd(n)=1.0
  1591. arhs(n)=v(101)-(2.0*v(100))+v(99)
  1592. n=n+1
  1593. alcd(n)=0.0
  1594. ad(n)=1.0
  1595. arhs(n)=v(101)
  1596. call dgtsl(n,alcd,ad,aucd,arhs,ier)
  1597. c n is number of equations
  1598. c alcd,ad,aucd,arhs are arrays of dimension at least (n)
  1599. c if (ier.ne.0) matrix acof is algorithmically singular
  1600. if(ier.ne.0) call errout
  1601. n=1
  1602. u(1)=arhs(n)
  1603. n=n+1
  1604. u(2)=arhs(n)
  1605. do 25003 k=3,99,1
  1606. n=n+1
  1607. u(k)=arhs(n)
  1608. 25003 continue
  1609. n=n+1
  1610. u(100)=arhs(n)
  1611. n=n+1
  1612. u(101)=arhs(n)
  1613. amer=0.0
  1614. arer=0.0
  1615. do 25004 i=1,101
  1616. am=abs(real(u(i)-v(i)))
  1617. ar=am/v(i)
  1618. if(am.gt.amer) amer=am
  1619. if(ar.gt.arer) arer=ar
  1620. 25004 continue
  1621. write(*,100)amer,arer
  1622. stop
  1623. 100 format(' max. abs. error = ',e12.2,' max. rel. error = ',e12.2)
  1624. end
  1625. %***********************************************************************
  1626. % Example L.2
  1627. on nag;
  1628. off echo;
  1629. dimension u(200),v(200),acof(200,3),arhs(200),xl(200,3)
  1630. dx=5.0e-2
  1631. x=0.1
  1632. do 25005 i=1,101
  1633. v(i)=x**2/2.0
  1634. x=x+dx
  1635. 25005 continue
  1636. iacof=200
  1637. iarhs=200
  1638. n=1
  1639. ad(n)=1.0
  1640. aucd(n+1)=0.0
  1641. arhs(n)=v(1)
  1642. n=n+1
  1643. alcd(n)=1.0
  1644. ad(n)=-2.0
  1645. aucd(n+1)=1.0
  1646. arhs(n)=v(3)-(2.0*v(2))+v(1)
  1647. do 25006 k=3,99,1
  1648. n=n+1
  1649. alcd(n)=1.0
  1650. ad(n)=-2.0
  1651. aucd(n+1)=1.0
  1652. arhs(n)=v(k-1)+v(k+1)-(2.0*v(k))
  1653. 25006 continue
  1654. n=n+1
  1655. alcd(n)=1.0
  1656. ad(n)=-2.0
  1657. aucd(n+1)=1.0
  1658. arhs(n)=v(101)-(2.0*v(100))+v(99)
  1659. n=n+1
  1660. alcd(n)=0.0
  1661. ad(n)=1.0
  1662. arhs(n)=v(101)
  1663. ier=0
  1664. call f01lef(n,ad,0.,aucd,alcd,1.e-10,au2cd,in,ier)
  1665. c n is number of equations
  1666. c alcd,ad,aucd,au2cd,arhs are arrays of dimension at least (n)
  1667. c in is integer array of dimension at least (n)
  1668. if(ier.ne.0 .or. in(n).ne.0) call errout
  1669. call f04lef(1,n,ad,aucd,alcd,au2cd,in,arhs,0.,ier)
  1670. if(ier.ne.0) call errout
  1671. n=1
  1672. u(1)=arhs(n)
  1673. n=n+1
  1674. u(2)=arhs(n)
  1675. do 25007 k=3,99,1
  1676. n=n+1
  1677. u(k)=arhs(n)
  1678. 25007 continue
  1679. n=n+1
  1680. u(100)=arhs(n)
  1681. n=n+1
  1682. u(101)=arhs(n)
  1683. amer=0.0
  1684. arer=0.0
  1685. do 25008 i=1,101
  1686. am=abs(real(u(i)-v(i)))
  1687. ar=am/v(i)
  1688. if(am.gt.amer) amer=am
  1689. if(ar.gt.arer) arer=ar
  1690. 25008 continue
  1691. write(*,100)amer,arer
  1692. stop
  1693. 100 format(' max. abs. error = ',e12.2,' max. rel. error = ',e12.2)
  1694. end
  1695. %***********************************************************************
  1696. % Example L.3
  1697. on imsl;
  1698. off echo,nag;
  1699. dimension u(200),v(200),acof(200,3),arhs(200),xl(200,3)
  1700. dx=5.0e-2
  1701. x=0.1
  1702. do 25009 i=1,101
  1703. v(i)=x**2/2.0
  1704. x=x+dx
  1705. 25009 continue
  1706. iacof=200
  1707. iarhs=200
  1708. n=1
  1709. acof(n,1)=0.0
  1710. acof(n,2)=1.0
  1711. acof(n,3)=0.0
  1712. arhs(n)=v(1)
  1713. n=n+1
  1714. acof(n,1)=1.0
  1715. acof(n,2)=-2.0
  1716. acof(n,3)=1.0
  1717. arhs(n)=v(3)-(2.0*v(2))+v(1)
  1718. do 25010 k=3,99,1
  1719. n=n+1
  1720. acof(n,1)=1.0
  1721. acof(n,2)=-2.0
  1722. acof(n,3)=1.0
  1723. arhs(n)=v(k-1)+v(k+1)-(2.0*v(k))
  1724. 25010 continue
  1725. n=n+1
  1726. acof(n,1)=1.0
  1727. acof(n,2)=-2.0
  1728. acof(n,3)=1.0
  1729. arhs(n)=v(101)-(2.0*v(100))+v(99)
  1730. n=n+1
  1731. acof(n,1)=0.0
  1732. acof(n,2)=1.0
  1733. acof(n,3)=0.0
  1734. arhs(n)=v(101)
  1735. call leqt1b(acof,n,1,1,iacof,arhs,1,iarhs,0,xl,ier)
  1736. c iacof is actual 1-st dimension of the acof array
  1737. c iarhs is actual 1-st dimension of the arhs array
  1738. c xl is working array with size n*(nlc+1)
  1739. c where n is number of equations nlc number of lower
  1740. c codiagonals
  1741. c if ier=129( .ne.0) matrix acof is algorithmically singular
  1742. if(ier.ne.0) call errout
  1743. n=1
  1744. u(1)=arhs(n)
  1745. n=n+1
  1746. u(2)=arhs(n)
  1747. do 25011 k=3,99,1
  1748. n=n+1
  1749. u(k)=arhs(n)
  1750. 25011 continue
  1751. n=n+1
  1752. u(100)=arhs(n)
  1753. n=n+1
  1754. u(101)=arhs(n)
  1755. amer=0.0
  1756. arer=0.0
  1757. do 25012 i=1,101
  1758. am=abs(real(u(i)-v(i)))
  1759. ar=am/v(i)
  1760. if(am.gt.amer) amer=am
  1761. if(ar.gt.arer) arer=ar
  1762. 25012 continue
  1763. write(*,100)amer,arer
  1764. stop
  1765. 100 format(' max. abs. error = ',e12.2,' max. rel. error = ',e12.2)
  1766. end
  1767. %***********************************************************************
  1768. % Example L.4
  1769. on essl;
  1770. off echo,imsl;
  1771. dimension u(200),v(200),acof(200,3),arhs(200),xl(200,3)
  1772. dx=5.0e-2
  1773. x=0.1
  1774. do 25013 i=1,101
  1775. v(i)=x**2/2.0
  1776. x=x+dx
  1777. 25013 continue
  1778. iacof=200
  1779. iarhs=200
  1780. n=1
  1781. ad(n)=1.0
  1782. aucd(n)=0.0
  1783. arhs(n)=v(1)
  1784. n=n+1
  1785. alcd(n)=1.0
  1786. ad(n)=-2.0
  1787. aucd(n)=1.0
  1788. arhs(n)=v(3)-(2.0*v(2))+v(1)
  1789. do 25014 k=3,99,1
  1790. n=n+1
  1791. alcd(n)=1.0
  1792. ad(n)=-2.0
  1793. aucd(n)=1.0
  1794. arhs(n)=v(k-1)+v(k+1)-(2.0*v(k))
  1795. 25014 continue
  1796. n=n+1
  1797. alcd(n)=1.0
  1798. ad(n)=-2.0
  1799. aucd(n)=1.0
  1800. arhs(n)=v(101)-(2.0*v(100))+v(99)
  1801. n=n+1
  1802. alcd(n)=0.0
  1803. ad(n)=1.0
  1804. arhs(n)=v(101)
  1805. call dgtf(n,alcd,ad,aucd,af,ipvt)
  1806. c n is number of equations
  1807. c alcd,ad,aucd,af,arhs are arrays of dimension at least (n)
  1808. c these arrays are double precision type
  1809. c for single precision change dgtf to sgtf and dgts to sgts
  1810. c ipvt is integer array of dimension at least (n+3)/8
  1811. call dgts(n,alcd,ad,aucd,af,ipvt,arhs)
  1812. n=1
  1813. u(1)=arhs(n)
  1814. n=n+1
  1815. u(2)=arhs(n)
  1816. do 25015 k=3,99,1
  1817. n=n+1
  1818. u(k)=arhs(n)
  1819. 25015 continue
  1820. n=n+1
  1821. u(100)=arhs(n)
  1822. n=n+1
  1823. u(101)=arhs(n)
  1824. amer=0.0
  1825. arer=0.0
  1826. do 25016 i=1,101
  1827. am=abs(real(u(i)-v(i)))
  1828. ar=am/v(i)
  1829. if(am.gt.amer) amer=am
  1830. if(ar.gt.arer) arer=ar
  1831. 25016 continue
  1832. write(*,100)amer,arer
  1833. stop
  1834. 100 format(' max. abs. error = ',e12.2,' max. rel. error = ',e12.2)
  1835. end
  1836. off essl;
  1837. %***********************************************************************
  1838. %***** *****
  1839. %***** T e s t Complex Examples --- More Modules *****
  1840. %***** *****
  1841. %***********************************************************************
  1842. % Example M.1
  1843. off exp;
  1844. coordinates t,x into n,j;
  1845. grid uniform,x,t;
  1846. dependence v(t,x),w(t,x);
  1847. isgrid v(x..one),w(x..half);
  1848. iim aa, v, diff(v,t)=c*diff(w,x),
  1849. w, diff(w,t)=c*diff(v,x);
  1850. *****************************
  1851. ***** Program ***** IIMET Ver 1.1.2
  1852. *****************************
  1853. Partial Differential Equations
  1854. ==============================
  1855. diff(v,t) - diff(w,x)*c = 0
  1856. - diff(v,x)*c + diff(w,t) = 0
  1857. 0 interpolations are needed in t coordinate
  1858. Equation for v variable is integrated in half grid point
  1859. Equation for w variable is integrated in half grid point
  1860. 0 interpolations are needed in x coordinate
  1861. Equation for v variable is integrated in one grid point
  1862. Equation for w variable is integrated in half grid point
  1863. Equations after Discretization Using IIM :
  1864. ==========================================
  1865. 2*j - 1 2*j + 1 2*j + 1 2*j - 1
  1866. ((w(n,---------) - w(n,---------) - w(n + 1,---------) + w(n + 1,---------))*c
  1867. 2 2 2 2
  1868. *ht + 2*(v(n + 1,j) - v(n,j))*hx)/(2*ht*hx) = 0
  1869. ( - (v(n,j + 1) - v(n,j) - v(n + 1,j) + v(n + 1,j + 1))*c*ht
  1870. 2*j + 1 2*j + 1
  1871. + 2*(w(n + 1,---------) - w(n,---------))*hx)/(2*ht*hx) = 0
  1872. 2 2
  1873. on exp;
  1874. center t=1/2;
  1875. functions v,w;
  1876. approx( aa(0,0)=aa(0,1));
  1877. Difference scheme approximates differential equation df(v,t) - df(w,x)*c=0
  1878. with orders of approximation:
  1879. 2
  1880. ht
  1881. 2
  1882. hx
  1883. center x=1/2;
  1884. approx( aa(1,0)=aa(1,1));
  1885. Difference scheme approximates differential equation - df(v,x)*c + df(w,t)=0
  1886. with orders of approximation:
  1887. 2
  1888. ht
  1889. 2
  1890. hx
  1891. let cos ax**2=1-sin ax**2;
  1892. unfunc v,w;
  1893. matrix a(1,2),b(2,2),bt(2,2);
  1894. a(1,1):=aa(0,0);
  1895. 2*j - 1
  1896. a(1,1) := (2*v(n + 1,j)*hx - 2*v(n,j)*hx + w(n + 1,---------)*c*ht
  1897. 2
  1898. 2*j + 1 2*j - 1
  1899. - w(n + 1,---------)*c*ht + w(n,---------)*c*ht
  1900. 2 2
  1901. 2*j + 1
  1902. - w(n,---------)*c*ht)/(2*ht*hx)
  1903. 2
  1904. a(1,2):=aa(1,0);
  1905. a(1,2) := ( - v(n + 1,j + 1)*c*ht + v(n + 1,j)*c*ht - v(n,j + 1)*c*ht
  1906. 2*j + 1 2*j + 1
  1907. + v(n,j)*c*ht + 2*w(n + 1,---------)*hx - 2*w(n,---------)*hx)/(2*ht
  1908. 2 2
  1909. *hx)
  1910. off prfourmat;
  1911. b:=ampmat a;
  1912. kx*hx
  1913. ax := -------
  1914. 2
  1915. [ 2 2 2 2 ]
  1916. [ - sin(ax) *c *ht + hx 2*i*sin(ax)*c*ht*hx ]
  1917. [-------------------------- ----------------------- ]
  1918. [ 2 2 2 2 2 2 2 2 ]
  1919. [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
  1920. b := [ ]
  1921. [ 2 2 2 2 ]
  1922. [ 2*i*sin(ax)*c*ht*hx - sin(ax) *c *ht + hx ]
  1923. [ ----------------------- --------------------------]
  1924. [ 2 2 2 2 2 2 2 2 ]
  1925. [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
  1926. clear a,aa;
  1927. factor lam;
  1928. pol:=charpol b;
  1929. 2 4 4 4 2 2 2 2 4
  1930. pol := (lam *(sin(ax) *c *ht + 2*sin(ax) *c *ht *hx + hx )
  1931. 4 4 4 4 4 4 4
  1932. + 2*lam*(sin(ax) *c *ht - hx ) + sin(ax) *c *ht
  1933. 2 2 2 2 4 4 4 4 2 2 2 2
  1934. + 2*sin(ax) *c *ht *hx + hx )/(sin(ax) *c *ht + 2*sin(ax) *c *ht *hx
  1935. 4
  1936. + hx )
  1937. pol:=troot1 pol;
  1938. 2 2 2
  1939. 4*sin(ax) *c *ht
  1940. If ----------------------- = 0 and 0
  1941. 2 2 2 2
  1942. sin(ax) *c *ht + hx
  1943. = 0 , a root of the polynomial is equal to 1.
  1944. 2 4 4 4 2 2 2 2 4
  1945. pol := (lam *(sin(ax) *c *ht + 2*sin(ax) *c *ht *hx + hx )
  1946. 4 4 4 4 4 4 4
  1947. + 2*lam*(sin(ax) *c *ht - hx ) + sin(ax) *c *ht
  1948. 2 2 2 2 4 4 4 4 2 2 2 2
  1949. + 2*sin(ax) *c *ht *hx + hx )/(sin(ax) *c *ht + 2*sin(ax) *c *ht *hx
  1950. 4
  1951. + hx )
  1952. pol:=hurw num pol;
  1953. pol :=
  1954. 2 2 2 2 2 2 2 2 2 2 2 2 2
  1955. 4*lam *sin(ax) *c *ht *(sin(ax) *c *ht + hx ) + 4*hx *(sin(ax) *c *ht + hx )
  1956. hurwitzp pol;
  1957. Necessary and sufficient conditions are:
  1958. 2
  1959. hx
  1960. ----------------- > 0
  1961. 2 2 2
  1962. sin(ax) *c *ht
  1963. cond
  1964. bt:=tcon b;
  1965. [ 2 2 2 2 ]
  1966. [ - sin(ax) *c *ht + hx - 2*sin(ax)*c*ht*hx*i ]
  1967. [-------------------------- ------------------------ ]
  1968. [ 2 2 2 2 2 2 2 2 ]
  1969. [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
  1970. bt := [ ]
  1971. [ 2 2 2 2 ]
  1972. [ - 2*sin(ax)*c*ht*hx*i - sin(ax) *c *ht + hx ]
  1973. [ ------------------------ --------------------------]
  1974. [ 2 2 2 2 2 2 2 2 ]
  1975. [ sin(ax) *c *ht + hx sin(ax) *c *ht + hx ]
  1976. bt*b;
  1977. [1 0]
  1978. [ ]
  1979. [0 1]
  1980. bt*b-b*bt;
  1981. [0 0]
  1982. [ ]
  1983. [0 0]
  1984. clear aa,a,b,bt;
  1985. %***********************************************************************
  1986. % Example M.2 : Richtmyer, Morton: Difference methods for initial value
  1987. % problems, &10.2. p.261
  1988. coordinates t,x into n,j;
  1989. grid uniform,t,x;
  1990. let cos ax**2=1-sin ax**2;
  1991. unfunc v,w;
  1992. matrix a(1,2),b(2,2),bt(2,2);
  1993. a(1,1):=(v(n+1)-v(n))/ht-c*(w(j+1/2)-w(j-1/2))/hx$
  1994. a(1,2):=(w(n+1,j-1/2)-w(n,j-1/2))/ht-c*(v(n+1,j)-v(n+1,j-1))/hx$
  1995. off prfourmat;
  1996. b:=ampmat a;
  1997. kx*hx
  1998. ax := -------
  1999. 2
  2000. [ 2*i*sin(ax)*c*ht ]
  2001. [ 1 ------------------ ]
  2002. [ hx ]
  2003. [ ]
  2004. b := [ 2 2 2 2 ]
  2005. [ 2*i*sin(ax)*c*ht - 4*sin(ax) *c *ht + hx ]
  2006. [------------------ ----------------------------]
  2007. [ hx 2 ]
  2008. [ hx ]
  2009. clear a;
  2010. factor lam;
  2011. pol:=charpol b;
  2012. 2 2 2 2 2 2 2
  2013. lam *hx + 2*lam*(2*sin(ax) *c *ht - hx ) + hx
  2014. pol := --------------------------------------------------
  2015. 2
  2016. hx
  2017. pol:=hurw num pol;
  2018. 2 2 2 2 2 2 2 2
  2019. pol := 4*lam *sin(ax) *c *ht + 4*( - sin(ax) *c *ht + hx )
  2020. hurwitzp pol;
  2021. Necessary and sufficient conditions are:
  2022. 2 2 2 2
  2023. - sin(ax) *c *ht + hx
  2024. -------------------------- > 0
  2025. 2 2 2
  2026. sin(ax) *c *ht
  2027. cond
  2028. bt:=tcon b;
  2029. [ - 2*sin(ax)*c*ht*i ]
  2030. [ 1 --------------------- ]
  2031. [ hx ]
  2032. [ ]
  2033. bt := [ 2 2 2 2 ]
  2034. [ - 2*sin(ax)*c*ht*i - 4*sin(ax) *c *ht + hx ]
  2035. [--------------------- ----------------------------]
  2036. [ hx 2 ]
  2037. [ hx ]
  2038. bt*b;
  2039. [ 2 2 2 2 3 3 3 ]
  2040. [ 4*sin(ax) *c *ht + hx 8*sin(ax) *c *ht *i ]
  2041. [------------------------- --------------------- ]
  2042. [ 2 3 ]
  2043. [ hx hx ]
  2044. [ ]
  2045. [ 3 3 3 4 4 4 2 2 2 2 4 ]
  2046. [ - 8*sin(ax) *c *ht *i 16*sin(ax) *c *ht - 4*sin(ax) *c *ht *hx + hx ]
  2047. [------------------------ --------------------------------------------------]
  2048. [ 3 4 ]
  2049. [ hx hx ]
  2050. bt*b-b*bt;
  2051. [ 3 3 3 ]
  2052. [ 16*sin(ax) *c *ht *i ]
  2053. [ 0 ----------------------]
  2054. [ 3 ]
  2055. [ hx ]
  2056. [ ]
  2057. [ 3 3 3 ]
  2058. [ - 16*sin(ax) *c *ht *i ]
  2059. [------------------------- 0 ]
  2060. [ 3 ]
  2061. [ hx ]
  2062. clear a,b,bt;
  2063. %***********************************************************************
  2064. % Example M.3: Mazurik: Algoritmy resenia zadaci..., preprint no.24-85,
  2065. % AN USSR SO, Inst. teor. i prikl. mechaniky, p.34
  2066. operator v1,v2;
  2067. matrix a(1,3),b(3,3),bt(3,3);
  2068. a(1,1):=(p(n+1)-p(n))/ht+c/2*((-p(m-1)+2*p(m)-p(m+1))/hx +
  2069. (v1(m+1)-v1(m-1))/hx - (p(k-1)-2*p(k)+p(k+1))/hy +
  2070. (v2(k+1)-v2(k-1))/hy)$
  2071. a(1,2):=(v1(n+1)-v1(n))/ht+c/2*((p(m+1)-p(m-1))/hx -
  2072. (v1(m-1)-2*v1(m)+v1(m+1))/hx)$
  2073. a(1,3):=(v2(n+1)-v2(n))/ht + c/2*((p(k+1)-p(k-1))/hy -
  2074. (v2(k-1)-2*v2(k)+v2(k+1))/hy)$
  2075. coordinates t,x,y into n,m,k;
  2076. functions p,v1,v2;
  2077. for k:=1:3 do approx(a(1,k)=0);
  2078. Difference scheme approximates differential equation
  2079. df(p,t) + df(v1,x)*c + df(v2,y)*c=0
  2080. with orders of approximation:
  2081. 2
  2082. ht
  2083. hx
  2084. hy
  2085. Difference scheme approximates differential equation df(p,x)*c + df(v1,t)=0
  2086. with orders of approximation:
  2087. 2
  2088. ht
  2089. hx
  2090. 1
  2091. Difference scheme approximates differential equation df(p,y)*c + df(v2,t)=0
  2092. with orders of approximation:
  2093. 2
  2094. ht
  2095. 1
  2096. hy
  2097. grid uniform,t,x,y;
  2098. unfunc p,v1,v2;
  2099. hy:=hx;
  2100. hy := hx
  2101. off prfourmat;
  2102. b:=ampmat a;
  2103. ax := kx*hx
  2104. ay := ky*hy
  2105. cos(ax)*c*ht + cos(ay)*c*ht - 2*c*ht + hx - i*sin(ax)*c*ht
  2106. b := mat((-------------------------------------------,-------------------,
  2107. hx hx
  2108. - i*sin(ay)*c*ht
  2109. -------------------),
  2110. hx
  2111. - i*sin(ax)*c*ht cos(ax)*c*ht - c*ht + hx
  2112. (-------------------,--------------------------,0),
  2113. hx hx
  2114. - i*sin(ay)*c*ht cos(ay)*c*ht - c*ht + hx
  2115. (-------------------,0,--------------------------))
  2116. hx hx
  2117. pol:=charpol b;
  2118. 3 3 2 2
  2119. pol := (lam *hx + lam *hx *( - 2*cos(ax)*c*ht - 2*cos(ay)*c*ht + 4*c*ht - 3*hx)
  2120. 2 2 2 2
  2121. + lam*hx*(3*cos(ax)*cos(ay)*c *ht - 5*cos(ax)*c *ht
  2122. 2 2
  2123. + 4*cos(ax)*c*ht*hx - 5*cos(ay)*c *ht + 4*cos(ay)*c*ht*hx
  2124. 2 2 2 3 3
  2125. + 7*c *ht - 8*c*ht*hx + 3*hx ) + 4*cos(ax)*cos(ay)*c *ht
  2126. 2 2 3 3 2 2
  2127. - 3*cos(ax)*cos(ay)*c *ht *hx - 4*cos(ax)*c *ht + 5*cos(ax)*c *ht *hx
  2128. 2 3 3 2 2
  2129. - 2*cos(ax)*c*ht*hx - 4*cos(ay)*c *ht + 5*cos(ay)*c *ht *hx
  2130. 2 3 3 2 2 2 3 3
  2131. - 2*cos(ay)*c*ht*hx + 4*c *ht - 7*c *ht *hx + 4*c*ht*hx - hx )/hx
  2132. let
  2133. cos ax=cos ax2**2-sin ax2**2,
  2134. cos ay=cos ay2**2-sin ay2**2,
  2135. sin ax=2*sin ax2*cos ax2,
  2136. sin ay=2*sin ay2*cos ay2,
  2137. cos ax2**2=1-sin ax2**2,
  2138. cos ay2**2=1-sin ay2**2,
  2139. sin ax2=s1,
  2140. sin ay2=s2,
  2141. hx=c*ht/cap;
  2142. factor lam;
  2143. order s1,s2;
  2144. pol:=troot1 pol;
  2145. 2 2 3
  2146. If 16*s1 *s2 *cap = 0 and 0
  2147. = 0 , a root of the polynomial is equal to 1.
  2148. 3 2 2 2
  2149. pol := lam + lam *(4*s1 *cap + 4*s2 *cap - 3) + lam
  2150. 2 2 2 2 2 2 2 2 2
  2151. *(12*s1 *s2 *cap + 4*s1 *cap - 8*s1 *cap + 4*s2 *cap - 8*s2 *cap + 3)
  2152. 2 2 3 2 2 2 2 2 2
  2153. + 16*s1 *s2 *cap - 12*s1 *s2 *cap - 4*s1 *cap + 4*s1 *cap
  2154. 2 2 2
  2155. - 4*s2 *cap + 4*s2 *cap - 1
  2156. clear cos ax,cos ay,sin ax,sin ay,cos ax2**2,cos ay2**2,sin ax2,sin ay2,
  2157. hx,hy;
  2158. pol:=hurw num pol;
  2159. 3 2 2 3
  2160. pol := 16*lam *s1 *s2 *cap
  2161. 2 2 2 2 2 2 2 2
  2162. + 8*lam *cap *( - 6*s1 *s2 *cap + 3*s1 *s2 + s1 + s2 ) + 16*lam*cap
  2163. 2 2 2 2 2 2 2 2 2
  2164. *(3*s1 *s2 *cap - 3*s1 *s2 *cap - s1 *cap + s1 - s2 *cap + s2 ) + 8*(
  2165. 2 2 3 2 2 2 2 2 2 2 2
  2166. - 2*s1 *s2 *cap + 3*s1 *s2 *cap + s1 *cap - 2*s1 *cap + s2 *cap
  2167. 2
  2168. - 2*s2 *cap + 1)
  2169. hurwitzp pol;
  2170. If we denote:
  2171. 2 2 3
  2172. (1) 16*s1 *s2 *cap > 0
  2173. 2 2 2 2 2 2 2
  2174. (2) 8*cap *( - 6*s1 *s2 *cap + 3*s1 *s2 + s1 + s2 ) > 0
  2175. 2 2 2 2 2 2 2 2 2
  2176. (3) 16*cap*(3*s1 *s2 *cap - 3*s1 *s2 *cap - s1 *cap + s1 - s2 *cap + s2 )
  2177. > 0
  2178. 2 2 3 2 2 2 2 2 2 2 2
  2179. (4) 8*( - 2*s1 *s2 *cap + 3*s1 *s2 *cap + s1 *cap - 2*s1 *cap + s2 *cap
  2180. 2
  2181. - 2*s2 *cap + 1) > 0
  2182. 2 2 2 2 2 2 2
  2183. (5) 8*cap *( - 6*s1 *s2 *cap + 3*s1 *s2 + s1 + s2 ) > 0
  2184. 3 4 4 3 4 4 2 4 4
  2185. (6) 128*cap *( - 16*s1 *s2 *cap + 24*s1 *s2 *cap - 9*s1 *s2 *cap
  2186. 4 2 2 4 2 4 2 4 4
  2187. + 8*s1 *s2 *cap - 10*s1 *s2 *cap + 3*s1 *s2 - s1 *cap + s1
  2188. 2 4 2 2 4 2 4 2 2
  2189. + 8*s1 *s2 *cap - 10*s1 *s2 *cap + 3*s1 *s2 - 2*s1 *s2 *cap
  2190. 2 2 4 4
  2191. + s1 *s2 - s2 *cap + s2 ) > 0
  2192. 3 6 6 6 6 6 5 6 6 4
  2193. (7) 1024*cap *(32*s1 *s2 *cap - 96*s1 *s2 *cap + 90*s1 *s2 *cap
  2194. 6 6 3 6 4 5 6 4 4
  2195. - 27*s1 *s2 *cap - 32*s1 *s2 *cap + 100*s1 *s2 *cap
  2196. 6 4 3 6 4 2 6 2 4
  2197. - 93*s1 *s2 *cap + 27*s1 *s2 *cap + 10*s1 *s2 *cap
  2198. 6 2 3 6 2 2 6 2 6 3
  2199. - 31*s1 *s2 *cap + 26*s1 *s2 *cap - 6*s1 *s2 *cap - s1 *cap
  2200. 6 2 6 4 6 5 4 6 4
  2201. + 3*s1 *cap - 2*s1 *cap - 32*s1 *s2 *cap + 100*s1 *s2 *cap
  2202. 4 6 3 4 6 2 4 4 4
  2203. - 93*s1 *s2 *cap + 27*s1 *s2 *cap + 20*s1 *s2 *cap
  2204. 4 4 3 4 4 2 4 4
  2205. - 76*s1 *s2 *cap + 73*s1 *s2 *cap - 21*s1 *s2 *cap
  2206. 4 2 3 4 2 2 4 2
  2207. - 3*s1 *s2 *cap + 16*s1 *s2 *cap - 14*s1 *s2 *cap
  2208. 4 2 4 4 2 6 4
  2209. + 3*s1 *s2 - s1 *cap + s1 + 10*s1 *s2 *cap
  2210. 2 6 3 2 6 2 2 6
  2211. - 31*s1 *s2 *cap + 26*s1 *s2 *cap - 6*s1 *s2 *cap
  2212. 2 4 3 2 4 2 2 4
  2213. - 3*s1 *s2 *cap + 16*s1 *s2 *cap - 14*s1 *s2 *cap
  2214. 2 4 2 2 2 2 6 3 6 2
  2215. + 3*s1 *s2 - 2*s1 *s2 *cap + s1 *s2 - s2 *cap + 3*s2 *cap
  2216. 6 4 4
  2217. - 2*s2 *cap - s2 *cap + s2 ) > 0
  2218. (c1) (1) AND (2) AND (4)
  2219. (c2) (1) AND (3) AND (4)
  2220. (d1) (5) AND (7)
  2221. (d2) (6)
  2222. Necessary and sufficient conditions are:
  2223. ( (C1) OR (C2) ) AND ( (D1) OR (D2) )
  2224. cond
  2225. bt:=tcon b;
  2226. cos(ax)*c*ht + cos(ay)*c*ht - 2*c*ht + hx sin(ax)*c*ht*i
  2227. bt := mat((-------------------------------------------,----------------,
  2228. hx hx
  2229. sin(ay)*c*ht*i
  2230. ----------------),
  2231. hx
  2232. sin(ax)*c*ht*i cos(ax)*c*ht - c*ht + hx
  2233. (----------------,--------------------------,0),
  2234. hx hx
  2235. sin(ay)*c*ht*i cos(ay)*c*ht - c*ht + hx
  2236. (----------------,0,--------------------------))
  2237. hx hx
  2238. bt*b;
  2239. 2 2 2 2
  2240. mat(((2*cos(ax)*cos(ay)*c *ht - 4*cos(ax)*c *ht + 2*cos(ax)*c*ht*hx
  2241. 2 2 2 2 2 2
  2242. - 4*cos(ay)*c *ht + 2*cos(ay)*c*ht*hx + 6*c *ht - 4*c*ht*hx + hx )/hx ,
  2243. 2 2 2 2
  2244. sin(ax)*c *ht *i*( - cos(ay) + 1) sin(ay)*c *ht *i*( - cos(ax) + 1)
  2245. -----------------------------------,-----------------------------------),
  2246. 2 2
  2247. hx hx
  2248. 2 2
  2249. sin(ax)*c *ht *i*(cos(ay) - 1)
  2250. (--------------------------------,
  2251. 2
  2252. hx
  2253. 2 2 2 2 2
  2254. - 2*cos(ax)*c *ht + 2*cos(ax)*c*ht*hx + 2*c *ht - 2*c*ht*hx + hx
  2255. ----------------------------------------------------------------------,
  2256. 2
  2257. hx
  2258. 2 2
  2259. sin(ax)*sin(ay)*c *ht
  2260. ------------------------),
  2261. 2
  2262. hx
  2263. 2 2 2 2
  2264. sin(ay)*c *ht *i*(cos(ax) - 1) sin(ax)*sin(ay)*c *ht
  2265. (--------------------------------,------------------------,
  2266. 2 2
  2267. hx hx
  2268. 2 2 2 2 2
  2269. - 2*cos(ay)*c *ht + 2*cos(ay)*c*ht*hx + 2*c *ht - 2*c*ht*hx + hx
  2270. ----------------------------------------------------------------------))
  2271. 2
  2272. hx
  2273. bt*b-b*bt;
  2274. 2 2
  2275. 2*sin(ax)*c *ht *i*( - cos(ay) + 1)
  2276. mat((0,-------------------------------------,
  2277. 2
  2278. hx
  2279. 2 2
  2280. 2*sin(ay)*c *ht *i*( - cos(ax) + 1)
  2281. -------------------------------------),
  2282. 2
  2283. hx
  2284. 2 2
  2285. 2*sin(ax)*c *ht *i*(cos(ay) - 1)
  2286. (----------------------------------,0,0),
  2287. 2
  2288. hx
  2289. 2 2
  2290. 2*sin(ay)*c *ht *i*(cos(ax) - 1)
  2291. (----------------------------------,0,0))
  2292. 2
  2293. hx
  2294. clear a,b,bt,pol;
  2295. %***********************************************************************
  2296. end;
  2297. Time for test: 22393 ms