Algebraic Operation System (AOS)
|
04-17-2022, 12:57 AM
(This post was last modified: 04-18-2022 10:54 AM by Thomas Klemm.)
Post: #1
|
|||
|
|||
Algebraic Operation System (AOS)
Description
This program allows you to use the Algebraic Operation System (AOS) similar to how old Texas Instruments calculators work. The shunting yard algorithm is used with a data and an operator stack. Their stack size is configurable and is only limited by the amount of memory available. Functions The functions just operate on the X register in postfix notation. This is how the TI-57 and other older calculators from Texas Instruments work. For example, to calculate \( \sqrt{3^2 + 4^2} \) use: 3 x^2 + 4 x^2 = √x Alternatively we can use: ( 3 x^2 + 4 x^2 ) √x However, this requires one more keystroke. Apparently we use a mixture of infix notation for arithmetic operations and postfix notation for functions. Change Sign It behaves similarly to an ordinary function. E.g. an expression like \( - 3^4 \) has to be keyed in like: 3 y^x 4 = +/- Or alternatively: ( 3 y^x 4 ) +/- Intermediate Results The intermediate results of a calculation are viewed and may also be printed. Example \( \frac{1 \times 2 + 3 \times 4 + 5 \times 6 + 7 \times 8}{4} \) ( 1 * 2 + 3 * 4 + 5 * 6 + 7 * 8 ) / 4 = Code: ST X= 2 Implicit Data Entry The current value in the X register is used as data entry. This allows to reuse the first entry: 3 + = This results in \( 3 + 3 = 6 \). 3 * * = This results in \( 3^4 = 81 \). The Monster Formula The formula is from A case against the x<>y key: \( 1 - 2 \times 3^4 \div 5 + \sin\left(6 - \sqrt[3]{7^2} \right) \times 8! + \ln \left[ \left(-9^{2^3} \times 45 ^ \frac{6}{7} \right)^2 \right] \) Here's how it is entered with this program. 1 - 2 * 3 ^ 4 / 5 + ( 6 - 7 X^2 ^ 3 1/X ) SIN * 8 FACT + ( 9 ^ 2 ^ 3 * 45 ^ ( 6 / 7 ) ) CHS X^2 LN = 1657.008948 Intermediate Results Code: ST X= 81 Registers This is a list of the registers after the calculation: Code: 00: 5 Mark Hardman’s solution (05-10-2015 03:12 PM)Mark Hardman Wrote: TI-57 These are the key strokes for the TI-57: 1 - 2 × 3 y^x 4 ÷ 5 + ( 6 - 7 x^2 INV y^x 3 ) 2nd sin * 40320 + ( 9 y^x ( 2 y^x 3 ) × 45 ^ ( 6 ÷ 7 ) ) +/- x^2 lnx = We get the same result: 1657.0089 For this I used the TI-57 Programmable Calculator. However I had to cheat a little: since the factorial function is missing I just replaced \( 8! \) with \( 40320 \). Also since the \( y^x \) operation apparently is not right associative I used another pair of parenthesis to calculate: \( 9 ^ {2 ^ 3} = 9 ^ {(2 ^ 3)} \) Program This is the program for the HP-41C: Code: 01▸LBL "AOS" Key Assignments Of course you are free to choose differently buy I recommend the following key assignments: Code: | Label | Key | Code Registers The program needs 3 register to control the data and the operator stack: Code: | Register | Comment Synthetic Programming We could use the alpha registers M, N and O instead of register 00-02. With this the data stack could be started at register 00. For now I'm leaving that as an exercise for the dear reader. Operators The decimal part of the code is used as precedence. A negative code means left associativity. The code for the left parenthesis ( is 0. Thus we already have an implicit open parenthesis. This makes handling the right parenthesis ) and = similar. Code: | Operator | Label | Code | Precedence | Associativity Code Walkthrough Initialisation The registers and the stack is cleared with: XEQ AOS Here you can configure the start of the data and the operator stack. Be warned that there are no checks in the program. Thus the data stack could grow into the operator stack and vice versa. It's up to you to select reasonable values. Code: LBL "AOS" Enter Operator Each operator pushes a specific code onto the stack in which label, precedence and associativity is encoded. Code: LBL "+" New operator Each time we reach a new operator, we pop operators from the stack until we reach one that has lower precedence. In the case of a right associative operator, we also stop if we reach an operator of the same precedence. Code: | X | Y | Decision There's no lower precedence than -0.2, thus + and - always pop. On the other hand, ^ never pops previous operators. This leaves us with * and / which pop unless an operator on the stack has lower precedence like + or -. Stack diagram: ( x op -- x' ) Code: LBL 00 ; add new operator Push Operator The left parenthesis ( is just pushed onto the operator stack. The RTN command after ISG is used as a no-operation which is always skipped. Code: LBL "(" Right Parentheses and Equals Code: while the operator at the top of the operator stack is not a left parenthesis: Code: LBL ")" The = operator does not pop the implicit left parenthesis. But otherwise it behaves like the right parenthesis and removes any leftover operators from the operator stack. Pop Operator Stack diagram: ( a x op -- a a op x' ) Code: LBL 06 ; pop operator Implementation This is just the implementation of the operators: Code: LBL 01 ; + HP-42S The program also works with the HP-42S. However, we can assign the programs only to a custom menu. I'm using the following layout: Code: X^2 | SQRT | 10^X | LOG | E^X | LN Code: 00 { 186-Byte Prgm } References |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)