Conversion: Algebraic - Polish - Reverse Polish - LISP ?
|
11-01-2024, 12:34 PM
Post: #2
|
|||
|
|||
RE: Conversion: Algebraic - Polish - Reverse Polish - LISP ?
(11-01-2024 09:52 AM)Martin Hepperle Wrote: Something written in RPL for the HP 4x family of calculators would be an option On the HP-48 you can run the TEACH command, which creates an EXAMPLES directory. In the PRGS subdirectory you will find the following program →RPN: Code: « OBJ→ The algebraic expression 'x*(1+x*(1-x))*SIN(x)' is converted into an RPN program: { x 1 x 1 x - * + * x SIN * } Using REVLIST we can reverse the list: { * SIN x * + * - x 1 x 1 x } Now we need to insert the missing parentheses: { * {SIN x} {* {+ {* {- x 1} x} 1} x} } Let's swap the arguments of the binary operators: {* {* x {+ 1 {* x {- 1 x}}}} {SIN x}} Compare it with: (* (* x (+ 1 (* x (- 1 x)))) (SIN x)) Maybe you can modify the program to do that automatically for you. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)