taylor.log 23 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. Sat Jun 29 14:12:23 PDT 1991
  2. REDUCE 3.4, 15-Jul-91 ...
  3. 1: 1:
  4. 2: 2:
  5. 3: 3: comment
  6. Test and demonstration file for the Taylor expansion package,
  7. by Rainer M. Schoepf. Works with version 1.3 (31-Jan-91);
  8. showtime;
  9. Time: 17 ms
  10. on errcont;
  11. % disable interruption on errors
  12. comment Simple Taylor expansion;
  13. xx := taylor (e**x, x, 0, 4);
  14. 1 2 1 3 1 4
  15. XX := 1 + X + ---*X + ---*X + ----*X + ...
  16. 2 6 24
  17. yy := taylor (e**y, y, 0, 4);
  18. 1 2 1 3 1 4
  19. YY := 1 + Y + ---*Y + ---*Y + ----*Y + ...
  20. 2 6 24
  21. comment Basic operations, i.e. addition, subtraction, multiplication,
  22. and division are possible: this is not done automatically if
  23. the switch TAYLORAUTOCOMBINE is OFF. In this case it is
  24. necessary to use taylorcombine;
  25. taylorcombine (xx**2);
  26. 2 4 3 2 4
  27. 1 + 2*X + 2*X + ---*X + ---*X + ...
  28. 3 3
  29. taylorcombine (ws - xx);
  30. 3 2 7 3 5 4
  31. X + ---*X + ---*X + ---*X + ...
  32. 2 6 8
  33. comment The result is again a Taylor kernel;
  34. if taylorseriesp ws then write "OK";
  35. OK
  36. comment It is not possible to combine Taylor kernels that were
  37. expanded with respect to different variables;
  38. taylorcombine (xx**yy);
  39. 1 2 1 3 1 4
  40. (1 + X + ---*X + ---*X + ----*X + ...)
  41. 2 6 24
  42. 1 2 1 3 1 4
  43. **(1 + Y + ---*Y + ---*Y + ----*Y + ...)
  44. 2 6 24
  45. comment But we can take the exponential or the logarithm
  46. of a Taylor kernel;
  47. taylorcombine (e**xx);
  48. 2 5*E 3 5*E 4
  49. E + E*X + E*X + -----*X + -----*X + ...
  50. 6 8
  51. taylorcombine log ws;
  52. 1 2 1 3 1 4
  53. 1 + X + ---*X + ---*X + ----*X + ...
  54. 2 6 24
  55. comment We may try to expand about another point;
  56. taylor (xx, x, 1, 2);
  57. 65 8 5 2
  58. ---- + ---*(X - 1) + ---*(X - 1) + ...
  59. 24 3 4
  60. comment Arc tangent is one of the functions this package knows of;
  61. xxa := taylorcombine atan ws;
  62. 65 1536 - 2933040 2
  63. XXA := ATAN(----) + ------*(X - 1) + ------------*(X - 1) + ...
  64. 24 4801 23049601
  65. comment Expansion with respect to more than one kernel is possible;
  66. xy := taylor (e**(x+y), x, 0, 2, y, 0, 2);
  67. 1 2 1 2 1 2 1 2
  68. XY := 1 + Y + ---*Y + X + Y*X + ---*Y *X + ---*X + ---*Y*X
  69. 2 2 2 2
  70. 1 2 2
  71. + ---*Y *X + ...
  72. 4
  73. taylorcombine (ws**2);
  74. 2 2 2 2 2 2
  75. 1 + 2*Y + 2*Y + 2*X + 4*Y*X + 4*Y *X + 2*X + 4*Y*X + 4*Y *X + ...
  76. comment We take the inverse and convert back to REDUCE's standard
  77. representation;
  78. taylorcombine (1/ws);
  79. 2 2 2 2 2 2
  80. 1 - 2*X + 2*X - 2*Y + 4*Y*X - 4*Y*X + 2*Y - 4*Y *X + 4*Y *X + ...
  81. taylortostandard ws;
  82. 2 2 2 2 2 2
  83. 4*X *Y - 4*X *Y + 2*X - 4*X*Y + 4*X*Y - 2*X + 2*Y - 2*Y + 1
  84. comment An example of Taylor kernel divsion;
  85. xx1 := taylor (sin (x), x, 0, 4);
  86. - 1 3
  87. XX1 := X + ------*X + ...
  88. 6
  89. taylorcombine (xx/xx1);
  90. -1 2
  91. X + 1 + ---*X + ...
  92. 3
  93. taylorcombine (1/xx1);
  94. -1 1 1 3
  95. X + ---*X + ----*X + ...
  96. 6 36
  97. comment Here's what I call homogeneous expansion;
  98. xx := taylor (e**(x*y), {x,y}, 0, 2);
  99. XX := 1 + Y*X + ...
  100. xx1 := taylor (sin (x+y), {x,y}, 0, 2);
  101. XX1 := Y + X + ...
  102. xx2 := taylor (cos (x+y), {x,y}, 0, 2);
  103. - 1 2 - 1 2
  104. XX2 := 1 + ------*Y - Y*X + ------*X + ...
  105. 2 2
  106. temp := taylorcombine (xx/xx2);
  107. 1 2 1 2
  108. TEMP := 1 + ---*Y + 2*Y*X + ---*X + ...
  109. 2 2
  110. taylorcombine (ws*xx2);
  111. 1 + Y*X + ...
  112. comment The following shows a principal difficulty:
  113. since xx1 is symmetric in x and y but has no constant term
  114. it is impossible to compute 1/xx1;
  115. taylorcombine (1/xx1);
  116. ***** Not a unit in argument to INVTAYLOR
  117. comment Substitution in Taylor expressions is possible;
  118. sub (x=z, xy);
  119. 1 2 1 2 1 2 1 2 1 2 2
  120. 1 + Y + ---*Y + Z + Y*Z + ---*Y *Z + ---*Z + ---*Y*Z + ---*Y *Z
  121. 2 2 2 2 4
  122. + ...
  123. comment Expression dependency in substitution is detected;
  124. sub (x=y, xy);
  125. ***** Substitution of dependent variables Y Y
  126. comment It is possible to replace a Taylor variable by a constant;
  127. sub (x=4, xy);
  128. 13 2
  129. 13 + 13*Y + ----*Y + ...
  130. 2
  131. sub (x=4, xx1);
  132. 4 + Y + ...
  133. comment This package has three switches:
  134. TAYLORKEEPORIGINAL, TAYLORAUTOEXPAND, and TAYLORAUTOCOMBINE;
  135. on taylorkeeporiginal;
  136. temp := taylor (e**(x+y), x, 0, 5);
  137. Y Y Y Y
  138. Y Y E 2 E 3 E 4 E 5
  139. TEMP := E + E *X + ----*X + ----*X + ----*X + -----*X + ...
  140. 2 6 24 120
  141. taylorcombine (log (temp));
  142. Y + X + ...
  143. taylororiginal ws;
  144. X + Y
  145. taylorcombine (temp * e**x);
  146. Y Y Y Y
  147. X Y Y E 2 E 3 E 4 E 5
  148. E *(E + E *X + ----*X + ----*X + ----*X + -----*X + ...)
  149. 2 6 24 120
  150. on taylorautoexpand;
  151. taylorcombine ws;
  152. Y Y Y
  153. Y Y Y 2 4*E 3 2*E 4 4*E 5
  154. E + (2*E )*X + (2*E )*X + ------*X + ------*X + ------*X + ...
  155. 3 3 15
  156. taylororiginal ws;
  157. 2*X + Y
  158. E
  159. taylorcombine (xx1 / x);
  160. -1 -1
  161. X + Y*X + 1 + ...
  162. on taylorautocombine;
  163. xx / xx2;
  164. 1 2 1 2
  165. 1 + ---*Y + 2*Y*X + ---*X + ...
  166. 2 2
  167. ws * xx2;
  168. 1 + Y*X + ...
  169. comment Another example that shows truncation if Taylor kernels
  170. of different expansion order are combined;
  171. p := taylor (x**2 + 2, x, 0, 10);
  172. 2
  173. P := 2 + X + ...
  174. p - x**2;
  175. 2 2
  176. (2 + X + ...) - X
  177. p - taylor (x**2, x, 0, 5);
  178. 2 + ...
  179. taylor (p - x**2, x, 0, 6);
  180. 2 + ...
  181. off taylorautocombine;
  182. taylorcombine(p-x**2);
  183. 2 + ...
  184. taylorcombine(p - taylor(x**2,x,0,5));
  185. 2 + ...
  186. comment A problem are non-analytic terms: there are no precautions
  187. taken to detect or handle them;
  188. taylor (sqrt (x), x, 0, 2);
  189. ***** Zero divisor
  190. ***** Error during expansion (possible singularity!)
  191. taylor (e**(1/x), x, 0, 2);
  192. ***** Zero divisor
  193. ***** Error during expansion (possible singularity!)
  194. comment Even worse: you can substitute a non analytical kernel;
  195. sub (y = sqrt (x), yy);
  196. 1 2 1 3 1 4
  197. 1 + SQRT(X) + ---*SQRT(X) + ---*SQRT(X) + ----*SQRT(X) + ...
  198. 2 6 24
  199. comment Expansion about infinity is possible in principle...;
  200. taylor (e**(1/x), x, infinity, 5);
  201. 1 1 1 1 1 1 1 1 1
  202. 1 + --- + ---*---- + ---*---- + ----*---- + -----*---- + ...
  203. X 2 2 6 3 24 4 120 5
  204. X X X X
  205. xi := taylor (sin (1/x), x, infinity, 5);
  206. 1 - 1 1 1 1
  207. XI := --- + ------*---- + -----*---- + ...
  208. X 6 3 120 5
  209. X X
  210. y1 := taylor(x/(x-1), x, infinity, 3);
  211. 1 1 1
  212. Y1 := 1 + --- + ---- + ---- + ...
  213. X 2 3
  214. X X
  215. z := df(y1, x);
  216. 1 1 1
  217. Z := - ---- - 2*---- - 3*---- + ...
  218. 2 3 4
  219. X X X
  220. comment ...but far from being perfect;
  221. taylor (1 / sin (x), x, infinity, 5);
  222. ***** Zero divisor
  223. ***** Error during expansion (possible singularity!)
  224. comment The template of a Taylor kernel can be extracted;
  225. taylortemplate yy;
  226. {{Y,0,4}}
  227. taylortemplate xxa;
  228. {{X,1,2}}
  229. taylortemplate xi;
  230. {{X,INFINITY,5}}
  231. taylortemplate xy;
  232. {{X,0,2},{Y,0,2}}
  233. taylortemplate xx1;
  234. {{{X,Y},0,2}}
  235. comment Here is a slightly less trivial example;
  236. exp := (sin (x) * sin (y) / (x * y))**2;
  237. 2 2
  238. SIN(X) *SIN(Y)
  239. EXP := -----------------
  240. 2 2
  241. X *Y
  242. taylor (exp, x, 0, 1, y, 0, 1);
  243. 1 + ...
  244. taylor (exp, x, 0, 2, y, 0, 2);
  245. - 1 2 - 1 2 1 2 2
  246. 1 + ------*Y + ------*X + ---*Y *X + ...
  247. 3 3 9
  248. tt := taylor (exp, {x,y}, 0, 2);
  249. - 1 2 - 1 2
  250. TT := 1 + ------*Y + ------*X + ...
  251. 3 3
  252. comment An application is the problem posed by Prof. Stanley:
  253. we prove that the finite difference expression below
  254. corresponds to the given derivative expression;
  255. comment We use gg to avoid conflicts with the predefined g operator;
  256. define g=gg;
  257. operator diff,a,f,g;
  258. for all f,arg let diff(f,arg) = df(f,arg);
  259. derivative!_expression :=
  260. diff(a(x,y)*diff(g(x,y),x)*diff(g(x,y),y)*diff(f(x,y),y),x) +
  261. diff(a(x,y)*diff(g(x,y),x)*diff(g(x,y),y)*diff(f(x,y),x),y) ;
  262. DERIVATIVE_EXPRESSION :=
  263. 2*A(X,Y)*DF(F(X,Y),X,Y)*DF(GG(X,Y),X)*DF(GG(X,Y),Y)
  264. + A(X,Y)*DF(F(X,Y),X)*DF(GG(X,Y),X,Y)*DF(GG(X,Y),Y)
  265. + A(X,Y)*DF(F(X,Y),X)*DF(GG(X,Y),X)*DF(GG(X,Y),Y,2)
  266. + A(X,Y)*DF(F(X,Y),Y)*DF(GG(X,Y),X,Y)*DF(GG(X,Y),X)
  267. + A(X,Y)*DF(F(X,Y),Y)*DF(GG(X,Y),X,2)*DF(GG(X,Y),Y)
  268. + DF(A(X,Y),X)*DF(F(X,Y),Y)*DF(GG(X,Y),X)*DF(GG(X,Y),Y)
  269. + DF(A(X,Y),Y)*DF(F(X,Y),X)*DF(GG(X,Y),X)*DF(GG(X,Y),Y)
  270. finite!_difference!_expression :=
  271. +a(x+dx,y+dy)*f(x+dx,y+dy)*g(x+dx,y+dy)^2/(32*dx^2*dy^2)
  272. +a(x+dx,y)*f(x+dx,y+dy)*g(x+dx,y+dy)^2/(32*dx^2*dy^2)
  273. +a(x,y+dy)*f(x+dx,y+dy)*g(x+dx,y+dy)^2/(32*dx^2*dy^2)
  274. +a(x,y)*f(x+dx,y+dy)*g(x+dx,y+dy)^2/(32*dx^2*dy^2)
  275. -f(x,y)*a(x+dx,y+dy)*g(x+dx,y+dy)^2/(32*dx^2*dy^2)
  276. -f(x,y)*a(x+dx,y)*g(x+dx,y+dy)^2/(32*dx^2*dy^2)
  277. -f(x,y)*a(x,y+dy)*g(x+dx,y+dy)^2/(32*dx^2*dy^2)
  278. -a(x,y)*f(x,y)*g(x+dx,y+dy)^2/(32*dx^2*dy^2)
  279. -g(x,y)*a(x+dx,y+dy)*f(x+dx,y+dy)*g(x+dx,y+dy)/(16*dx^2*dy^2)
  280. -g(x,y)*a(x+dx,y)*f(x+dx,y+dy)*g(x+dx,y+dy)/(16*dx^2*dy^2)
  281. -g(x,y)*a(x,y+dy)*f(x+dx,y+dy)*g(x+dx,y+dy)/(16*dx^2*dy^2)
  282. -a(x,y)*g(x,y)*f(x+dx,y+dy)*g(x+dx,y+dy)/(16*dx^2*dy^2)
  283. +f(x,y)*g(x,y)*a(x+dx,y+dy)*g(x+dx,y+dy)/(16*dx^2*dy^2)
  284. +f(x,y)*g(x,y)*a(x+dx,y)*g(x+dx,y+dy)/(16*dx^2*dy^2)
  285. +f(x,y)*g(x,y)*a(x,y+dy)*g(x+dx,y+dy)/(16*dx^2*dy^2)
  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,y)/(32*dx^2*dy^2)
  439. +f(x,y)*g(x,y-dy)^2*a(x-dx,y)/(32*dx^2*dy^2)
  440. -f(x,y)*g(x,y)^2*a(x-dx,y)/(16*dx^2*dy^2)
  441. +f(x,y)*a(x,y+dy)*g(x,y+dy)^2/(16*dx^2*dy^2)
  442. +a(x,y)*f(x,y)*g(x,y+dy)^2/(16*dx^2*dy^2)
  443. -f(x,y)*g(x,y)^2*a(x,y+dy)/(16*dx^2*dy^2)
  444. +f(x,y)*a(x,y-dy)*g(x,y-dy)^2/(16*dx^2*dy^2)
  445. +a(x,y)*f(x,y)*g(x,y-dy)^2/(16*dx^2*dy^2)
  446. -f(x,y)*g(x,y)^2*a(x,y-dy)/(16*dx^2*dy^2)
  447. -a(x,y)*f(x,y)*g(x,y)^2/(8*dx^2*dy^2)$
  448. comment We define abbreviations for the partial derivatives;
  449. operator ax,ay,fx,fy,gx,gy;
  450. for all x,y let df(a(x,y),x) = ax(x,y);
  451. for all x,y let df(a(x,y),y) = ay(x,y);
  452. for all x,y let df(f(x,y),x) = fx(x,y);
  453. for all x,y let df(f(x,y),y) = fy(x,y);
  454. for all x,y let df(g(x,y),x) = gx(x,y);
  455. for all x,y let df(g(x,y),y) = gy(x,y);
  456. operator axx,axy,ayy,fxx,fxy,fyy,gxx,gxy,gyy;
  457. for all x,y let df(ax(x,y),x) = axx(x,y);
  458. for all x,y let df(ax(x,y),y) = axy(x,y);
  459. for all x,y let df(ay(x,y),x) = axy(x,y);
  460. for all x,y let df(ay(x,y),y) = ayy(x,y);
  461. for all x,y let df(fx(x,y),x) = fxx(x,y);
  462. for all x,y let df(fx(x,y),y) = fxy(x,y);
  463. for all x,y let df(fy(x,y),x) = fxy(x,y);
  464. for all x,y let df(fy(x,y),y) = fyy(x,y);
  465. for all x,y let df(gx(x,y),x) = gxx(x,y);
  466. for all x,y let df(gx(x,y),y) = gxy(x,y);
  467. for all x,y let df(gy(x,y),x) = gxy(x,y);
  468. for all x,y let df(gy(x,y),y) = gyy(x,y);
  469. operator axxx,axxy,axyy,ayyy,fxxx,fxxy,fxyy,fyyy,gxxx,gxxy,gxyy,gyyy;
  470. for all x,y let df(axx(x,y),x) = axxx(x,y);
  471. for all x,y let df(axy(x,y),x) = axxy(x,y);
  472. for all x,y let df(ayy(x,y),x) = axyy(x,y);
  473. for all x,y let df(ayy(x,y),y) = ayyy(x,y);
  474. for all x,y let df(fxx(x,y),x) = fxxx(x,y);
  475. for all x,y let df(fxy(x,y),x) = fxxy(x,y);
  476. for all x,y let df(fxy(x,y),y) = fxyy(x,y);
  477. for all x,y let df(fyy(x,y),x) = fxyy(x,y);
  478. for all x,y let df(fyy(x,y),y) = fyyy(x,y);
  479. for all x,y let df(gxx(x,y),x) = gxxx(x,y);
  480. for all x,y let df(gxx(x,y),y) = gxxy(x,y);
  481. for all x,y let df(gxy(x,y),x) = gxxy(x,y);
  482. for all x,y let df(gxy(x,y),y) = gxyy(x,y);
  483. for all x,y let df(gyy(x,y),x) = gxyy(x,y);
  484. for all x,y let df(gyy(x,y),y) = gyyy(x,y);
  485. operator axxxy,axxyy,axyyy,fxxxy,fxxyy,fxyyy,
  486. gxxxx,gxxxy,gxxyy,gxyyy,gyyyy;
  487. for all x,y let df(axyy(x,y),x) = axxyy(x,y);
  488. for all x,y let df(axxy(x,y),x) = axxxy(x,y);
  489. for all x,y let df(ayyy(x,y),x) = axyyy(x,y);
  490. for all x,y let df(fxxy(x,y),x) = fxxxy(x,y);
  491. for all x,y let df(fxyy(x,y),x) = fxxyy(x,y);
  492. for all x,y let df(fyyy(x,y),x) = fxyyy(x,y);
  493. for all x,y let df(gxxx(x,y),x) = gxxxx(x,y);
  494. for all x,y let df(gxxy(x,y),x) = gxxxy(x,y);
  495. for all x,y let df(gxyy(x,y),x) = gxxyy(x,y);
  496. for all x,y let df(gyyy(x,y),x) = gxyyy(x,y);
  497. for all x,y let df(gyyy(x,y),y) = gyyyy(x,y);
  498. operator axxxyy,axxyyy,fxxyyy,fxxxyy,gxxxxy,gxxxyy,gxxyyy,gxyyyy;
  499. for all x,y let df(axxyy(x,y),x) = axxxyy(x,y);
  500. for all x,y let df(axyyy(x,y),x) = axxyyy(x,y);
  501. for all x,y let df(fxxyy(x,y),x) = fxxxyy(x,y);
  502. for all x,y let df(fxyyy(x,y),x) = fxxyyy(x,y);
  503. for all x,y let df(gxxxy(x,y),x) = gxxxxy(x,y);
  504. for all x,y let df(gxxyy(x,y),x) = gxxxyy(x,y);
  505. for all x,y let df(gxyyy(x,y),x) = gxxyyy(x,y);
  506. for all x,y let df(gyyyy(x,y),x) = gxyyyy(x,y);
  507. operator gxxxxyy,gxxxyyy,gxxyyyy;
  508. for all x,y let df(gxxxyy(x,y),x) = gxxxxyy(x,y);
  509. for all x,y let df(gxxyyy(x,y),x) = gxxxyyy(x,y);
  510. for all x,y let df(gxyyyy(x,y),x) = gxxyyyy(x,y);
  511. texp := taylor (finite!_difference!_expression, dx, 0, 1, dy, 0, 1);
  512. TEXP := A(X,Y)*FX(X,Y)*GX(X,Y)*GYY(X,Y)
  513. + A(X,Y)*FX(X,Y)*GY(X,Y)*GXY(X,Y)
  514. + A(X,Y)*FY(X,Y)*GX(X,Y)*GXY(X,Y)
  515. + A(X,Y)*FY(X,Y)*GY(X,Y)*GXX(X,Y)
  516. + 2*A(X,Y)*GX(X,Y)*GY(X,Y)*FXY(X,Y)
  517. + AX(X,Y)*FY(X,Y)*GX(X,Y)*GY(X,Y)
  518. + AY(X,Y)*FX(X,Y)*GX(X,Y)*GY(X,Y) + ...
  519. comment You may also try to expand further but this needs a lot
  520. of CPU time. Therefore the following line is commented out;
  521. %texp := taylor (finite!_difference!_expression, dx, 0, 2, dy, 0, 2);
  522. factor dx,dy;
  523. result := taylortostandard texp;
  524. RESULT := A(X,Y)*FX(X,Y)*GX(X,Y)*GYY(X,Y)
  525. + A(X,Y)*FX(X,Y)*GY(X,Y)*GXY(X,Y)
  526. + A(X,Y)*FY(X,Y)*GX(X,Y)*GXY(X,Y)
  527. + A(X,Y)*FY(X,Y)*GY(X,Y)*GXX(X,Y)
  528. + 2*A(X,Y)*GX(X,Y)*GY(X,Y)*FXY(X,Y)
  529. + AX(X,Y)*FY(X,Y)*GX(X,Y)*GY(X,Y)
  530. + AY(X,Y)*FX(X,Y)*GX(X,Y)*GY(X,Y)
  531. derivative!_expression - result;
  532. 0
  533. comment That's all, folks;
  534. showtime;
  535. Time: 19924 ms
  536. end;
  537. 4: 4:
  538. Quitting
  539. Sat Jun 29 14:12:56 PDT 1991