Post Reply 
(12C) Determinant of the 3x3 Matrix
12-08-2018, 05:15 AM
Post: #1
(12C) Determinant of the 3x3 Matrix
Program to get the "Determinant of the 3x3 Matrix"

a1 b1 c1
a2 b2 c2
a3 b3 c3

-------------------------

Procedure:

Input steps from 1 to 9
in a pattern as shown.

1 4 7
8 2 5
6 9 3

--------------------------
Example: FIX 2

6 2 -4
5 6 -2
5 2 -3

1. 6 [R/S] display 6.00
2. 6 [R/S] display 36.00
3. 3 [CHS] [R/S] display -108.00
4. 2 [R/S] display 2.00
5. 2 [CHS] [R/S] display -4.00
6. 5 [R/S] display -128.00
7. 4 [CHS] [R/S] display -4
8. 5 [R/S] display -20.00
9. 2 [R/S] display 6

Answer: Determinant is 6
-----------------------------------
Program:
Code:

STO 1
R/S
STO 2
x
R/S
STO 3
x
R/S
STO 4
R/S
STO 5
x
R/S
STO 6
x
+
R/S
STO 7
R/S
STO 8
x
R/S
STO 9
x
+
RCL 6
RCL 2
x
RCL 7
x
-
RCL 9
RCL 5
x
RCL 1
x
-
RCL 3
RCL 8
x
RCL 4
x
-

Gamo
Find all posts by this user
Quote this message in a reply
12-08-2018, 01:59 PM (This post was last modified: 12-08-2018 02:00 PM by Dieter.)
Post: #2
RE: (12C) Determinant of the 3x3 Matrix
(12-08-2018 05:15 AM)Gamo Wrote:  Program to get the "Determinant of the 3x3 Matrix"

a1 b1 c1
a2 b2 c2
a3 b3 c3

It works, but entering the matrix is very cumbersome. First of all you have to remember the exact sequence (a1, b2, c3, b1, c2, a3, c1, a2, b3). This is very error prone: usually a matrix is enterend row by row or column by column. After each entered element an intermediate result shows up that may confuse the user. The stack must not be disturbed during entry and if you only get one single element wrong you have to start all over again.

So here's another idea. ;-)

Take a look at the keyboard. The numbers 1 through 9 are nicely arranged like the elements of a 3x3 matrix. Simply store the respective element in the register with the same position on the keyboard!

This way you can enter the matrix in any order you like, errors can be corrected, elements can be changed and the deteminant recomputed, and more.

So your example matrix

6  2 -4
5  6 -2
5  2 -3

is stored this way:

6 [STO] 7   2 [STO] 8  -4 [STO] 9

5 [STO] 4   6 [STO] 5  -2 [STO] 6

5 [STO] 1   2 [STO] 5  -3 [STO] 3

Looks quite intuitive to me. ;-)
You can also recall the registers to review the matrix.

Then run this program:

Code:
RCL 7
RCL 5
x
RCL 3
x
RCL 4
RCL 2
x
RCL 9
x
+
RCL 8
RCL 6
x
RCL 1
x
+
RCL 9
RCL 5
x
RCL 1
x
-
RCL 6
RCL 2
x
RCL 7
x
-
RCL 8
RCL 4
x
RCL 3
x
-

[R/S] => 6,00

Alternative method
Instead of storing the elements directly you can also enter the matrix this way:

f[CLEAR FIN]

6 [CFj]   2 [CFj]   -4 [CFj]

5 [CFj]   6 [CFj]   -2 [CFj]

5 [CFj]   2 [CFj]   -3 [CFj]

You may enter the matrix row by row or column by column – doesn't matter.

But, important: add a final [CHS] at the end of the above program.

[R/S] => 6,00

Dieter
Find all posts by this user
Quote this message in a reply
12-08-2018, 03:25 PM (This post was last modified: 12-08-2018 04:27 PM by Albert Chan.)
Post: #3
RE: (12C) Determinant of the 3x3 Matrix
(12-08-2018 01:59 PM)Dieter Wrote:  Take a look at the keyboard. The numbers 1 through 9 are nicely arranged like the elements of a 3x3 matrix.
Simply store the respective element in the register with the same position on the keyboard!

It would work even better if the keyboard shape like a telephone.
That way, the Cj input method match direct memory-store method. (No sign change needed)

I would suggest forget about the shape of keyboard, and store the numbers to R1, R2, R3 ...
So, both input methods get the same answer.

It also helps when lookup the registers: R1 = first number (instead of R7)

Edit: program can be shortened to 30 steps (possibly slightly faster too)
Assuming above suggested input method:

Code:
RCL 5 RCL 9 × RCL 6 RCL 8 × − RCL 1 ×
RCL 4 RCL 9 × RCL 6 RCL 7 × − RCL 2 × −
RCL 4 RCL 8 × RCL 5 RCL 7 × − RCL 3 × +
GTO 00
Find all posts by this user
Quote this message in a reply
12-08-2018, 04:40 PM (This post was last modified: 12-08-2018 04:41 PM by Dieter.)
Post: #4
RE: (12C) Determinant of the 3x3 Matrix
(12-08-2018 03:25 PM)Albert Chan Wrote:  I would suggest forget about the shape of keyboard, and store the numbers to R1, R2, R3 ...
So, both input methods get the same answer.

It also helps when lookup the registers: R1 = first number (instead of R7)

The point is: with the method I suggested there is no need to know which is the first or 5th or 8th element: simply look at the keyboard. Want to enter the first element in the third row? Simply look at the keyboard and store it in R1. No need to know this is the 7th element. If you count row by row and not column by column, that is. Otherwise it's the 3rd element. #-)

That's why I prefer the method suggested in my above post.

(12-08-2018 03:25 PM)Albert Chan Wrote:  Edit: program can be shortened to 30 steps (possibly slightly faster too)
Assuming above suggested input method:

Yes, but this can also be done for the other method. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 




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