reduce.log 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. Codemist Standard Lisp 3.54 for DEC Alpha: May 23 1994
  2. Dump file created: Mon May 23 10:39:11 1994
  3. REDUCE 3.5, 15-Oct-93 ...
  4. Memory allocation: 6023424 bytes
  5. +++ About to read file ndotest.red
  6. Comment This is a standard test file for REDUCE that has been used for
  7. many years. It only tests a limited number of facilities in the
  8. current system. In particular, it does not test floating point
  9. arithmetic, or any of the more advanced packages that have been made
  10. available since REDUCE 3.0 was released. It has been used for a long
  11. time to benchmark the performance of REDUCE. A description of this
  12. benchmarking with statistics for REDUCE 3.2 was reported in Jed B.
  13. Marti and Anthony C. Hearn, "REDUCE as a Lisp Benchmark", SIGSAM Bull.
  14. 19 (1985) 8-16. That paper also gives information on the the parts of
  15. the system exercised by the test file. Updated statistics may be found
  16. in the "timings" file in the REDUCE Network Library;
  17. showtime;
  18. Time: 0 ms
  19. comment some examples of the FOR statement;
  20. comment summing the squares of the even positive integers
  21. through 50;
  22. for i:=2 step 2 until 50 sum i**2;
  23. 22100
  24. comment to set w to the factorial of 10;
  25. w := for i:=1:10 product i;
  26. w := 3628800
  27. comment alternatively, we could set the elements a(i) of the
  28. array a to the factorial of i by the statements;
  29. array a(10);
  30. a(0):=1$
  31. for i:=1:10 do a(i):=i*a(i-1);
  32. comment the above version of the FOR statement does not return
  33. an algebraic value, but we can now use these array
  34. elements as factorials in expressions, e. g.;
  35. 1+a(5);
  36. 121
  37. comment we could have printed the values of each a(i)
  38. as they were computed by writing the FOR statement as;
  39. for i:=1:10 do write a(i):= i*a(i-1);
  40. a(1) := 1
  41. a(2) := 2
  42. a(3) := 6
  43. a(4) := 24
  44. a(5) := 120
  45. a(6) := 720
  46. a(7) := 5040
  47. a(8) := 40320
  48. a(9) := 362880
  49. a(10) := 3628800
  50. comment another way to use factorials would be to introduce an
  51. operator FAC by an integer procedure as follows;
  52. integer procedure fac (n);
  53. begin integer m;
  54. m:=1;
  55. l1: if n=0 then return m;
  56. m:=m*n;
  57. n:=n-1;
  58. go to l1
  59. end;
  60. fac
  61. comment we can now use fac as an operator in expressions, e. g.;
  62. z**2+fac(4)-2*fac 2*y;
  63. 2
  64. - 4*y + z + 24
  65. comment note in the above example that the parentheses around
  66. the arguments of FAC may be omitted since it is a unary operator;
  67. comment the following examples illustrate the solution of some
  68. complete problems;
  69. comment the f and g series (ref Sconzo, P., Leschack, A. R. and
  70. Tobey, R. G., Astronomical Journal, Vol 70 (May 1965);
  71. deps:= -sigma*(mu+2*epsilon)$
  72. dmu:= -3*mu*sigma$
  73. dsig:= epsilon-2*sigma**2$
  74. f1:= 1$
  75. g1:= 0$
  76. for i:= 1:8 do
  77. <<f2:=-mu*g1 + deps*df(f1,epsilon) + dmu*df(f1,mu) + dsig*df(f1,sigma);
  78. write "F(",i,") := ",f2;
  79. g2:= f1 + deps*df(g1,epsilon) + dmu*df(g1,mu) + dsig*df(g1,sigma);
  80. write "G(",i,") := ",g2;
  81. f1:=f2;
  82. g1:=g2>>;
  83. F(1) := 0
  84. G(1) := 1
  85. F(2) := - mu
  86. G(2) := 0
  87. F(3) := 3*mu*sigma
  88. G(3) := - mu
  89. 2
  90. F(4) := mu*(3*epsilon + mu - 15*sigma )
  91. G(4) := 6*mu*sigma
  92. 2
  93. F(5) := 15*mu*sigma*( - 3*epsilon - mu + 7*sigma )
  94. 2
  95. G(5) := mu*(9*epsilon + mu - 45*sigma )
  96. 2 2 2
  97. F(6) := mu*( - 45*epsilon - 24*epsilon*mu + 630*epsilon*sigma - mu
  98. 2 4
  99. + 210*mu*sigma - 945*sigma )
  100. 2
  101. G(6) := 30*mu*sigma*( - 6*epsilon - mu + 14*sigma )
  102. 2 2
  103. F(7) := 63*mu*sigma*(25*epsilon + 14*epsilon*mu - 150*epsilon*sigma
  104. 2 2 4
  105. + mu - 50*mu*sigma + 165*sigma )
  106. 2 2
  107. G(7) := mu*( - 225*epsilon - 54*epsilon*mu + 3150*epsilon*sigma
  108. 2 2 4
  109. - mu + 630*mu*sigma - 4725*sigma )
  110. 3 2 2 2
  111. F(8) := mu*(1575*epsilon + 1107*epsilon *mu - 42525*epsilon *sigma
  112. 2 2
  113. + 117*epsilon*mu - 24570*epsilon*mu*sigma
  114. 4 3 2 2
  115. + 155925*epsilon*sigma + mu - 2205*mu *sigma
  116. 4 6
  117. + 51975*mu*sigma - 135135*sigma )
  118. 2
  119. G(8) := 126*mu*sigma*(75*epsilon + 24*epsilon*mu
  120. 2 2 2 4
  121. - 450*epsilon*sigma + mu - 100*mu*sigma + 495*sigma )
  122. comment a problem in Fourier analysis;
  123. factor cos,sin;
  124. on list;
  125. (a1*cos(omega*t) + a3*cos(3*omega*t) + b1*sin(omega*t)
  126. + b3*sin(3*omega*t))**3
  127. where {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
  128. cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
  129. sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
  130. cos(~x)**2 => (1+cos(2*x))/2,
  131. sin(~x)**2 => (1-cos(2*x))/2};
  132. 3
  133. (3*cos(omega*t)*(a1
  134. 2
  135. +a1 *a3
  136. 2
  137. +2*a1*a3
  138. 2
  139. +a1*b1
  140. +2*a1*b1*b3
  141. 2
  142. +2*a1*b3
  143. 2
  144. -a3*b1 )
  145. 2
  146. +cos(9*omega*t)*a3*(a3
  147. 2
  148. -3*b3 )
  149. 2
  150. +3*cos(7*omega*t)*(a1*a3
  151. 2
  152. -a1*b3
  153. -2*a3*b1*b3)
  154. 2
  155. +3*cos(5*omega*t)*(a1 *a3
  156. 2
  157. +a1*a3
  158. -2*a1*b1*b3
  159. 2
  160. -a1*b3
  161. 2
  162. -a3*b1
  163. +2*a3*b1*b3)
  164. 3
  165. +cos(3*omega*t)*(a1
  166. 2
  167. +6*a1 *a3
  168. 2
  169. -3*a1*b1
  170. 3
  171. +3*a3
  172. 2
  173. +6*a3*b1
  174. 2
  175. +3*a3*b3 )
  176. 2
  177. +3*sin(omega*t)*(a1 *b1
  178. 2
  179. +a1 *b3
  180. -2*a1*a3*b1
  181. 2
  182. +2*a3 *b1
  183. 3
  184. +b1
  185. 2
  186. -b1 *b3
  187. 2
  188. +2*b1*b3 )
  189. 2
  190. +sin(9*omega*t)*b3*(3*a3
  191. 2
  192. -b3 )
  193. +3*sin(7*omega*t)*(2*a1*a3*b3
  194. 2
  195. +a3 *b1
  196. 2
  197. -b1*b3 )
  198. 2
  199. +3*sin(5*omega*t)*(a1 *b3
  200. +2*a1*a3*b1
  201. +2*a1*a3*b3
  202. 2
  203. -a3 *b1
  204. 2
  205. -b1 *b3
  206. 2
  207. +b1*b3 )
  208. 2
  209. +sin(3*omega*t)*(3*a1 *b1
  210. 2
  211. +6*a1 *b3
  212. 2
  213. +3*a3 *b3
  214. 3
  215. -b1
  216. 2
  217. +6*b1 *b3
  218. 3
  219. +3*b3 ))/4
  220. remfac cos,sin;
  221. off list;
  222. comment end of Fourier analysis example;
  223. comment the following program, written in collaboration with David
  224. Barton and John Fitch, solves a problem in general relativity. it
  225. will compute the Einstein tensor from any given metric;
  226. on nero;
  227. comment here we introduce the covariant and contravariant metrics;
  228. operator p1,q1,x;
  229. array gg(3,3),h(3,3);
  230. gg(0,0):=e**(q1(x(1)))$
  231. gg(1,1):=-e**(p1(x(1)))$
  232. gg(2,2):=-x(1)**2$
  233. gg(3,3):=-x(1)**2*sin(x(2))**2$
  234. for i:=0:3 do h(i,i):=1/gg(i,i);
  235. comment generate Christoffel symbols and store in arrays cs1 and cs2;
  236. array cs1(3,3,3),cs2(3,3,3);
  237. for i:=0:3 do for j:=i:3 do
  238. <<for k:=0:3 do
  239. cs1(j,i,k) := cs1(i,j,k):=(df(gg(i,k),x(j))+df(gg(j,k),x(i))
  240. -df(gg(i,j),x(k)))/2;
  241. for k:=0:3 do cs2(j,i,k):= cs2(i,j,k) := for p := 0:3
  242. sum h(k,p)*cs1(i,j,p)>>;
  243. comment now compute the Riemann tensor and store in r(i,j,k,l);
  244. array r(3,3,3,3);
  245. for i:=0:3 do for j:=i+1:3 do for k:=i:3 do
  246. for l:=k+1:if k=i then j else 3 do
  247. <<r(j,i,l,k) := r(i,j,k,l) := for q := 0:3
  248. sum gg(i,q)*(df(cs2(k,j,q),x(l))-df(cs2(j,l,q),x(k))
  249. + for p:=0:3 sum (cs2(p,l,q)*cs2(k,j,p)
  250. -cs2(p,k,q)*cs2(l,j,p)));
  251. r(i,j,l,k) := -r(i,j,k,l);
  252. r(j,i,k,l) := -r(i,j,k,l);
  253. if i neq k or j>l
  254. then <<r(k,l,i,j) := r(l,k,j,i) := r(i,j,k,l);
  255. r(l,k,i,j) := -r(i,j,k,l);
  256. r(k,l,j,i) := -r(i,j,k,l)>>>>;
  257. comment now compute and print the Ricci tensor;
  258. array ricci(3,3);
  259. for i:=0:3 do for j:=0:3 do
  260. write ricci(j,i) := ricci(i,j) := for p := 0:3 sum for q := 0:3
  261. sum h(p,q)*r(q,i,p,j);
  262. q1(x(1))
  263. ricci(0,0) := ricci(0,0) := (e *(
  264. df(p1(x(1)),x(1))*df(q1(x(1)),x(1))*x(1)
  265. 2
  266. - 2*df(q1(x(1)),x(1),2)*x(1) - df(q1(x(1)),x(1)) *x(1)
  267. p1(x(1))
  268. - 4*df(q1(x(1)),x(1))))/(4*e *x(1))
  269. ricci(1,1) := ricci(1,1) := (
  270. - df(p1(x(1)),x(1))*df(q1(x(1)),x(1))*x(1) - 4*df(p1(x(1)),x(1))
  271. 2
  272. + 2*df(q1(x(1)),x(1),2)*x(1) + df(q1(x(1)),x(1)) *x(1))/(4*x(1))
  273. ricci(2,2) := ricci(2,2) := ( - df(p1(x(1)),x(1))*x(1)
  274. p1(x(1)) p1(x(1))
  275. + df(q1(x(1)),x(1))*x(1) - 2*e + 2)/(2*e )
  276. 2
  277. ricci(3,3) := ricci(3,3) := (sin(x(2)) *( - df(p1(x(1)),x(1))*x(1)
  278. p1(x(1)) p1(x(1))
  279. + df(q1(x(1)),x(1))*x(1) - 2*e + 2))/(2*e )
  280. comment now compute and print the Ricci scalar;
  281. rs := for i:= 0:3 sum for j:= 0:3 sum h(i,j)*ricci(i,j);
  282. 2
  283. rs := (df(p1(x(1)),x(1))*df(q1(x(1)),x(1))*x(1)
  284. 2
  285. + 4*df(p1(x(1)),x(1))*x(1) - 2*df(q1(x(1)),x(1),2)*x(1)
  286. 2 2
  287. - df(q1(x(1)),x(1)) *x(1) - 4*df(q1(x(1)),x(1))*x(1)
  288. p1(x(1)) p1(x(1)) 2
  289. + 4*e - 4)/(2*e *x(1) )
  290. comment finally compute and print the Einstein tensor;
  291. array einstein(3,3);
  292. for i:=0:3 do for j:=0:3 do
  293. write einstein(i,j):=ricci(i,j)-rs*gg(i,j)/2;
  294. einstein(0,0) :=
  295. q1(x(1)) p1(x(1))
  296. e *( - df(p1(x(1)),x(1))*x(1) - e + 1)
  297. -------------------------------------------------------
  298. p1(x(1)) 2
  299. e *x(1)
  300. p1(x(1))
  301. - df(q1(x(1)),x(1))*x(1) + e - 1
  302. einstein(1,1) := -------------------------------------------
  303. 2
  304. x(1)
  305. einstein(2,2) := (x(1)*(df(p1(x(1)),x(1))*df(q1(x(1)),x(1))*x(1)
  306. + 2*df(p1(x(1)),x(1))
  307. - 2*df(q1(x(1)),x(1),2)*x(1)
  308. 2
  309. - df(q1(x(1)),x(1)) *x(1)
  310. p1(x(1))
  311. - 2*df(q1(x(1)),x(1))))/(4*e )
  312. 2
  313. einstein(3,3) := (sin(x(2)) *x(1)*(
  314. df(p1(x(1)),x(1))*df(q1(x(1)),x(1))*x(1)
  315. + 2*df(p1(x(1)),x(1))
  316. - 2*df(q1(x(1)),x(1),2)*x(1)
  317. 2
  318. - df(q1(x(1)),x(1)) *x(1)
  319. p1(x(1))
  320. - 2*df(q1(x(1)),x(1))))/(4*e )
  321. comment end of Einstein tensor program;
  322. clear gg,h,cs1,cs2,r,ricci,einstein;
  323. comment an example using the matrix facility;
  324. matrix xx,yy,zz;
  325. let xx= mat((a11,a12),(a21,a22)),
  326. yy= mat((y1),(y2));
  327. 2*det xx - 3*w;
  328. 2*(a11*a22 - a12*a21 - 5443200)
  329. zz:= xx**(-1)*yy;
  330. [ - a12*y2 + a22*y1 ]
  331. [--------------------]
  332. [ a11*a22 - a12*a21 ]
  333. zz := [ ]
  334. [ a11*y2 - a21*y1 ]
  335. [------------------- ]
  336. [ a11*a22 - a12*a21 ]
  337. 1/xx**2;
  338. 2
  339. a12*a21 + a22
  340. mat((-------------------------------------------,
  341. 2 2 2 2
  342. a11 *a22 - 2*a11*a12*a21*a22 + a12 *a21
  343. - a12*(a11 + a22)
  344. -------------------------------------------),
  345. 2 2 2 2
  346. a11 *a22 - 2*a11*a12*a21*a22 + a12 *a21
  347. - a21*(a11 + a22)
  348. (-------------------------------------------,
  349. 2 2 2 2
  350. a11 *a22 - 2*a11*a12*a21*a22 + a12 *a21
  351. 2
  352. a11 + a12*a21
  353. -------------------------------------------))
  354. 2 2 2 2
  355. a11 *a22 - 2*a11*a12*a21*a22 + a12 *a21
  356. comment end of matrix examples;
  357. comment a physics example;
  358. on div;
  359. comment this gives us output in same form as Bjorken and Drell;
  360. mass ki= 0, kf= 0, p1= m, pf= m;
  361. vector ei,ef;
  362. mshell ki,kf,p1,pf;
  363. let p1.ei= 0, p1.ef= 0, p1.pf= m**2+ki.kf, p1.ki= m*k,p1.kf=
  364. m*kp, pf.ei= -kf.ei, pf.ef= ki.ef, pf.ki= m*kp, pf.kf=
  365. m*k, ki.ei= 0, ki.kf= m*(k-kp), kf.ef= 0, ei.ei= -1, ef.ef=
  366. -1;
  367. operator gp;
  368. for all p let gp(p)= g(l,p)+m;
  369. comment this is just to save us a lot of writing;
  370. gp(pf)*(g(l,ef,ei,ki)/(2*ki.p1) + g(l,ei,ef,kf)/(2*kf.p1))
  371. * gp(p1)*(g(l,ki,ei,ef)/(2*ki.p1) + g(l,kf,ef,ei)/(2*kf.p1))$
  372. write "The Compton cross-section is ",ws;
  373. 2 1 -1 1 -1
  374. The Compton cross-section is 2*ef.ei + ---*k*kp + ---*k *kp - 1
  375. 2 2
  376. comment end of first physics example;
  377. off div;
  378. comment another physics example;
  379. index ix,iy,iz;
  380. mass p1=mm,p2=mm,p3= mm,p4= mm,k1=0;
  381. mshell p1,p2,p3,p4,k1;
  382. vector qi,q2;
  383. factor mm,p1.p3;
  384. operator ga,gb;
  385. for all p let ga(p)=g(la,p)+mm, gb(p)= g(lb,p)+mm;
  386. ga(-p2)*g(la,ix)*ga(-p4)*g(la,iy)* (gb(p3)*g(lb,ix)*gb(qi)
  387. *g(lb,iz)*gb(p1)*g(lb,iy)*gb(q2)*g(lb,iz) + gb(p3)
  388. *g(lb,iz)*gb(q2)*g(lb,ix)*gb(p1)*g(lb,iz)*gb(qi)*g(lb,iy))$
  389. let qi=p1-k1, q2=p3+k1;
  390. comment it is usually faster to make such substitutions after all the
  391. trace algebra is done;
  392. write "CXN =",ws;
  393. 4 4 2 2
  394. CXN =32*mm *p1.p3 + 8*mm *(k1.p1 - k1.p3) - 16*mm *p1.p3
  395. 2
  396. + 16*mm *p1.p3*( - k1.p1 + k1.p3 - p2.p4)
  397. 2
  398. + 8*mm *( - k1.p1*p2.p4 - 2*k1.p2*k1.p4 + k1.p3*p2.p4) + 8
  399. *p1.p3*(k1.p2*p1.p4 - k1.p2*p3.p4 + k1.p4*p1.p2 - k1.p4*p2.p3
  400. + 2*p1.p2*p3.p4 + 2*p1.p4*p2.p3) + 8*(k1.p1*p1.p2*p3.p4
  401. + k1.p1*p1.p4*p2.p3 + 2*k1.p1*p2.p3*p3.p4
  402. - 2*k1.p3*p1.p2*p1.p4 - k1.p3*p1.p2*p3.p4
  403. - k1.p3*p1.p4*p2.p3)
  404. comment end of second physics example;
  405. showtime;
  406. Time: 3383 ms plus GC time: 50 ms
  407. end;
  408. (TIME: reduce 3400 3450)
  409. End of Lisp run after 3.41+0.69 seconds