Algebraic Operation System (AOS)
|
04-24-2022, 11:18 PM
Post: #20
|
|||
|
|||
RE: Algebraic Operation System (AOS)
(04-20-2022 07:07 AM)Chr Yoko Wrote: No issue calculating the Mach number in manual mode onto a DM41X or HP41C. Mach Formula I used this Python to RPN converter to translate the following function: Code: def mach(): But alas it gave me an error: Potential RPN stack overflow detected - expression too complex for 4 level stack - simplify! [5, 1, 0.2, 350, 661.5], line: 4 return SQRT( 5 * ( ( ( ( ( 1 + .2 * ( 350 / 661.5 ) ** 2 ) ** 3.5 - 1 ) * ( 1 - 6.875E-6 * 25500 ) ** -5.2656 ) + 1 ) ** .286 - 1 ) ) The fix was easy. I just had to move the multiplication by 5 to the end: Code: def mach(): This is the generated program for the HP-42S: Code: 00 { 75-Byte Prgm } It leads to: 0.835724535175 Monster Formula Again the naïve approach fails with: Potential RPN stack overflow detected - expression too complex for 4 level stack - simplify! ['_result_', 6, 7, 2, 3], line: 4 return 1 - 2 * 3 ** 4 / 5 + SIN( 6 - 7 ** (2 / 3 ) ) * FACT(8) + LN( ( - 9 ** 2 ** 3 * 45 ** ( 6 / 7 ) ) ** 2 ) We have to rearrange the terms a bit: Code: def monster(): This generated the following program for the HP-42S: Code: 00 { 58-Byte Prgm } It leads to: 1657.00894809 In both cases, the expression had to be slightly modified due to the 4-level stack constraint. Most of us probably do this intuitively, or rather work from the inside out. So stack overflow is not really a problem. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)