leff%smu.csnet@csnet-relay (07/20/85)
Several of the notes I submitted recently did not reach the full news group. I am resubmitting these from rand-unix. If you didnot receive these before you might let me know. leff ==== ==== ==== ==== ==== ==== ==== Note 33 leff 9:10 pm Jun 8, 1985 Macsyma Questions 1) Is it possible to pass an array to a subroutine or function and have the function either alter the values of the array or return an array. For example, how would one write a subroutine to take an array and return the result of differentiating each element of it. Some things I tried: a:integrate(x1^2,x1); (c49) f(x):=BLOCK([temp],x[2]:3); (d49) f(x) := block([temp], x : 3) 2 (c50) array(zing,3); (d50) zing (c51) f(zing); (d51) 3 (c52) zing[2]; (d52) zing 2 (c53) f(x):=BLOCK([temp],x[2]::3); (d53) f(x) := block([temp], x :: 3) 2 (c54) f(zing); 3 improper value assignment Undefined function called from compiled code err 2) According to the Macsyma Manual, Section 15.1 (page 15-7), timer_info(f) prints information stored also as get('f,'calls),get('f,'runtime) and get('f,'gctime). However, the numbers I get when I try these things do not match: (c14) timer_info(f); (d14) [ function time/call calls runtime gctime ] [ ] [ f 0.01666666666666667 sec 1 0.01666666666666667 sec 0 ] [ ] [ total 0.01666666666666667 sec 1 0.01666666666666667 sec 0 ] (c15) get('f,'runtime); (d15) 1 What does this one come in (d15) have to do with the runtime numbers in the timer_info call? Macsyma Notes (primarily for beginning users) 1) There is an ODE function available that combines the features of ODE2 and DESOLVE plus a few more. However, it is not documented anywhere in the Macsyma manual. 2) Be careful of using constants of the form cnn and dnn. If a naive user copies a formula from a textbook using such constants, they are often confused with the formula labels used by Macsyma. 3) Note that Macsyma does case folding; the variable E is the same as e. I could find no statement to this effect in the Macsyma manual. This can also be confusing to naive users typing in math formulas from books. In math, these are often viewed as different. 4) A short note on the use of Macsyma with the typeset option under Unix 4.2BSD (that is using the typeset:true option). One neat trick is to include EQ defines in MACSYMA comments. This way you can take symbols like x sub 1, use a name that macsyma can understand like x1 and then have it print out as x with a 1 subscripted in the laser printer output. See below for an example. /* macsyma demonstration */ /* .EQ define x1 "x sub 1" .EN */ typeset:true; ==== ==== ==== ==== ==== ==== ==== Note 35 1 response leff 12:50 am Jun 16, 1985 More Macsyma Questions 1. I have been having problems with floating exceptions coming from RAT (when invoked by fullratsimp or by general polynomial simplification routines) even on such values as fullratsimp(1.0). Now it is apparent to me that something is getting clobbered inside this code. I took the rather large program that was giving me problems, inserted a save to dump the variables. I then loaded the values and issued the statement to continue execution and then it continued past the same point. I have not been isolate the problem as to what are the preconditions to cause RAT to misbehave like this but I would like to know if anyone has seen these symptoms before. 2. It appears that Macsyma does not know how to pass arrays as arguments to procedures. That is, if one passes an array name to a procedure it uses the global variable whose name is the same as the dummy parameter name. The following illustrates this problem. (c2) batch("/usr2/grad/leff/31.p"); (c3) Test(a):=BLOCK([temp], d:a[2]); (d3) test(a) := block([temp], d : a ) 2 (c4) array (a,3); (d4) a (c5) array (b,3); (d5) b (c6) a[2]:5; (d6) 5 (c7) b[2]:7; (d7) 7 (c8) Test(b); (d8) 5 (c9) display(d); d = 5 (d9) done (d10) BATCH DONE (c11) 3. When passing an array to a procedure, array_info does not work on the parameter inside the procedure. Well, I tried changing the name of my parameter so it did not correspond to any global names. Well I attempt to reference the parameter, I get the value corresponding to the argument. But now ARRAYINFO does not work. See the following example: (c10) batch("31.m"); (c11) Test(ax):=BLOCK([temp], d:ax[2],arrayinfo(ax)); (d11) test(ax) := block([temp], d : ax , arrayinfo(ax)) 2 (c12) array (a,3); (d12) a (c13) array (b,3); (d13) b (c14) a[2]:5; (d14) 5 (c15) b[2]:7; (d15) 7 (c16) Test(b); Not an array - ARRAYINFO: ax Undefined function called from compiled code err Error in batch fileUndefined function called from compiled code err (c17) 4. Macsyma (when loaded from EMACS) does not go away with emacs. Unipress Emacs #264 under VAX 4.2BSD I start a csh under Emacs in a process window. I start up macsyma under that shell. I then do a ^X^F to leave emacs. Emacs asks me if I want to kill my processes on the prowl. I type yes. I am out of emacs, but macsyma is still running using CPU time. It has to be killed manually. ==== ==== ==== Response 1 to Note 35 leff 9:58 pm Jun 16, 1985 Well I isolated the cause of the zerodivide and floating exceptions from fullratsimp that I complained about as question 1 in the base note. The problem is fullratsimp sometimes does not function properly when keepfloat is set to true. The following program reads in an expression to be fullratsimped. It barfs when keepfloat is true and will work when keepfloat is false. To save useless lines, I truncated the working output. % macsyma This is UNIX MACSYMA Release 304. (c) 1976,1983 Massachusetts Institute of Technology. All Rights Reserved. Enhancements (c) 1983, Symbolics, Inc. All Rights Reserved. Type describe(trade_secret); to see Trade Secret notice. (c1) batch("zing1"); (c2) testing: (0.5*p+1)*(2.552595426509751e-17*p^43-7.542068620194144e-15*p^42+9.022361062203114e-13*p^41-5.092591445473571e-11*p^40+7.62030606748932e-10*p^39+6.4188914568388e-08*p^38-3.256771986531714e-06*p^37+1.81707826487359e-06*p^36+0.003348751271024195*p^35-0.0512 6458806017258*p^34-1.961069112117538*p^33+49.92776066991307*p^32+835.6660731781534*p^31-28348.96365022052*p^30-317867.1713723205*p^29+11376097.32471373*p^28+122941909.0339667*p^27-3333129747.297105*p^26-45272173465.06486*p^25+661210759298.3234*p^24+135477 99660946.89*p^23-59283729269633.63*p^22-2865283880901595.0*p^21-9794493039930057.0*p^20+3.538014829589027e+17*p^19+4.067461531878026e+18*p^18-8.888777530037501e+18*p^17-5.100047147279584e+20*p^16-3.664347115194807e+21*p^15+9.713847941144256e+21*p^14+3.628 141152605675e+23*p^13+2.781707875714671e+24*p^12+5.836599548801854e+24*p^11-7.960557278128876e+25*p^10-9.795616824886904e+26*p^9-6.180953866287679e+27*p^8-2.68368954031736e+28*p^7-8.603625700470659e+28*p^6-2.075220592868845e+29*p^5-3.744076935627496e+29*p ^4-4.920257582823338e+29*p^3-4.458679675796763e+29*p^2-2.493783465969821e+29*p-6.488613877600273e+28)/(1.914446569882313e-17*p^43-5.969669837464137e-15*p^42+7.623996723003401e-13*p^41-4.736412612620711e-11*p^40+9.862077354736313e-10*p^39+4.908771085569499 e-08*p^38-3.279587514782085e-06*p^37+2.395369950777211e-05*p^36+0.003080601984989127*p^35-0.07161287407377953*p^34-1.581606473591411*p^33+64.11353610342029*p^32+540.9284552087644*p^31-36672.79247467464*p^30-166108.2843991688*p^29+15621570.03201456*p^28+71 751102.93250367*p^27-5146556474.920464*p^26-36888667764.38366*p^25+1260804998497.479*p^24+15121449677164.4*p^23-195607996235299.1*p^22-4259262591082211.0*p^21+5980547817777665.0*p^20+7.410810921367991e+17*p^19+5.038743904827382e+18*p^18-5.607717812507236e +19*p^17-1.101760616419929e+21*p^16-4.133903966524848e+21*p^15+6.711760161743657e+22*p^14+1.022410310947885e+24*p^13+5.197197752654535e+24*p^12-1.625721768610155e+25*p^11-4.896275958981356e+26*p^10-4.438410594908515e+27*p^9-2.60268651843989e+28*p^8-1.1150 64840903781e+29*p^7-3.624961001958235e+29*p^6-9.013958486002017e+29*p^5-1.696952458232618e+30*p^4-2.350619903853952e+30*p^3-2.266494167210921e+30*p^2-1.36164082220438e+30*p-3.844025949366557e+29)-(0.375*p+5)*(1.196529106176446e-18*p^45-2.728884048153081e- 16*p^44+2.065914037219976e-14*p^43-1.456417940301916e-13*p^42-5.854894537871396e-11*p^41+2.235661144489576e-09*p^40+5.824245170144037e-08*p^39-4.501719202642594e-06*p^38-1.695836742975403e-05*p^37+0.0051130 46839642523*p^36-0.01703308493071451*p^35-4.124629948460025*p^34+20.64915764070933*p^33+2598.867604689798*p^32-8573.922798292997*p^31-1313541.073055975*p^30-852478.6543264873*p^29+518470972.3144627*p^28+3112046971.830418*p^27-147242381494.3065*p^26-191663 1076434.444*p^25+24025869374153.18*p^24+646562150502858.7*p^23+443858239361239.0*p^22-1.205250793977344e+17*p^21-1.220515451282901e+18*p^20+6.916457455947288e+18*p^19+2.438468602768404e+20*p^18+1.678509069072556e+21*p^17-9.983956893044318e+21*p^16-2.84112 503867105e+23*p^15-2.276766245562404e+24*p^14-2.569423287101871e+24*p^13+1.38266170565549e+26*p^12+1.805368355268015e+27*p^11+1.36591381346464e+28*p^10+7.425072377117364e+28*p^9+3.085162159366603e+29*p^8+1.001537099094069e+30*p^7+2.549911531504875e+30*p^6 +5.048503339868016e+30*p^5+7.614427026744443e+30*p^4+8.43430284998738e+30*p^3+6.43925187886699e+30*p^2+3.003744647437293e+30*p+6.365757934616256e+29)/(2.692190488897003e-18*p^45-7.676930745228076e-16*p^44+8.530480366921539e-14*p^43-3.950823211308203e-12*p ^42-1.987001836478877e-11*p^41+9.417135193953047e-09*p^40-2.524578851705338e-07*p^39-7.702771415759992e-06*p^38+0.0004410463394236893*p^37+0.002080539514778283*p^36-0.4139466385007372*p^35+1.294619886731201*p^34+276.9536625617733*p^33-1525.791332132747*p^ 32-147358.7378934439*p^31+657057.407388298*p^30+64518179.35995869*p^29-64128617.48843752*p^28-22693278112.0056*p^27-89695713075.7423*p^26+5932255911107.199*p^25+60718186781214.54*p^24-954452545824197.6*p^23-2.002142008556578e+16*p^22+2.016001812134834e+16 *p^21+3.637141152573789e+18*p^20+2.953646377268436e+19*p^19-2.392559070323894e+20*p^18-6.114862009994101e+21*p^17-3.36077425575144e+22*p^16+2.921198568793123e+23*p^15+6.242834640457527e+24*p^14+4.27635781090436e+25*p^13+1.114968203072442e+23*p^12-2.866685 416679557e+27*p^11-3.254475754491642e+28*p^10-2.242416086394182e+29*p^9-1.119796959038928e+30*p^8-4.273781269203194e+30*p^7-1.268127087658531e+31*p^6-2.922902385735682e+31*p^5-5.155736183753181e+31*p^4-6.745633146401225e+31*p^3-6.182256387845242e+31*p^2-3 .548253028612195e+31*p-9.610064873416392e+30); 43 42 (d2) (0.5 p + 1) (2.552595426509751e-17 p - 7.542068620194144e-15 p 41 40 + 9.022361062203114e-13 p - 5.092591445473571e-11 p 39 38 + 7.62030606748932e-10 p + 6.4188914568388e-08 p 37 36 - 3.256771986531714e-06 p + 1.81707826487359e-06 p 35 34 33 + 0.003348751271024195 p - 0.05126458806017258 p - 1.961069112117538 p 32 31 30 + 49.92776066991307 p + 835.6660731781534 p - 28348.96365022052 p 29 28 27 - 317867.1713723205 p + 11376097.32471373 p + 122941909.0339667 p 26 25 24 - 3333129747.297105 p - 45272173465.06486 p + 661210759298.3234 p 23 22 21 + 13547799660946.89 p - 59283729269633.63 p - 2865283880901595.0 p 20 19 - 9794493039930057.0 p + 3.538014829589027e+17 p 18 17 + 4.067461531878026e+18 p - 8.888777530037501e+18 p 16 15 - 5.100047147279584e+20 p - 3.664347115194807e+21 p 14 13 + 9.713847941144256e+21 p + 3.628141152605675e+23 p 12 11 + 2.781707875714671e+24 p + 5.836599548801854e+24 p 10 9 - 7.960557278128876e+25 p - 9.795616824886904e+26 p 8 7 - 6.180953866287679e+27 p - 2.68368954031736e+28 p 6 5 - 8.603625700470659e+28 p - 2.075220592868845e+29 p 4 3 - 3.744076935627496e+29 p - 4.920257582823338e+29 p 2 - 4.458679675796763e+29 p - 2.493783465969821e+29 p - 6.488613877600273e+28) 43 42 /(1.914446569882313e-17 p - 5.969669837464137e-15 p 41 40 + 7.623996723003401e-13 p - 4.736412612620711e-11 p 39 38 + 9.862077354736313e-10 p + 4.908771085569499e-08 p 37 36 - 3.279587514782085e-06 p + 2.395369950777211e-05 p 35 34 33 + 0.003080601984989127 p - 0.07161287407377953 p - 1.581606473591411 p 32 31 30 + 64.11353610342029 p + 540.9284552087644 p - 36672.79247467464 p 29 28 27 - 166108.2843991688 p + 15621570.03201456 p + 71751102.93250367 p 26 25 24 - 5146556474.920464 p - 36888667764.38366 p + 1260804998497.479 p 23 22 21 + 15121449677164.4 p - 195607996235299.1 p - 4259262591082211.0 p 20 19 + 5980547817777665.0 p + 7.410810921367991e+17 p 18 17 + 5.038743904827382e+18 p - 5.607717812507236e+19 p 16 15 - 1.101760616419929e+21 p - 4.133903966524848e+21 p 14 13 + 6.711760161743657e+22 p + 1.022410310947885e+24 p 12 11 + 5.197197752654535e+24 p - 1.625721768610155e+25 p 10 9 - 4.896275958981356e+26 p - 4.438410594908515e+27 p 8 7 - 2.60268651843989e+28 p - 1.115064840903781e+29 p 6 5 - 3.624961001958235e+29 p - 9.013958486002017e+29 p 4 3 - 1.696952458232618e+30 p - 2.350619903853952e+30 p 2 - 2.266494167210921e+30 p - 1.36164082220438e+30 p - 3.844025949366557e+29) 45 44 - (0.375 p + 5) (1.196529106176446e-18 p - 2.728884048153081e-16 p 43 42 + 2.065914037219976e-14 p - 1.456417940301916e-13 p 41 40 - 5.854894537871396e-11 p + 2.235661144489576e-09 p 39 38 + 5.824245170144037e-08 p - 4.501719202642594e-06 p 37 36 - 1.695836742975403e-05 p + 0.005113046839642523 p 35 34 33 - 0.01703308493071451 p - 4.124629948460025 p + 20.64915764070933 p 32 31 30 + 2598.867604689798 p - 8573.922798292997 p - 1313541.073055975 p 29 28 27 - 852478.6543264873 p + 518470972.3144627 p + 3112046971.830418 p 26 25 24 - 147242381494.3065 p - 1916631076434.444 p + 24025869374153.18 p 23 22 21 + 646562150502858.7 p + 443858239361239.0 p - 1.205250793977344e+17 p 20 19 - 1.220515451282901e+18 p + 6.916457455947288e+18 p 18 17 + 2.438468602768404e+20 p + 1.678509069072556e+21 p 16 15 - 9.983956893044318e+21 p - 2.84112503867105e+23 p 14 13 - 2.276766245562404e+24 p - 2.569423287101871e+24 p 12 11 + 1.38266170565549e+26 p + 1.805368355268015e+27 p 10 9 + 1.36591381346464e+28 p + 7.425072377117364e+28 p 8 7 + 3.085162159366603e+29 p + 1.001537099094069e+30 p 6 5 + 2.549911531504875e+30 p + 5.048503339868016e+30 p 4 3 2 + 7.614427026744443e+30 p + 8.43430284998738e+30 p + 6.43925187886699e+30 p + 3.003744647437293e+30 p + 6.365757934616256e+29) 45 44 /(2.692190488897003e-18 p - 7.676930745228076e-16 p 43 42 + 8.530480366921539e-14 p - 3.950823211308203e-12 p 41 40 - 1.987001836478877e-11 p + 9.417135193953047e-09 p 39 38 - 2.524578851705338e-07 p - 7.702771415759992e-06 p 37 36 + 0.0004410463394236893 p + 0.002080539514778283 p 35 34 33 - 0.4139466385007372 p + 1.294619886731201 p + 276.9536625617733 p 32 31 30 - 1525.791332132747 p - 147358.7378934439 p + 657057.407388298 p 29 28 27 + 64518179.35995869 p - 64128617.48843752 p - 22693278112.0056 p 26 25 24 - 89695713075.7423 p + 5932255911107.199 p + 60718186781214.54 p 23 22 - 954452545824197.6 p - 2.002142008556578e+16 p 21 20 + 2.016001812134834e+16 p + 3.637141152573789e+18 p 19 18 + 2.953646377268436e+19 p - 2.392559070323894e+20 p 17 16 - 6.114862009994101e+21 p - 3.36077425575144e+22 p 15 14 + 2.921198568793123e+23 p + 6.242834640457527e+24 p 13 12 + 4.27635781090436e+25 p + 1.114968203072442e+23 p 11 10 - 2.866685416679557e+27 p - 3.254475754491642e+28 p 9 8 - 2.242416086394182e+29 p - 1.119796959038928e+30 p 7 6 - 4.273781269203194e+30 p - 1.268127087658531e+31 p 5 4 - 2.922902385735682e+31 p - 5.155736183753181e+31 p 3 2 - 6.745633146401225e+31 p - 6.182256387845242e+31 p - 3.548253028612195e+31 p - 9.610064873416392e+30) (c3) ; (d3) BATCH DONE (c4) keepfloat:true; (d4) true (c5) fullratsimp(testing); Floating Exception Undefined function called from compiled code err (c6) keepfloat:false; (d6) false (c7) fullratsimp(testing); RAT replaced 0.5 by 1/2 = 0.5 RAT replaced -3.844025949366557e+29 by -384402594936655688805400969216/1 = -3.844025949366557e+29 RAT replaced -1.36164082220438e+30 by -1361640822204379948998469877760/1 = -1.36164082220438e+30 RAT replaced -2.266494167210921e+30 by -2266494167210920905679992520704/1 = -2.266494167210921e+30 RAT replaced -2.350619903853952e+30 by -2350619903853951935954458509312/1 = -2.350619903853952e+30 RAT replaced -1.696952458232618e+30 by -1696952458232617945292920061952/1 = -1.696952458232618e+30 RAT replaced -9.013958486002017e+29 by -901395848600201679540745928704/1 = -9.013958486002017e+29 RAT replaced -3.624961001958235e+29 by -362496100195823491674135330816/1 = -3.624961001958235e+29 RAT replaced -1.115064840903781e+29 by -111506484090378098567909736448/1 = -1.115064840903781e+29 RAT replaced -2.60268651843989e+28 by -26026865184398899486929190912/1 = -2.60268651843989e+28 RAT replaced -4.438410594908515e+27 by Interrupt (h for help):r [Return to top level] (c8) ==== ==== ==== ==== ==== ==== ==== Note 36 leff 6:55 pm Jun 19, 1985 The new officers of Sigsam: Chairman: David Y. Y. Yun Vice-Chairman James Davenport Secretary Eric Kaltofen Treasurer Dennis Arnon ==== ==== ==== ==== ==== ==== ==== Note 37 leff 7:05 pm Jun 19, 1985 I just received the announcement for this new book: Applications of Computer Algebra Edited by Richard Pavelle 446 Pages $59.95 Kluwer Academic Publishers This is based on the symposium of the American Chemical Society's Division of Computers in Chemistry entitled "Symbolic Algebraic Manipulation in Scientific Computation" I. Macsyma: Capabilities and Applications to Problems in Engineering and the Sciences - Richard Pavelle II. Modern Symbolic Mathematical Compuation Systems - Paul S. Wang III. Using Vaxima to write FORTRAN code - Stanly Steinberg IV. Applications of Symbolic Mathematics to Mathematics Andrew M. Odlyzko V. Past, Present and Future Applications of Computer Algebra in Chemistry T. E. Raidy VI. Symbolic Computation in Chemical Education - Don McLaughlin VII. A Lisp System for Chemical Groups: Wigner - Eckart Coefficients for Arbitrary Permutation Groups - Carl Trindle VIII. Polymer Modeling Applications of Symbolic Computation John T. Bendler & Michael F. Shlesinger IX. Stability Analysis and Optimal Control of a Photochemical Heat Engine Stanley J. Watowitch, Jeffrey L. Krause, R. Stephen Berry X. Fourier Transform Algorithms for Spectral Analysis Derived with Macsyma Robert H. Berman XI. Computer Algebra as a tool for solving optimal control problems C. Gomez, J. P. Quadrat, A. Sulem XII. Application to Macsyma to kinematics and mechanical systems M. A. Hussain B. Noble XIII. Stability Analysis of a Robotic Mechanism Using Computer Algebra M. Golnaraghi, W. Keith, F. C. Moon XIV Derivation of the Hopf Bifurcation Formula using Lindstedt's Perturbation Method and Macsyma - Richard H. Rand XV Normal Form and Center Manifold Calculations on Macsyma R. H. Rand & W. L. Keith XVI. Symbolic Compuation of the Stokes Wave - W. H. Hui, G. Tenti XVII. Simplifying Large Algebraic Expressions by Computer Richard L. Brenner XVIII. A Proposal for the Solution of Quantum Field Theory Problems using A Finite-Element Approximation - Carl M. Bender XIX. Exact Solutions for Superlattices and how to Recognize them with Computer Algebra Gene Cooperman, Lionel Friendman, Walter Bloss XX. Computer Generation of Symbolic Generalized Inverses and Applications to Physics and Data Analysis W. J. Frawley