paul+@andrew.cmu.edu (Paul J. Dujmich) (06/29/90)
I would like to build an algebraic expression from within a program. What I want to do is something like: Pull 2 from the stack, then pull 3 from the stack and make '2*S^3' , so then I could take the derrivative of it. The manual talks about "building" a string object, piece by piece, but how do you build an algebraic object from within a program? Paul
edp@vmsdev.enet.dec.com (Eric Postpischil (Always mount a scratch monkey.)) (06/29/90)
> I would like to build an algebraic expression from within a program. > What I want to do is something like: > Pull 2 from the stack, then pull 3 from the stack and make '2*S^3' , > so then I could take the derivative of it. If two algebraic objects (including simple numbers and names) are on the stack (call them a and b), you can form the algebraic a*S^b with the following: << "*S^" SWAP + + "'" SWAP + OBJ-> >> or with: << 'S' SWAP ^ * >> The former is longer, but does not do some of the evaluations you get in the latter case. E.g., if a is 0, the latter program will return 0, but the former will return 0*S^b. -- edp
herman@corpane.UUCP (Harry Herman) (07/02/90)
In article <QaWnlIy00WBKM0gUw-@andrew.cmu.edu> paul+@andrew.cmu.edu (Paul J. Dujmich) writes: >I would like to build an algebraic expression from within a program. >What I want to do is something like: >Pull 2 from the stack, then pull 3 from the stack and make '2*S^3' , >so then I could take the derrivative of it. The manual talks about "building" >a string object, piece by piece, but how do you build an algebraic object >from within a program? >Paul In your example above, assuming S is undefined, typing in: 2 ENTER S ENTER 3 yx * (where yx is the y-to-the-x-power key on the 4th row, next to the 1/x key) gave me '2*S^3' as an algebraic. Once an variable name is used, the stack argument is automatically changed to algebraic, and all further operations on it are done in algebraic mode, allowing you to "build" an algebraic. You can then save it in a variable, or leave it on the stack, store a value for S and then EVAL or ->NUM it, or do whatever you want with it, (including taking the derivative, as in your example).