(12C) Complex Arithmetic - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (12C) Complex Arithmetic (/thread-8371.html) |
(12C) Complex Arithmetic - Eddie W. Shore - 05-20-2017 01:47 PM Let A and B represent the two complex numbers A = R1 + R4*i B = R2 + R5*i Where i = √-1 Store real components in R1 and R2, and imaginary parts R4 and R5. Choose the arithmetic calculations: Enter 0 for addition: A + B Enter 1 for multiplication: A * B Enter 2 or otherwise for division: A ÷ B Result: C = R3 + R6*i Program: Code:
Example: A = 4.25 + 3.16*i, B = -2.27 + 1.04*i Option 0 (+): 1.98 + 4.20*i Option 1 (*): -12.93 – 2.75*i Option 2 (÷): -1.02 – 1.86*i RE: (12C) Complex Arithmetic - hibiki - 05-24-2017 05:27 PM Hi Eddie ! Nice program. In step 16, there is a mistake: you wrote "RCL"6 instead of "STO"6. The keycode is correct. RE: (12C) Complex Arithmetic - Dieter - 05-27-2017 09:02 AM (05-20-2017 01:47 PM)Eddie W. Shore Wrote: Store real components in R1 and R2, and imaginary parts R4 and R5. Choose the arithmetic calculations: This approach can be improved so that you do not have to store four values into four registers. The program may do this for you. Also chain calculations are possible if the final result is stored as input for the next calculation. Here is my suggestion: Code: 01- 44 2 STO 2 Enter program, switch back to run mode [P/R] 0. Reset calculation: [f] [PRGM] 1. Enter first operand: real [ENTER] imaginary part [R/S] 2. Enter second operand and opcode: real [ENTER] imaginary part [ENTER] code [R/S] where code=1 for add, 2 for subtract, 3 for multiply and 4 for divide. Any other code yields Error 0. For further calculations with the result continue with step 2. Example: (3+4i * 5–6i) / (1+2i) + (7+3i) Code: [f] [PRGM] So the final result is 15,6 – 12,2 i Of course the intermediate results do not have to be examined by [X<>Y] to show the real part, you can simply continue calculating after each step. Start a new calculation with [f][PRGM] which resets the program to step 00 to accept a new first operand. Dieter RE: (12C) Complex Arithmetic - bshoring - 06-27-2017 10:17 PM I like Dieter's approach the best. It allows chain calculations and is more flexible. |