RPN2 - Reverse Polish Evaluator ----begin documentation---- Well, after reading through some old TI list mail, I found a nice one about reverse polish notation. Having done a Pascal program to do this, I thought why not do one for the '85...so I did...and here it is...version 2. Chris Johnson. Email: cjohnso0@pine.shu.ac.uk <--- This one preferred ;-) xuubx@csv.warwick.ac.uk WWW: http://www.warwick.ac.uk/~xuubx/ TI Page: http://www.warwick.ac.uk/~xuubx/ti.html Oh, and by the way, it's edit-locked. I'd also like to point out the following. Throughout this 'manual', the following apply: RPN means Reverse Polish Notation - It does NOT mean the program RPN2 is the program !! About Reverse Polish Notation (RPN) ----------------------------------- RPN is an alternative way to denote mathematical expressions, which sets them in an order that compters etc... find easy to evaluate. RPN is stack based. This means that all values in an expression will be pushed on and off a stack. This includes any answers. The easiest way to explain is an example. So here it is: RPN expression: 2 4 * 9 3 / + Is evaluated as follows (the ^ indicates what stage of the operation that we're at): STAGE FORMULA STACK 0 2 4 * 9 3 / + | | | | +---+ 1 2 4 * 9 3 / + | | ^ | 2 | +---+ 2 2 4 * 9 3 / + | 4 | ^ | 2 | +---+ 3 2 4 * 9 3 / + | | ^ | 8 | +---+ 4 2 4 * 9 3 / + | 9 | ^ | 8 | +---+ 3 5 2 4 * 9 3 / + | 9 | ^ | 8 | +---+ 6 2 4 * 9 3 / + | 3 | ^ | 8 | +---+ 7 2 4 * 9 3 / + | | ^ | 11| +---+ OKay...got the idea? 2 4 * 9 3 / + represents 2*4 + 9/C Similarly, 4 7 + represents 4+7 And more complex examples: 10 \sqrt\ sin 4 * 3 (-) e^ * 7 log 0.5 / cos 6 * 7 e^ * + goes to: -3sin(\sqrt\ 10) 7cos(log 7/0.5) 4e^ + 6e^ And: 1 / pi sin^-1 4 7 sin * + 4 3 ln + \sqrt\ * e^ 3 8 \x-root\ + goes to: (4 sin 7 + sin^-1 (1/pi))*\sqrt\(4+ln 3) e^ + 3\x-root\8 (phew!) Notes: \sqrt\ square root (-) negate (the one next to ENTER) pi pi (suprisingly enough) sin^-1 arcsine ([2nd] [sin]) \x-root\ xth root ([2nd] [math] [misc] [more] [F4]) ========================================================================= How to use the program ---------------------- Right, now that's out of the way, all about how to use it. The main menu gives four options - Help, Go, About, Quit Help - Help!!! (quick reminder) Go - Enter the RPN editor About - About the program Quit - Err...I'll let you work this one out ;-) Once in the editor, type the RPN expression in in any of the following ways (taking 2 4 * 9 3 / + as the example): Bit at a time: :2 :4 :* etc... All at once: :2,4,*,9,3,/,+ A bit of both: :2,4,* :9,3,/ :+ To get the answer (current top of stack) enter an equals :2,4,*,9,3,/,+ := Current: 11 or :2,4,*,9,3,/,+,= Current: 11 Note each bit has to be seperated be a comma. Special commands in the editor ------------------------------ The editor has several special commands (well three actually, several sounds better though ;-) Command Keys Action = Equals Show top of stack (result of last operation, or last entered number). . decimal Show the answer (top of stack) and quit. Has to be ONLY point character on the line. :: Two colons Clear the stack. 'Cleared' will show on the display. System resources ---------------- RPN2 takes up 3812 bytes (well when I checked mine) All variables start with rpn, so there's rpnI, rpnBIT, rpnENT etc... Variables you might want to know about... rpnLIST - (Vector) The stack rpnENT - (String) What you entered last x - (Real/complex) The final answer (set when '.' entered) All together variables take about 500/600 bytes. (Size of rpnLIST will vary). Limitations ----------- This cannot cope with Matrices, Vectors or Lists. Only real or complex numbers, equations, variables. Also any functions that require braketed arguments (eg. pEval(, max(, min( etc...) cannot be used. Other functions that I know can't be used: All functions to do with vectors/matrices etc... The 'bit' functions (rotL, rotR, shftR, shftL) Anything with parathensis is classed as a single number. RPN does not cater for parathensis. The only numbers that have parathensis in on the '85 would be complex numbers. eg. (4,3) etc... . You could enter (4+3) if you wanted. This would evaluate to 7, but entering 4+3 will cause an error. (To get round this could put 4+3 into an equation; eg. A=4+3, and use that). As far as I know, RPN does not know about implied multiplication. (If you don't know what that is, read pages 1-8 and 1-9 of the manual!). Hmm...what else...errr...nope. I think that's it. Any problems, queries, mail me at cjohnso0@pine.shu.ac.uk ----end documentation---- ----begin ascii---- ----end ascii---- ----start uue---- begin 644 rpn2.85p M*BI423@U*BH:#`!5;F=R;W5P960@9G)O;2!R<&XR+C@U9P`````````````` M``````````#7#@@`RPX2!%)03C++#LD.X')P;DU!24X`;^QOZ2U24$X@179A M;'5A=&]R`&_I+4,N2F]H;G-O;B`Q.3DU`&],$$0Q`"\M2&5L<``O.7)P;DA% M3%`O1#(`+RU';P`O-W)P;D=/+T0T`"\M06)O=70`+SIR<&Y!0D]55"]$-0`O M+5%U:70`+SER<&Y%6$E4$6_L;^!R<&Y(14Q0`&\M2&5L<"!M92`A(2$`;^QO MZ2U%;G1E;RTL`&`X;S9R<&Y)840Q``LV;QT0.')P;D5.5"\V;^$``')P;D-03`!O+5)I9VAT+BXN;&5T)W,@<')O8V5S;]YOX')P;D]0`&\M M2!O;^X0-W)P;D53+S9R<&Y%$6\V;^-OX')P;D58250`;^QOXV]O;__$UP`` ` end ----end uue----