avector.rlg 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  1. Tue Feb 10 12:26:42 2004 run on Linux
  2. *** ^ redefined
  3. % Vector test routine
  4. % Author: David Harper (algebra@liverpool.ac.uk)
  5. % Computer Algebra Support Officer
  6. % University of Liverpool Computer Laboratory.
  7. % Please compare carefully the output from running this test file with the
  8. % log file provided to make sure your implementation is correct.
  9. linelength 72;
  10. 80
  11. off allfac;
  12. on div;
  13. vec a,b,c;
  14. matrix q;
  15. a := avec(ax,ay,az);
  16. vec(x) := ax
  17. vec(y) := ay
  18. vec(z) := az
  19. b := avec(bx,by,bz);
  20. vec(x) := bx
  21. vec(y) := by
  22. vec(z) := bz
  23. q := mat((q11,q12,q13),(q21,q22,q23),(q31,q32,q33));
  24. [q11 q12 q13]
  25. [ ]
  26. q := [q21 q22 q23]
  27. [ ]
  28. [q31 q32 q33]
  29. c := a+b;
  30. vec(x) := ax + bx
  31. vec(y) := ay + by
  32. vec(z) := az + bz
  33. c := a-b;
  34. vec(x) := ax - bx
  35. vec(y) := ay - by
  36. vec(z) := az - bz
  37. c := a cross b;
  38. vec(x) := ay*bz - az*by
  39. vec(y) := - ax*bz + az*bx
  40. vec(z) := ax*by - ay*bx
  41. d := a dot b;
  42. d := ax*bx + ay*by + az*bz
  43. a dot c;
  44. 0
  45. b dot c;
  46. 0
  47. q*a;
  48. vec(x) := ax*q11 + ay*q12 + az*q13
  49. vec(y) := ax*q21 + ay*q22 + az*q23
  50. vec(z) := ax*q31 + ay*q32 + az*q33
  51. c:=2*f*a - b/7;
  52. 1
  53. vec(x) := 2*ax*f - ---*bx
  54. 7
  55. 1
  56. vec(y) := 2*ay*f - ---*by
  57. 7
  58. 1
  59. vec(z) := 2*az*f - ---*bz
  60. 7
  61. c(0);
  62. 1
  63. 2*ax*f - ---*bx
  64. 7
  65. c(1);
  66. 1
  67. 2*ay*f - ---*by
  68. 7
  69. c(2);
  70. 1
  71. 2*az*f - ---*bz
  72. 7
  73. 1/vmod(a);
  74. 2 2 2 - 1/2
  75. (ax + ay + az )
  76. b/vmod(a);
  77. 2 2 2 - 1/2
  78. vec(x) := (ax + ay + az ) *bx
  79. 2 2 2 - 1/2
  80. vec(y) := (ax + ay + az ) *by
  81. 2 2 2 - 1/2
  82. vec(z) := (ax + ay + az ) *bz
  83. (a cross b)/(a dot b);
  84. ay*bz - az*by
  85. vec(x) := -----------------------
  86. ax*bx + ay*by + az*bz
  87. - ax*bz + az*bx
  88. vec(y) := -----------------------
  89. ax*bx + ay*by + az*bz
  90. ax*by - ay*bx
  91. vec(z) := -----------------------
  92. ax*bx + ay*by + az*bz
  93. 2/3*vmod(a)*a*(a dot c)/(vmod(a cross c));
  94. 28 2 2 2 2
  95. vec(x) := ----*(ax *by + ax *bz - 2*ax*ay*bx*by - 2*ax*az*bx*bz
  96. 3
  97. 2 2 2 2 2 2 2 2
  98. + ay *bx + ay *bz - 2*ay*az*by*bz + az *bx + az *by
  99. - 1 2 2 2 3 2 2 2
  100. )**------*sqrt(ax + ay + az )*ax *f - ---*(ax *by
  101. 2 3
  102. 2 2 2 2
  103. + ax *bz - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx
  104. 2 2 2 2 2 2 - 1
  105. + ay *bz - 2*ay*az*by*bz + az *bx + az *by )**------
  106. 2
  107. 2 2 2 2 28 2 2 2 2
  108. *sqrt(ax + ay + az )*ax *bx + ----*(ax *by + ax *bz
  109. 3
  110. 2 2 2 2
  111. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  112. 2 2 2 2 - 1
  113. - 2*ay*az*by*bz + az *bx + az *by )**------
  114. 2
  115. 2 2 2 2 2 2 2 2 2
  116. *sqrt(ax + ay + az )*ax*ay *f - ---*(ax *by + ax *bz
  117. 3
  118. 2 2 2 2
  119. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  120. 2 2 2 2 - 1
  121. - 2*ay*az*by*bz + az *bx + az *by )**------
  122. 2
  123. 2 2 2 28 2 2 2 2
  124. *sqrt(ax + ay + az )*ax*ay*by + ----*(ax *by + ax *bz
  125. 3
  126. 2 2 2 2
  127. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  128. 2 2 2 2 - 1
  129. - 2*ay*az*by*bz + az *bx + az *by )**------
  130. 2
  131. 2 2 2 2 2 2 2 2 2
  132. *sqrt(ax + ay + az )*ax*az *f - ---*(ax *by + ax *bz
  133. 3
  134. 2 2 2 2
  135. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  136. 2 2 2 2 - 1
  137. - 2*ay*az*by*bz + az *bx + az *by )**------
  138. 2
  139. 2 2 2
  140. *sqrt(ax + ay + az )*ax*az*bz
  141. 28 2 2 2 2
  142. vec(y) := ----*(ax *by + ax *bz - 2*ax*ay*bx*by - 2*ax*az*bx*bz
  143. 3
  144. 2 2 2 2 2 2 2 2
  145. + ay *bx + ay *bz - 2*ay*az*by*bz + az *bx + az *by
  146. - 1 2 2 2 2 2 2 2
  147. )**------*sqrt(ax + ay + az )*ax *ay*f - ---*(ax *by
  148. 2 3
  149. 2 2 2 2
  150. + ax *bz - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx
  151. 2 2 2 2 2 2 - 1
  152. + ay *bz - 2*ay*az*by*bz + az *bx + az *by )**------
  153. 2
  154. 2 2 2 28 2 2 2 2
  155. *sqrt(ax + ay + az )*ax*ay*bx + ----*(ax *by + ax *bz
  156. 3
  157. 2 2 2 2
  158. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  159. 2 2 2 2 - 1
  160. - 2*ay*az*by*bz + az *bx + az *by )**------
  161. 2
  162. 2 2 2 3 2 2 2 2 2
  163. *sqrt(ax + ay + az )*ay *f - ---*(ax *by + ax *bz
  164. 3
  165. 2 2 2 2
  166. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  167. 2 2 2 2 - 1
  168. - 2*ay*az*by*bz + az *bx + az *by )**------
  169. 2
  170. 2 2 2 2 28 2 2 2 2
  171. *sqrt(ax + ay + az )*ay *by + ----*(ax *by + ax *bz
  172. 3
  173. 2 2 2 2
  174. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  175. 2 2 2 2 - 1
  176. - 2*ay*az*by*bz + az *bx + az *by )**------
  177. 2
  178. 2 2 2 2 2 2 2 2 2
  179. *sqrt(ax + ay + az )*ay*az *f - ---*(ax *by + ax *bz
  180. 3
  181. 2 2 2 2
  182. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  183. 2 2 2 2 - 1
  184. - 2*ay*az*by*bz + az *bx + az *by )**------
  185. 2
  186. 2 2 2
  187. *sqrt(ax + ay + az )*ay*az*bz
  188. 28 2 2 2 2
  189. vec(z) := ----*(ax *by + ax *bz - 2*ax*ay*bx*by - 2*ax*az*bx*bz
  190. 3
  191. 2 2 2 2 2 2 2 2
  192. + ay *bx + ay *bz - 2*ay*az*by*bz + az *bx + az *by
  193. - 1 2 2 2 2 2 2 2
  194. )**------*sqrt(ax + ay + az )*ax *az*f - ---*(ax *by
  195. 2 3
  196. 2 2 2 2
  197. + ax *bz - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx
  198. 2 2 2 2 2 2 - 1
  199. + ay *bz - 2*ay*az*by*bz + az *bx + az *by )**------
  200. 2
  201. 2 2 2 28 2 2 2 2
  202. *sqrt(ax + ay + az )*ax*az*bx + ----*(ax *by + ax *bz
  203. 3
  204. 2 2 2 2
  205. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  206. 2 2 2 2 - 1
  207. - 2*ay*az*by*bz + az *bx + az *by )**------
  208. 2
  209. 2 2 2 2 2 2 2 2 2
  210. *sqrt(ax + ay + az )*ay *az*f - ---*(ax *by + ax *bz
  211. 3
  212. 2 2 2 2
  213. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  214. 2 2 2 2 - 1
  215. - 2*ay*az*by*bz + az *bx + az *by )**------
  216. 2
  217. 2 2 2 28 2 2 2 2
  218. *sqrt(ax + ay + az )*ay*az*by + ----*(ax *by + ax *bz
  219. 3
  220. 2 2 2 2
  221. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  222. 2 2 2 2 - 1
  223. - 2*ay*az*by*bz + az *bx + az *by )**------
  224. 2
  225. 2 2 2 3 2 2 2 2 2
  226. *sqrt(ax + ay + az )*az *f - ---*(ax *by + ax *bz
  227. 3
  228. 2 2 2 2
  229. - 2*ax*ay*bx*by - 2*ax*az*bx*bz + ay *bx + ay *bz
  230. 2 2 2 2 - 1
  231. - 2*ay*az*by*bz + az *bx + az *by )**------
  232. 2
  233. 2 2 2 2
  234. *sqrt(ax + ay + az )*az *bz
  235. a := avec(x**2*y**3,log(z+x),13*z-y);
  236. 2 3
  237. vec(x) := x *y
  238. vec(y) := log(x + z)
  239. vec(z) := - y + 13*z
  240. df(a,x);
  241. 3
  242. vec(x) := 2*x*y
  243. 1
  244. vec(y) := -------
  245. x + z
  246. vec(z) := 0
  247. df(a,x,y);
  248. 2
  249. vec(x) := 6*x*y
  250. vec(y) := 0
  251. vec(z) := 0
  252. int(a,x);
  253. 1 3 3
  254. vec(x) := ---*x *y
  255. 3
  256. vec(y) := log(x + z)*x + log(x + z)*z - x
  257. vec(z) := - x*y + 13*x*z
  258. exp(a);
  259. 2 3
  260. x *y
  261. vec(x) := e
  262. vec(y) := x + z
  263. - y + 13*z
  264. vec(z) := e
  265. log sin b;
  266. vec(x) := log(sin(bx))
  267. vec(y) := log(sin(by))
  268. vec(z) := log(sin(bz))
  269. a := avec(ax,ay,az);
  270. vec(x) := ax
  271. vec(y) := ay
  272. vec(z) := az
  273. depend ax,x,y,z;
  274. depend ay,x,y,z;
  275. depend az,x,y,z;
  276. depend p,x,y,z;
  277. c := grad p;
  278. vec(x) := df(p,x)
  279. vec(y) := df(p,y)
  280. vec(z) := df(p,z)
  281. div c;
  282. df(p,x,2) + df(p,y,2) + df(p,z,2)
  283. delsq p;
  284. df(p,x,2) + df(p,y,2) + df(p,z,2)
  285. div a;
  286. df(ax,x) + df(ay,y) + df(az,z)
  287. curl a;
  288. vec(x) := - df(ay,z) + df(az,y)
  289. vec(y) := df(ax,z) - df(az,x)
  290. vec(z) := - df(ax,y) + df(ay,x)
  291. delsq a;
  292. vec(x) := df(ax,x,2) + df(ax,y,2) + df(ax,z,2)
  293. vec(y) := df(ay,x,2) + df(ay,y,2) + df(ay,z,2)
  294. vec(z) := df(az,x,2) + df(az,y,2) + df(az,z,2)
  295. depend h1,x,y,z;
  296. depend h2,x,y,z;
  297. depend h3,x,y,z;
  298. scalefactors(h1,h2,h3);
  299. grad p;
  300. -1
  301. vec(x) := df(p,x)*h1
  302. -1
  303. vec(y) := df(p,y)*h2
  304. -1
  305. vec(z) := df(p,z)*h3
  306. div a;
  307. -1 -1 -1 -1 -1
  308. df(ax,x)*h1 + df(ay,y)*h2 + df(az,z)*h3 + df(h1,y)*ay*h1 *h2
  309. -1 -1 -1 -1 -1 -1
  310. + df(h1,z)*az*h1 *h3 + df(h2,x)*ax*h1 *h2 + df(h2,z)*az*h2 *h3
  311. -1 -1 -1 -1
  312. + df(h3,x)*ax*h1 *h3 + df(h3,y)*ay*h2 *h3
  313. curl a;
  314. -1 -1 -1 -1
  315. vec(x) := - df(ay,z)*h3 + df(az,y)*h2 - df(h2,z)*ay*h2 *h3
  316. -1 -1
  317. + df(h3,y)*az*h2 *h3
  318. -1 -1 -1 -1
  319. vec(y) := df(ax,z)*h3 - df(az,x)*h1 + df(h1,z)*ax*h1 *h3
  320. -1 -1
  321. - df(h3,x)*az*h1 *h3
  322. -1 -1 -1 -1
  323. vec(z) := - df(ax,y)*h2 + df(ay,x)*h1 - df(h1,y)*ax*h1 *h2
  324. -1 -1
  325. + df(h2,x)*ay*h1 *h2
  326. dp1 := delsq p;
  327. -3 -1 -2
  328. dp1 := - df(h1,x)*df(p,x)*h1 + df(h1,y)*df(p,y)*h1 *h2
  329. -1 -2 -2 -1
  330. + df(h1,z)*df(p,z)*h1 *h3 + df(h2,x)*df(p,x)*h1 *h2
  331. -3 -1 -2
  332. - df(h2,y)*df(p,y)*h2 + df(h2,z)*df(p,z)*h2 *h3
  333. -2 -1 -2 -1
  334. + df(h3,x)*df(p,x)*h1 *h3 + df(h3,y)*df(p,y)*h2 *h3
  335. -3 -2 -2
  336. - df(h3,z)*df(p,z)*h3 + df(p,x,2)*h1 + df(p,y,2)*h2
  337. -2
  338. + df(p,z,2)*h3
  339. dp2 := div grad p;
  340. -3 -1 -2
  341. dp2 := - df(h1,x)*df(p,x)*h1 + df(h1,y)*df(p,y)*h1 *h2
  342. -1 -2 -2 -1
  343. + df(h1,z)*df(p,z)*h1 *h3 + df(h2,x)*df(p,x)*h1 *h2
  344. -3 -1 -2
  345. - df(h2,y)*df(p,y)*h2 + df(h2,z)*df(p,z)*h2 *h3
  346. -2 -1 -2 -1
  347. + df(h3,x)*df(p,x)*h1 *h3 + df(h3,y)*df(p,y)*h2 *h3
  348. -3 -2 -2
  349. - df(h3,z)*df(p,z)*h3 + df(p,x,2)*h1 + df(p,y,2)*h2
  350. -2
  351. + df(p,z,2)*h3
  352. dp1-dp2;
  353. 0
  354. delsq a;
  355. -2 -3
  356. vec(x) := df(ax,x,2)*h1 - df(ax,x)*df(h1,x)*h1
  357. -2 -1 -2 -1
  358. + df(ax,x)*df(h2,x)*h1 *h2 + df(ax,x)*df(h3,x)*h1 *h3
  359. -2 -1 -2
  360. + df(ax,y,2)*h2 + df(ax,y)*df(h1,y)*h1 *h2
  361. -3 -2 -1
  362. - df(ax,y)*df(h2,y)*h2 + df(ax,y)*df(h3,y)*h2 *h3
  363. -2 -1 -2
  364. + df(ax,z,2)*h3 + df(ax,z)*df(h1,z)*h1 *h3
  365. -1 -2 -3
  366. + df(ax,z)*df(h2,z)*h2 *h3 - df(ax,z)*df(h3,z)*h3
  367. -2 -1
  368. + 2*df(ay,x)*df(h1,y)*h1 *h2
  369. -1 -2
  370. - 2*df(ay,y)*df(h2,x)*h1 *h2
  371. -2 -1
  372. + 2*df(az,x)*df(h1,z)*h1 *h3
  373. -1 -2 -2 -1
  374. - 2*df(az,z)*df(h3,x)*h1 *h3 + df(h1,x,y)*ay*h1 *h2
  375. -2 -1 -3 -1
  376. + df(h1,x,z)*az*h1 *h3 - df(h1,x)*df(h1,y)*ay*h1 *h2
  377. -3 -1
  378. - df(h1,x)*df(h1,z)*az*h1 *h3
  379. -3 -1
  380. - df(h1,x)*df(h2,x)*ax*h1 *h2
  381. -3 -1 -1 -2
  382. - df(h1,x)*df(h3,x)*ax*h1 *h3 + df(h1,y,2)*ax*h1 *h2
  383. 2 -2 -2 -1 -3
  384. - df(h1,y) *ax*h1 *h2 - df(h1,y)*df(h2,y)*ax*h1 *h2
  385. -1 -2 -1
  386. + df(h1,y)*df(h3,y)*ax*h1 *h2 *h3
  387. -1 -2 2 -2 -2
  388. + df(h1,z,2)*ax*h1 *h3 - df(h1,z) *ax*h1 *h3
  389. -1 -1 -2
  390. + df(h1,z)*df(h2,z)*ax*h1 *h2 *h3
  391. -1 -3 -1 -2
  392. - df(h1,z)*df(h3,z)*ax*h1 *h3 - df(h2,x,y)*ay*h1 *h2
  393. -1 -1 -1 -2 -1
  394. + df(h2,x,z)*az*h1 *h2 *h3 + df(h2,x,2)*ax*h1 *h2
  395. 2 -2 -2 -1 -3
  396. - df(h2,x) *ax*h1 *h2 + df(h2,x)*df(h2,y)*ay*h1 *h2
  397. -1 -2 -1
  398. - df(h2,x)*df(h2,z)*az*h1 *h2 *h3
  399. -1 -2 -1
  400. - 2*df(h2,x)*df(h3,y)*ay*h1 *h2 *h3
  401. -1 -1 -2
  402. - 2*df(h2,z)*df(h3,x)*az*h1 *h2 *h3
  403. -1 -1 -1 -1 -2
  404. + df(h3,x,y)*ay*h1 *h2 *h3 - df(h3,x,z)*az*h1 *h3
  405. -2 -1 2 -2 -2
  406. + df(h3,x,2)*ax*h1 *h3 - df(h3,x) *ax*h1 *h3
  407. -1 -1 -2
  408. - df(h3,x)*df(h3,y)*ay*h1 *h2 *h3
  409. -1 -3
  410. + df(h3,x)*df(h3,z)*az*h1 *h3
  411. -2 -1
  412. vec(y) := - 2*df(ax,x)*df(h1,y)*h1 *h2
  413. -1 -2 -2
  414. + 2*df(ax,y)*df(h2,x)*h1 *h2 + df(ay,x,2)*h1
  415. -3 -2 -1
  416. - df(ay,x)*df(h1,x)*h1 + df(ay,x)*df(h2,x)*h1 *h2
  417. -2 -1 -2
  418. + df(ay,x)*df(h3,x)*h1 *h3 + df(ay,y,2)*h2
  419. -1 -2 -3
  420. + df(ay,y)*df(h1,y)*h1 *h2 - df(ay,y)*df(h2,y)*h2
  421. -2 -1 -2
  422. + df(ay,y)*df(h3,y)*h2 *h3 + df(ay,z,2)*h3
  423. -1 -2 -1 -2
  424. + df(ay,z)*df(h1,z)*h1 *h3 + df(ay,z)*df(h2,z)*h2 *h3
  425. -3 -2 -1
  426. - df(ay,z)*df(h3,z)*h3 + 2*df(az,y)*df(h2,z)*h2 *h3
  427. -1 -2 -2 -1
  428. - 2*df(az,z)*df(h3,y)*h2 *h3 - df(h1,x,y)*ax*h1 *h2
  429. -3 -1
  430. + df(h1,x)*df(h1,y)*ax*h1 *h2
  431. -3 -1
  432. - df(h1,x)*df(h2,x)*ay*h1 *h2
  433. -1 -1 -1 -1 -2
  434. + df(h1,y,z)*az*h1 *h2 *h3 + df(h1,y,2)*ay*h1 *h2
  435. 2 -2 -2
  436. - df(h1,y) *ay*h1 *h2
  437. -2 -1 -1
  438. - df(h1,y)*df(h1,z)*az*h1 *h2 *h3
  439. -1 -3
  440. - df(h1,y)*df(h2,y)*ay*h1 *h2
  441. -2 -1 -1
  442. - 2*df(h1,y)*df(h3,x)*ax*h1 *h2 *h3
  443. -1 -1 -2
  444. + df(h1,z)*df(h2,z)*ay*h1 *h2 *h3
  445. -1 -1 -2
  446. - 2*df(h1,z)*df(h3,y)*az*h1 *h2 *h3
  447. -1 -2 -2 -1
  448. + df(h2,x,y)*ax*h1 *h2 + df(h2,x,2)*ay*h1 *h2
  449. 2 -2 -2 -1 -3
  450. - df(h2,x) *ay*h1 *h2 - df(h2,x)*df(h2,y)*ax*h1 *h2
  451. -2 -1 -1
  452. + df(h2,x)*df(h3,x)*ay*h1 *h2 *h3
  453. -2 -1 -3 -1
  454. + df(h2,y,z)*az*h2 *h3 - df(h2,y)*df(h2,z)*az*h2 *h3
  455. -3 -1 -1 -2
  456. - df(h2,y)*df(h3,y)*ay*h2 *h3 + df(h2,z,2)*ay*h2 *h3
  457. 2 -2 -2 -1 -3
  458. - df(h2,z) *ay*h2 *h3 - df(h2,z)*df(h3,z)*ay*h2 *h3
  459. -1 -1 -1
  460. + df(h3,x,y)*ax*h1 *h2 *h3
  461. -1 -1 -2
  462. - df(h3,x)*df(h3,y)*ax*h1 *h2 *h3
  463. -1 -2 -2 -1
  464. - df(h3,y,z)*az*h2 *h3 + df(h3,y,2)*ay*h2 *h3
  465. 2 -2 -2 -1 -3
  466. - df(h3,y) *ay*h2 *h3 + df(h3,y)*df(h3,z)*az*h2 *h3
  467. -2 -1
  468. vec(z) := - 2*df(ax,x)*df(h1,z)*h1 *h3
  469. -1 -2
  470. + 2*df(ax,z)*df(h3,x)*h1 *h3
  471. -2 -1
  472. - 2*df(ay,y)*df(h2,z)*h2 *h3
  473. -1 -2 -2
  474. + 2*df(ay,z)*df(h3,y)*h2 *h3 + df(az,x,2)*h1
  475. -3 -2 -1
  476. - df(az,x)*df(h1,x)*h1 + df(az,x)*df(h2,x)*h1 *h2
  477. -2 -1 -2
  478. + df(az,x)*df(h3,x)*h1 *h3 + df(az,y,2)*h2
  479. -1 -2 -3
  480. + df(az,y)*df(h1,y)*h1 *h2 - df(az,y)*df(h2,y)*h2
  481. -2 -1 -2
  482. + df(az,y)*df(h3,y)*h2 *h3 + df(az,z,2)*h3
  483. -1 -2 -1 -2
  484. + df(az,z)*df(h1,z)*h1 *h3 + df(az,z)*df(h2,z)*h2 *h3
  485. -3 -2 -1
  486. - df(az,z)*df(h3,z)*h3 - df(h1,x,z)*ax*h1 *h3
  487. -3 -1
  488. + df(h1,x)*df(h1,z)*ax*h1 *h3
  489. -3 -1
  490. - df(h1,x)*df(h3,x)*az*h1 *h3
  491. -1 -1 -1
  492. + df(h1,y,z)*ay*h1 *h2 *h3
  493. -2 -1 -1
  494. - df(h1,y)*df(h1,z)*ay*h1 *h2 *h3
  495. -1 -2 -1
  496. - 2*df(h1,y)*df(h2,z)*ay*h1 *h2 *h3
  497. -1 -2 -1
  498. + df(h1,y)*df(h3,y)*az*h1 *h2 *h3
  499. -1 -2 2 -2 -2
  500. + df(h1,z,2)*az*h1 *h3 - df(h1,z) *az*h1 *h3
  501. -2 -1 -1
  502. - 2*df(h1,z)*df(h2,x)*ax*h1 *h2 *h3
  503. -1 -3
  504. - df(h1,z)*df(h3,z)*az*h1 *h3
  505. -1 -1 -1
  506. + df(h2,x,z)*ax*h1 *h2 *h3
  507. -1 -2 -1
  508. - df(h2,x)*df(h2,z)*ax*h1 *h2 *h3
  509. -2 -1 -1
  510. + df(h2,x)*df(h3,x)*az*h1 *h2 *h3
  511. -2 -1 -3 -1
  512. - df(h2,y,z)*ay*h2 *h3 + df(h2,y)*df(h2,z)*ay*h2 *h3
  513. -3 -1 -1 -2
  514. - df(h2,y)*df(h3,y)*az*h2 *h3 + df(h2,z,2)*az*h2 *h3
  515. 2 -2 -2 -1 -3
  516. - df(h2,z) *az*h2 *h3 - df(h2,z)*df(h3,z)*az*h2 *h3
  517. -1 -2 -2 -1
  518. + df(h3,x,z)*ax*h1 *h3 + df(h3,x,2)*az*h1 *h3
  519. 2 -2 -2 -1 -3
  520. - df(h3,x) *az*h1 *h3 - df(h3,x)*df(h3,z)*ax*h1 *h3
  521. -1 -2 -2 -1
  522. + df(h3,y,z)*ay*h2 *h3 + df(h3,y,2)*az*h2 *h3
  523. 2 -2 -2 -1 -3
  524. - df(h3,y) *az*h2 *h3 - df(h3,y)*df(h3,z)*ay*h2 *h3
  525. curl grad p;
  526. vec(x) := 0
  527. vec(y) := 0
  528. vec(z) := 0
  529. grad div a;
  530. -2 -3
  531. vec(x) := df(ax,x,2)*h1 - df(ax,x)*df(h1,x)*h1
  532. -2 -1 -2 -1
  533. + df(ax,x)*df(h2,x)*h1 *h2 + df(ax,x)*df(h3,x)*h1 *h3
  534. -1 -1 -2 -1
  535. + df(ay,x,y)*h1 *h2 + df(ay,x)*df(h1,y)*h1 *h2
  536. -1 -1 -1
  537. + df(ay,x)*df(h3,y)*h1 *h2 *h3
  538. -1 -2 -1 -1
  539. - df(ay,y)*df(h2,x)*h1 *h2 + df(az,x,z)*h1 *h3
  540. -2 -1
  541. + df(az,x)*df(h1,z)*h1 *h3
  542. -1 -1 -1
  543. + df(az,x)*df(h2,z)*h1 *h2 *h3
  544. -1 -2 -2 -1
  545. - df(az,z)*df(h3,x)*h1 *h3 + df(h1,x,y)*ay*h1 *h2
  546. -2 -1 -3 -1
  547. + df(h1,x,z)*az*h1 *h3 - df(h1,x)*df(h1,y)*ay*h1 *h2
  548. -3 -1
  549. - df(h1,x)*df(h1,z)*az*h1 *h3
  550. -3 -1
  551. - df(h1,x)*df(h2,x)*ax*h1 *h2
  552. -3 -1
  553. - df(h1,x)*df(h3,x)*ax*h1 *h3
  554. -2 -2
  555. - df(h1,y)*df(h2,x)*ay*h1 *h2
  556. -2 -2
  557. - df(h1,z)*df(h3,x)*az*h1 *h3
  558. -1 -1 -1 -2 -1
  559. + df(h2,x,z)*az*h1 *h2 *h3 + df(h2,x,2)*ax*h1 *h2
  560. 2 -2 -2
  561. - df(h2,x) *ax*h1 *h2
  562. -1 -2 -1
  563. - df(h2,x)*df(h2,z)*az*h1 *h2 *h3
  564. -1 -2 -1
  565. - df(h2,x)*df(h3,y)*ay*h1 *h2 *h3
  566. -1 -1 -2
  567. - df(h2,z)*df(h3,x)*az*h1 *h2 *h3
  568. -1 -1 -1 -2 -1
  569. + df(h3,x,y)*ay*h1 *h2 *h3 + df(h3,x,2)*ax*h1 *h3
  570. 2 -2 -2
  571. - df(h3,x) *ax*h1 *h3
  572. -1 -1 -2
  573. - df(h3,x)*df(h3,y)*ay*h1 *h2 *h3
  574. -1 -1 -2 -1
  575. vec(y) := df(ax,x,y)*h1 *h2 - df(ax,x)*df(h1,y)*h1 *h2
  576. -1 -2
  577. + df(ax,y)*df(h2,x)*h1 *h2
  578. -1 -1 -1 -2
  579. + df(ax,y)*df(h3,x)*h1 *h2 *h3 + df(ay,y,2)*h2
  580. -1 -2 -3
  581. + df(ay,y)*df(h1,y)*h1 *h2 - df(ay,y)*df(h2,y)*h2
  582. -2 -1 -1 -1
  583. + df(ay,y)*df(h3,y)*h2 *h3 + df(az,y,z)*h2 *h3
  584. -1 -1 -1
  585. + df(az,y)*df(h1,z)*h1 *h2 *h3
  586. -2 -1 -1 -2
  587. + df(az,y)*df(h2,z)*h2 *h3 - df(az,z)*df(h3,y)*h2 *h3
  588. -1 -1 -1 -1 -2
  589. + df(h1,y,z)*az*h1 *h2 *h3 + df(h1,y,2)*ay*h1 *h2
  590. 2 -2 -2
  591. - df(h1,y) *ay*h1 *h2
  592. -2 -1 -1
  593. - df(h1,y)*df(h1,z)*az*h1 *h2 *h3
  594. -2 -2
  595. - df(h1,y)*df(h2,x)*ax*h1 *h2
  596. -1 -3
  597. - df(h1,y)*df(h2,y)*ay*h1 *h2
  598. -2 -1 -1
  599. - df(h1,y)*df(h3,x)*ax*h1 *h2 *h3
  600. -1 -1 -2
  601. - df(h1,z)*df(h3,y)*az*h1 *h2 *h3
  602. -1 -2 -1 -3
  603. + df(h2,x,y)*ax*h1 *h2 - df(h2,x)*df(h2,y)*ax*h1 *h2
  604. -2 -1 -3 -1
  605. + df(h2,y,z)*az*h2 *h3 - df(h2,y)*df(h2,z)*az*h2 *h3
  606. -3 -1
  607. - df(h2,y)*df(h3,y)*ay*h2 *h3
  608. -2 -2
  609. - df(h2,z)*df(h3,y)*az*h2 *h3
  610. -1 -1 -1
  611. + df(h3,x,y)*ax*h1 *h2 *h3
  612. -1 -1 -2
  613. - df(h3,x)*df(h3,y)*ax*h1 *h2 *h3
  614. -2 -1 2 -2 -2
  615. + df(h3,y,2)*ay*h2 *h3 - df(h3,y) *ay*h2 *h3
  616. -1 -1 -2 -1
  617. vec(z) := df(ax,x,z)*h1 *h3 - df(ax,x)*df(h1,z)*h1 *h3
  618. -1 -1 -1
  619. + df(ax,z)*df(h2,x)*h1 *h2 *h3
  620. -1 -2 -1 -1
  621. + df(ax,z)*df(h3,x)*h1 *h3 + df(ay,y,z)*h2 *h3
  622. -2 -1
  623. - df(ay,y)*df(h2,z)*h2 *h3
  624. -1 -1 -1
  625. + df(ay,z)*df(h1,y)*h1 *h2 *h3
  626. -1 -2 -2
  627. + df(ay,z)*df(h3,y)*h2 *h3 + df(az,z,2)*h3
  628. -1 -2 -1 -2
  629. + df(az,z)*df(h1,z)*h1 *h3 + df(az,z)*df(h2,z)*h2 *h3
  630. -3 -1 -1 -1
  631. - df(az,z)*df(h3,z)*h3 + df(h1,y,z)*ay*h1 *h2 *h3
  632. -2 -1 -1
  633. - df(h1,y)*df(h1,z)*ay*h1 *h2 *h3
  634. -1 -2 -1
  635. - df(h1,y)*df(h2,z)*ay*h1 *h2 *h3
  636. -1 -2 2 -2 -2
  637. + df(h1,z,2)*az*h1 *h3 - df(h1,z) *az*h1 *h3
  638. -2 -1 -1
  639. - df(h1,z)*df(h2,x)*ax*h1 *h2 *h3
  640. -2 -2
  641. - df(h1,z)*df(h3,x)*ax*h1 *h3
  642. -1 -3
  643. - df(h1,z)*df(h3,z)*az*h1 *h3
  644. -1 -1 -1
  645. + df(h2,x,z)*ax*h1 *h2 *h3
  646. -1 -2 -1
  647. - df(h2,x)*df(h2,z)*ax*h1 *h2 *h3
  648. -1 -2 2 -2 -2
  649. + df(h2,z,2)*az*h2 *h3 - df(h2,z) *az*h2 *h3
  650. -2 -2
  651. - df(h2,z)*df(h3,y)*ay*h2 *h3
  652. -1 -3 -1 -2
  653. - df(h2,z)*df(h3,z)*az*h2 *h3 + df(h3,x,z)*ax*h1 *h3
  654. -1 -3 -1 -2
  655. - df(h3,x)*df(h3,z)*ax*h1 *h3 + df(h3,y,z)*ay*h2 *h3
  656. -1 -3
  657. - df(h3,y)*df(h3,z)*ay*h2 *h3
  658. div curl a;
  659. 0
  660. % Examples of integration : (1) Volume integrals
  661. getcsystem 'spherical;
  662. (r theta phi)
  663. % Example 1 : integration of r**n over a sphere
  664. origin := avec(0,0,0);
  665. vec(r) := 0
  666. vec(theta) := 0
  667. vec(phi) := 0
  668. upperbound := avec(rr,pi,2*pi);
  669. vec(r) := rr
  670. vec(theta) := pi
  671. vec(phi) := 2*pi
  672. volintegral(r**n,origin,upperbound);
  673. n 3
  674. 4*rr *pi*rr
  675. --------------
  676. n + 3
  677. % Substitute n=0 to get the volume of a sphere
  678. sub(n=0,ws);
  679. 4 3
  680. ---*pi*rr
  681. 3
  682. % Example 2 : volume of a right-circular cone
  683. getcsystem 'cylindrical;
  684. (r z phi)
  685. upperbound := avec(pp*z,h,2*pi);
  686. vec(r) := pp*z
  687. vec(z) := h
  688. vec(phi) := 2*pi
  689. volintorder := avec(2,0,1);
  690. vec(r) := 2
  691. vec(z) := 0
  692. vec(phi) := 1
  693. % Integrate in the order : phi, r, z
  694. cone := volintegral(1,origin,upperbound);
  695. 1 3 2
  696. cone := ---*h *pi*pp
  697. 3
  698. % Now we replace P*Z by RR to get the result in the familiar form
  699. let pp*h=rr;
  700. cone := cone;
  701. 1 2
  702. cone := ---*h*pi*rr
  703. 3
  704. % This is the familiar form
  705. clear pp*h;
  706. % Example 3 : line integral to obtain the length of a line of latitude
  707. % on a sphere
  708. getcsystem 'spherical;
  709. (r theta phi)
  710. a := avec(0,0,1);
  711. vec(r) := 0
  712. vec(theta) := 0
  713. vec(phi) := 1
  714. % Function vector is the tangent to the
  715. % line of latitude
  716. curve := avec(rr,latitude,phi);
  717. vec(r) := rr
  718. vec(theta) := latitude
  719. vec(phi) := phi
  720. % Path is round a line of latitude
  721. deflineint(a,curve,phi,0,2*pi);
  722. 2*sin(latitude)*pi*rr
  723. end;
  724. Time for test: 60 ms, plus GC time: 10 ms