This program enables interactive chained calculations using complex numbers. The key operation order used is similar to the calculator's normal operation in that functions of 1 number (uniary functions) come after the number in question and functions of 2 numbers (binary functions) are requested between the 2 numbers. However there are differences between the operations and standard number calculations. The primary difference is that there is no automatic precedence so to properly calculate z1+z2×z3 you have to explictly enter z1+(z2×z3). There is also no expicit '=' operation because this is assumed after the EXE of entering the complex part of the last argument. Because there is no precedent taken into account, the next function to be applied does not have to be considered by the program before performing the calculation.Complex numbers are always entered and returned in rectangular form separated by EXE but the use of P->R (for input) and R->P (for output) is possible because there are no calculations performed between accepting or returning the real and imaginary parts. When inputting values it is compulsory to enter both real and imaginary parts but defaults of 0 are set for both and can be accepted by just hitting EXE. There is never any need to hit EXE to view the returned imaginary part of a calculation if the value is of no interest (for instance when the answer is to be used as part of a chained calculation).
The program numbers have the following functions:
P0 | All Clear and enter 1^{st} complex number (Mnemonic - like E0 the standard AC button) |
P1 | Multiply '×' (Mnemonic - like E1 the standard × button) |
P2 | Divide '÷' (Mnemonic - like E2 the standard ÷ button) |
P3 | Add '+' (Mnemonic - like E3 the standard + button) |
P4 | Subtract '-' (Mnemonic - like E4 the standard - button) |
P5 | Open bracket '(' |
P6 | Close bracket and perform pending function ')=' |
P7 | Power '^' |
P8 | Reciprocal '1/z' (Mnemonic - like C8 the button which is inverted for the standard 1/x function) |
P9 | Not user callable processing unit |
There are extra functions obtainable by pressing an integer before P1. All of these functions do not require another complex number to be entered. These functions are:
1 P1 | K constant multiply '×' by reusing the last used 2nd complex number (stored in M5 & M6) |
2 P1 | K constant divide '÷' by reusing the last used 2nd complex number as the divisor. |
3 P1 | K constant add '+' by reusing the last used 2nd complex number |
4 P1 | K constant subtract '-' by reusing the last used 2nd complex number as the number to be subtracted |
5 P1 | e^{(z)} |
6 P1 | ln(z) |
7 P1 | K constant power '^' by reusing the last used 2nd complex number as the index |
8 P1 | cos(z) |
9 P1 | Recall current complex number (M8 & M9) |
Calculate z1/(z2+z3) with the answer in polar form where z1=1+2i, z2=3+4i & z3=5+6i
Follow this by finding the square root of the answer: √(z1/(z2+z3)) by raising the first answer to the power of 0.5.
Data Input Operation | Read-out | Remark |
---|---|---|
Mode 1 | 0. | Reset |
P0 | 0. | Zero display and HLT annunciator indicate readiness for data entry |
1 EXE | 0. | Awaits imaginary entry |
2 EXE | 2. | Entry and program completed. HLT annunicator off. |
P2 | 0. | Divide function awaits input. Ignore this and instead open a bracket. |
INV P5 | 0. | Awaits real input for the 1^{st} number within bracket. |
3 EXE | 0. | Real input made now awaiting imaginary input. Zero display is for default zero imaginary input. |
4 EXE | 4. | Imaginary input made. Program completed. |
P3 | 0. | Addition awaits input of real part of z3 for addition. |
5 EXE | 0. | Awaits imaginary input |
6 EXE | 8. | Real part of the answer to z2+z3. Pressing EXE now would give the imaginary part of the answer to the addition but this is not necessary.(Imaginary value is 10.) |
INV P6 | 0.170731707 | Real part of the answer to z1/(z2+z3) displayed after closing bracket invokes ÷ calculation. |
INV R->P | 0.170731707 | To convert answer to polar form use rectangular to polar conversion between real and imaginary outputs. |
EXE | 0.036585365 | Imaginary part of z1/(z2+z3) |
= | 0.174607573 | Magnitude of answer of z1/(z2+z3) |
INV X<->Y | 12.09475707 | Argument in degrees of z1/(z2+z3) |
INV P7 | 0. | Awaits real part of index for performing power calculation. |
0.5 EXE | 0. | Real value input, program awaits imaginary input. |
EXE | 0.415535366 | EXE takes default zero input for imaginary input. Displayed value is real part of √(z1/(z2+z3)) |
EXE | 0.044021963 | Displayed value is imaginary part of √(z1/(z2+z3)) |
Show that multiplying by e^{iπ/4} causes a rotation of 45° (i.e π/4 radians)
Data Input Operation | Read-out | Remark |
---|---|---|
Mode 1 | 0. | Only required if RUN annunciator is not set |
P0 | 0. | Zero display and HLT annunciator indicate readiness for data entry |
EXE | 0. | Enter to imaginary component |
π ÷ 4 = EXE | 0.785398163 | iπ/4 entered |
5 P1 | 0.707106781 | Complex e^{x} called |
INV R->P EXE = | 1. | Perform rectangular to polar convertion to find magnitude and angle |
INV X<->Y | 45 | Shows that argument of e^{iπ/4} is 45° |
P1 | 0. | Call complex multiply |
INV P5 | 0. | Open bracket because to multiply by e^{iπ/4} requires forced precedence for performing the antilog. (Note: Instead of opening the bracket and recalculating e^{iπ/4} one could just recall M8 and put this into M5 and recall M9 and put this into M6. One could then use the 1 P1 feature to do the multiply. One would then end up at the step below after closing the bracket INV P6). |
EXE | 0. | Enter 0 for real part |
π ÷ 4 = EXE | 0.785398163 | Re-enter number to be antilogged |
5 P1 | 0.707106781 | e^{iπ/4} recalculated |
INV P6 | 1.42^{-10} | Close bracket and perform the × (The real part of the answer shown here should be zero. See comments on accuracy below) |
INV R->P EXE | 0.999999999 | Imaginary part of answer (Should be 1) |
= | 0.999999999 | Magnitude of answer of (e^{iπ/4})^{2}. (Should be 1) |
INV X<->Y | 89.99999999 | Argument in degrees of (e^{iπ/4})^{2}. (Should be 90°) |
1 P1 | -0.70710678 | Request multiplication by the last multiplier (i.e. e^{iπ/4}) |
INV R->P EXE = | 0.999999999 | Magnitude of answer (Should be 1) |
INV X<->Y | 135 | Argument in degrees of (e^{iπ/4})^{3}. (Correct answer i.e. 3×45°=135°) |
Brackets can be stacked to 3 levels only. WARNING: These is no C error for overflow. The first time a bracket is opened the 1^{st} (or current) complex number with the following operation is stored in M17 to M19. The 2^{nd} level is stored in memories M14 to M16. The 3^{rd} level is stored in M11 to M13. The 4^{th} level would be stored in M8 to M10 but this uses the memories that are used for the inside of the brackets. In practice this is not a major problem because calculations can be rearranged so that the limit is not breached. As an aside, the '80s Hewlett Packard HP15C, that had built in complex numbers, had a smaller stack and no overflow warning, but of course you could use the complex numbers within programs.
No attempt has been made to keep the 12 digital accuracy of the calculator that is lost when one puts numbers in the any of memories of the calculator (All M-registers store only 10 digits). Unfortunately when using the power function artefacts of the order of 10^{-10} of the magnitude are often seen. This is especially annoying when they appear as an imaginary part that shouldn't exist. This would of course still happen using 12 digits but with smaller errors. My HP48S, that has built in complex numbers and works to 12 digits, calculated (e^{iπ/4})² as -1.414×10^{-12}+1i rather than the correct 0+1i. Compare this with the result above of 1.42×10^{-10}+0.9999999998i.
Instead of typing in the below, if you've got the cassette adaptor try the *.wav file
Program for Complex Numbers | ||
---|---|---|
Program | Remark | |
MODE, 2, | Go to program mode | |
P0 | AC/Complex start program | |
1, 9, MinF, AC, Min1, HLT, Min8, 0, HLT, Min9, | Reset indirection for bracket memories. Request real and imaginary parts of first number. | |
Total number of steps = 10 | ||
P1 | Multiply and function request program | |
1, Min0, -, 1, =, INV ISZ, GOTO 1, 1, Min1, LBL1, GSB P9, | If no number has just been typed into the x-register then set function number to 1 for multiply and call processing routine P9. If a number has just been typed into the x-register then store the function number, set flag to indicate that a sec ond input number is not required and call for processing from P9. | |
Total number of steps = 11 | ||
P2 | Division request program | |
2, Min0, GSB P9 | ||
Total number of steps = 3 | ||
P3 | Addition request program | |
3, Min0, GSB P9 | ||
Total number of steps = 3 | ||
P4 | Subtraction request program | |
4, Min0, GSB P9 | ||
Total number of steps = 3 | ||
P5 | Open bracket | |
MR9, INV IND, MinF, 1, M- F, MR8, INV IND, MinF, 1, M- F, MR0, INV IND, MinF, 1, M- F, AC, HLT, Min8, 0, HLT, Min9 | Stack current complex number and associated function number, leaving indirection ready for next bracket. Request new complex number. | |
Total number of steps = 21 | ||
P6 | Close bracket and evaluate pending calculation | |
MR8, Min5, MR9, Min6, 1, M+ F, INV IND, MRF, Min0, 1, M+ F, INV IND, MRF, Min8, 1, M+ F, INVIND, MRF, Min9, 1, Min1, GSB P9 | Move 1^{st} complex number to 2^{nd} number and then unstack old complex number with associated function number. Call P9 for number processing. | |
Total number of steps = 22 | ||
P7 | Power function request | |
7, Min0, GSB P9 | ||
Total number of steps = 3 | ||
P8 | Reciprocal function request | |
2, Min0, 1, Min1, X<->M8, Min5, AC, X<->M9, Min6, GSB P9 | Set function to division. Set flag to prevent request for another complex number. Make 1^{st} number equal to 1 and the 2^{nd} number equal the current complex number. Call P9 for division processing. | |
Total number of steps = 10 | ||
P9 | Main processing routine | |
MODE 5, MR1, INV x=0, GOTO 0, 0, Min1, MR6, INV IND GOTO 0, | Set radian mode for possible future trig calculations. If flag requesting no 2^{nd} number input is set, clear the flag and jump to the calculation required using the indirect GOTO. (See Note 1) MR6 is performed because some of the calculation areas assume that the imaginary part of the 2^{nd} number is immediately available. | |
LBL 0, | HLT, Min5, 0, HLT, Min6, INV IND, GOTO 0, | Request 2^{nd} complex number and go to calculation requested by indirect GOTO. (See Note 1) |
LBL 7, | 1, Min1, | Set flag to perform complex powers using the below complex log, multiplication and antilog. |
LBL 6, | MR8, INV R->P, MR9, =, ln, Min8, INV X<->Y, Min9, MR1, INV x=0, GOTO 9, MR6, | Perform complex ln and then either goto output or if doing powers continue to do multiplication. |
LBL 1, | ×, MR9, +/-, +, MR8, ×, MR5, =, X<->M8, ×, MR6, +, MR9, ×, MR5, =, Min9, MR1, INV x=0, GOTO 9, | Perform complex multiplication and then either goto output or if doing powers continue to do antilog. |
LBL 5, | MR8, INV e^{x}, ×, ×, MR9, cos, =, Min8, MR9, sin, =, Min9, AC, Min1, GOTO 9, | Perform complex e^{x} and goto output. |
LBL 2, | INV x^{2}, +, MR5, INV x^{2}, =, Min0, MR9, ×, MR5, -, MR8, ×, MR6, =, ÷, MR0, =, X<->M9, ×, MR6, +, MR8, ×, MR5, =, ÷, MR0, =, Min8, GOTO 9, | Perform complex division and goto output. |
LBL 3, | M+ 9, MR5, M+ 8, GOTO 9, | Perform complex addition and goto output |
LBL 4, | M- 9, MR5, M- 8, GOTO 9, | Perform complex subtraction and goto output |
LBL 8, | MR8, cos, ×, MR9, hyp cos, =, X<->M8, sin, +/-, ×, MR9, hyp sin, =, Min 9 | Perform complex cosine |
LBL 9, | Mode 4, MR8, HLT, MR9 | Output the answer |
Total number of steps = 131 | ||
Number of steps left = 29 |
Notes | ||
---|---|---|
1 | The INV IND GOTO 0 jumps to the label pointed to by the most significant digit of the content of the M0 register. Hence if either P2 or P8 were pressed, putting 2 into M0, then LBL 2 would be the destination. However if 2 were pressed before pressing P1 then 21 would be placed in M0 and so LBL 2 would again be the destination | |
Contents in memories | |||
---|---|---|---|
0 | Function number | .0 | not used |
1 | Flag used to indicate uniary function and independently to indicate that fall thru of log, multiplication and antlog functions is required to implement complex powers. | .1 | function to be applied between the 3^{rd} stacked number and the next number when it is unstacked |
2 | not used | .2 | real part of 3^{rd} stacked number |
3 | not used | .3 | imaginary part of 3^{rd} stacked number |
4 | not used | .4 | function to be applied between the 2^{nd} stacked number and the next number when it is unstacked |
5 | real part of 2^{nd} number in calculation | .5 | real part of 2^{nd} stacked number |
6 | imaginary part of 2^{nd} number in calculation | .6 | imaginary part of 2^{nd} stacked number |
7 | not used | .7 | function to be applied between the 1^{st} stacked number and the next number when it is unstacked |
8 | Real part current complex number (Complex x-register) | .8 | real part of 1^{st} stacked number |
9 | Imaginary part current complex number (Complex x-register) | .9 | imaginary part of 1^{st} stacked number |
F | Pointer to next memory to be used for brackets | .F | not used |