Code Analyzer for HP Calculators
|
04-11-2022, 06:08 PM
Post: #3
|
|||
|
|||
RE: Code Analyzer for HP Calculators
(04-11-2022 09:56 AM)Namir Wrote: Your Python code is elegant. Well I must admit that I cobbled that together in a Jupyter notebook. And that's probably the best environment to run it. The state of the calculator is stored in these global variables, which I usually avoid. So I had to declare them global in each of the functions. But that along with the trace decorator makes them short and hopefully easy to understand. (04-10-2022 07:25 PM)Thomas Klemm Wrote: I haven't tried this yet, but we could import the functions from the cmath library. If we want to analyze complex values we import the cmath library: Code: from cmath import ( The trace function needs minor adjustments: Code: print(( And now we can also solve a quadratic equation with complex solutions: Code: a, b, c = 1, 1, 1 X: 1.000000e+00 Y: 1.000000e+00 Z: 1.000000e+00 T: 1.000000e+00 L: 0.000000e+00 : DUP X: 1.000000e+00 Y: 1.000000e+00 Z: 1.000000e+00 T: 1.000000e+00 L: 0.000000e+00 : RUP X: 1.000000e+00 Y: 1.000000e+00 Z: 1.000000e+00 T: 1.000000e+00 L: 1.000000e+00 : DIV X: 1.000000e+00 Y: 1.000000e+00 Z: 1.000000e+00 T: 1.000000e+00 L: 1.000000e+00 : RUP X: 1.000000e+00 Y: 1.000000e+00 Z: 1.000000e+00 T: 1.000000e+00 L: 1.000000e+00 : LASTX X: 1.000000e+00 Y: 1.000000e+00 Z: 1.000000e+00 T: 1.000000e+00 L: 1.000000e+00 : DIV X: -2.000000e+00 Y: 1.000000e+00 Z: 1.000000e+00 T: 1.000000e+00 L: 1.000000e+00 : number -2 X: -5.000000e-01 Y: 1.000000e+00 Z: 1.000000e+00 T: 1.000000e+00 L: -2.000000e+00 : DIV X: -5.000000e-01 Y: -5.000000e-01 Z: 1.000000e+00 T: 1.000000e+00 L: -2.000000e+00 : DUP X: -5.000000e-01 Y: -5.000000e-01 Z: -5.000000e-01 T: 1.000000e+00 L: -2.000000e+00 : DUP X: 2.500000e-01 Y: -5.000000e-01 Z: -5.000000e-01 T: 1.000000e+00 L: -5.000000e-01 : XT2 X: 1.000000e+00 Y: 2.500000e-01 Z: -5.000000e-01 T: -5.000000e-01 L: -5.000000e-01 : RUP X: -7.500000e-01 Y: -5.000000e-01 Z: -5.000000e-01 T: -5.000000e-01 L: 1.000000e+00 : SUB X: 0.000000e+00+8.660254e-01j Y: -5.000000e-01 Z: -5.000000e-01 T: -5.000000e-01 L: -7.500000e-01 : SQRT X: -5.000000e-01-8.660254e-01j Y: -5.000000e-01 Z: -5.000000e-01 T: -5.000000e-01 L: 0.000000e+00+8.660254e-01j : SUB X: -5.000000e-01 Y: -5.000000e-01-8.660254e-01j Z: -5.000000e-01 T: -5.000000e-01 L: 0.000000e+00+8.660254e-01j : SWAP X: 0.000000e+00+8.660254e-01j Y: -5.000000e-01 Z: -5.000000e-01-8.660254e-01j T: -5.000000e-01 L: 0.000000e+00+8.660254e-01j : LASTX X: -5.000000e-01+8.660254e-01j Y: -5.000000e-01-8.660254e-01j Z: -5.000000e-01 T: -5.000000e-01 L: 0.000000e+00+8.660254e-01j : ADD |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Code Analyzer for HP Calculators - Thomas Klemm - 04-10-2022, 07:25 PM
RE: Code Analyzer for HP Calculators - Namir - 04-11-2022, 09:56 AM
RE: Code Analyzer for HP Calculators - Thomas Klemm - 04-11-2022 06:08 PM
RE: Code Analyzer for HP Calculators - Sylvain Cote - 04-11-2022, 10:44 PM
RE: Code Analyzer for HP Calculators - Thomas Klemm - 04-12-2022, 11:27 PM
|
User(s) browsing this thread: 2 Guest(s)