Post Reply 
(12C) Complex Arithmetic
05-27-2017, 09:02 AM (This post was last modified: 05-27-2017 09:20 AM by Dieter.)
Post: #3
RE: (12C) Complex Arithmetic
(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
02-      34   X<>Y
03-    44 1   STO 1
04-    45 1   RCL 1     ' display first operand
05-    45 2   RCL 2     ' resp. result of last calculation
06-      31   R/S       ' and wait for another operand & opcode
07-      33   R↓
08-    44 4   STO 4
09-      33   R↓
10-    44 3   STO 3
11-      33   R↓
12-      33   R↓
13-       1   1
14-      30   -
15-   43 35   X=0?      ' code=1 ?
16-43,33 31   GTO 31    ' jump to add routine
17-       1   1
18-      30   -
19-   43 35   X=0?      ' code=2 ?
20-43,33 36   GTO 36    ' jump to subtract routine
21-       1   1
22-      30   -
23-   43 35   X=0?      ' code=3 ?
24-43,33 51   GTO 51    ' jump to multiply routine
25-       1   1
26-      30   -
27-   43 35   X=0?      ' code=4 ?
28-43,33 41   GTO 41    ' jump to divide routine
29-       0   0
30-      10   /         ' else generate Error 0
31-    45 3   RCL 3     ' addition
32- 44 40 1   STO+ 1
33-    45 4   RCL 4
34- 44 40 2   STO+ 2
35-43,33 04   GTO 04
36-    45 3   RCL 3     ' subtraction
37- 44 30 1   STO- 1
38-    45 4   RCL 4
39- 44 30 2   STO- 2
40-43,33 04   GTO 04
41-    45 3   RCL 3     ' division
42-      36   ENTER
43-      20   *
44-    45 4   RCL 4
45-      36   CHS
46-    44 4   STO 4
47-      36   ENTER
48-      20   *
49-      40   +
50-43,33 52   GTO 52
51-       1   1         ' multiplication
52-    44 0   STO 0     ' common code for multiply and divide starts here
53-    45 1   RCL 1
54-    45 3   RCL 3
55-      20   *
56-    45 2   RCL 2
57-    45 4   RCL 4
58-      20   *
59-      30   -
60-    45 2   RCL 1
61-    45 4   RCL 4
62-      20   *
63-    45 3   RCL 3
64-    45 2   RCL 2
65-      20   *
66-      40   +
67-    44 2   STO 2
68-      34   X<>Y
69-    44 1   STO 1
70-    45 0   RCL 0
71- 44 10 1   STO/ 1
72- 44 10 2   STO/ 2
73-43,33 04   GTO 04

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]

3 [ENTER] 4 [R/S]                    4,00
5 [ENTER] 6 [CHS] [ENTER] 3 [R/S]    2,00 [X<>Y] 39,00   ' = 39 + 2i
1 [ENTER] 2 [ENTER] 4 [R/S]        -15,20 [X<>Y]  8,60   ' = 8,6 - 15,2i
7 [ENTER] 3 [ENTER] 1 [R/S]        -12,20 [X<>Y] 15,60   ' = 15,6 - 12,2i

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
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C) Complex Arithmetic - Eddie W. Shore - 05-20-2017, 01:47 PM
RE: (12C) Complex Arithmetic - hibiki - 05-24-2017, 05:27 PM
RE: (12C) Complex Arithmetic - Dieter - 05-27-2017 09:02 AM
RE: (12C) Complex Arithmetic - bshoring - 06-27-2017, 10:17 PM



User(s) browsing this thread: 1 Guest(s)