Post Reply 
HP35S - Inverse of a 3x3 matrix (but also determinant, cross product, etc.)
09-28-2023, 12:12 PM (This post was last modified: 09-28-2023 12:16 PM by Roberto Volpi.)
Post: #1
HP35S - Inverse of a 3x3 matrix (but also determinant, cross product, etc.)
Hi all,

the following is an improvement of an already submitted program of mine: https://www.hpmuseum.org/forum/thread-18512.html

The purpose is to have in just 1 place a quick tool to find, in a 3x3 matrix:

Determinant
Inverse matrix
Cross product
Angle between two 3D vectors.

Maybe one day also Eigenvectors and Eigenvalues...

M001 LBL M
M002 SF1
M003 XEQ X001
M004 STO P
M005 R down
M006 STO C
M007 R down
M008 STO B
M009 R down
M010 STO A
M011 SF 10
M012 (equ) 2DN VECTOR Q
M013 CF 10
M014 XEQ X001
M015 STO Q
M016 R down
M017 STO F
M018 R down
M019 STO E
M020 R down
M021 STO T
M022 (eqn) [BxF-CxE, CxT-AxF, AxE-BxT]
M023 STO X
M024 FS 1?
M025 GTO M028
M026 VIEW X
M027 GTO M058
M028 SF 10
M029 (eqn) 3RD VECTOR R
M030 CF 10
M031 XEQ X001
M032 STO R
M033 R down
M034 STO N
M035 R down
M036 STO H
M037 R down
M038 STO G
M039 R down
M040 RCLxX
M041 STO D
M042 CF 1
M043 VIEW D
M044 RCL+C
M045 (eqn) [ExN-FxH, CxH-BxN, BxF-ExC]
M046 STO K
M047 (eqn) [FxG-TxN, AxN-CxG, TxC-AxF]
M048 STO L
M049 (eqn) [TxH-GxE, BxG-AxH, AxE-BxT]
M050 STO M
M051 RCL D
M052 STO/K
M053 STO/L
M054 STO/M
M055 RCL K
M056 RCL L
M057 RCL M
M058 RTN
M059 RCL X
M060 ABS
M061 RCL P
M062 RCLxQ
M063 /
M064 ATAN
M065 >DEG
M066 STO Y
M067 VIEW Y
M068 RTN


I have separated the following routine, as it may be used as an additional function, to put values on stacks z, y and x into a 3d vector

X001 LBL X
X002 (eqn) [RegZ, RegY, RegX]
X003 RTN

------------------
INSTRUCTIONS:
------------------

DETERMINANT + INVERSE MATRIX

enter 1st row, an entry per stack
XEQ M
enter 2nd row, an entry per stack
R/S
enter 3rd row, an entry per stack
R/S

HP35S: D= determinant value
R/S
HP35S: inverse matrix arranged this way:
stack t:determinant
stack z: 1st row
stack y: 2nd row
stack x: 3rd row

CROSS PRODUCT + ANGLE (1st & 2nd row vector)

enter 1st vector, an entry per stack
XEQM003
enter 2nd vector, an entry per stack
R/S

HP35S: X= cross product value
R/S
HP35S: Y= angle in DEG

CROSS PRODUCT + ANGLE of first 2 rows after finding determinant and inverse matrix:

RCL X to recall cross product
XEQ M058 to find the angle in DEG

DETERMINANT & INVERSE MATRIX after finding cross product (and/or angle)

XEQ M028
Enter 3rd row vector, an entry per stack
R/S
HP35S: determinant and inverse matrix arranged this way:
stack t:determinant
stack z: 1st row
stack y: 2nd row
stack x: 3rd row


Enjoy!



Put a calculator into your life!
Visit this user's website Find all posts by this user
Quote this message in a reply
09-28-2023, 08:52 PM
Post: #2
RE: HP35S - Inverse of a 3x3 matrix (but also determinant, cross product, etc.)
Please, could you please include one example for each calculation type. It will be very useful for everybody to check the correct program typing keys and procedure. Thank you in advance for your effort and sharing this valuable program. Pedro
Find all posts by this user
Quote this message in a reply
09-30-2023, 09:35 AM
Post: #3
RE: HP35S - Inverse of a 3x3 matrix (but also determinant, cross product, etc.)
Dear Pedro

here quick examples as requested:

1) Determinant and inverse of following matrix:

1, 2, 3
4, 5, 6
7, 8, -9

Press:
1
ENTER
2
ENTER
3
XEQ M
ENTER

The calculator will ask for the 2nd row vector

Press:
4
ENTER
5
ENTER
6
R/S

The calculator will ask for the 3rd row vector

Press:
7
ENTER
8
ENTER
-9
R/S

The calculator will display "D=54" which is the determinant

Press: R/S

The calculator will display 2nd and 3rd row vectors of inverse matrix in 3D vector form.

Stack values will be as follows, with entries in FDISP for easier readability:

Stack t: 54 (which is the determinant value)
Stack z: [ -1+13/18, 7/9, -1/18 ] (1st row vector of inverse matrix)
Stack y: [ 1+4/9, -5/9, 1/9 ] (2nd row vector of inverse matrix)
Stack x: [-1/18, 1/9, -1/18] (3rd row vector of inverse matrix)

2) Cross product and angle of first 2 row vectors already inputed

Cross vector: RCL X, which gives [ -3, 6, -3 ]
Angle: Press XEQ M058, which gives Y=12.9331... as DEG

3) Cross product and angle of 2 3D vectors:

[ 3, 2, 1 ]
[ 7, 5, -2]

Press:
3
ENTER
2
ENTER
1
XEQ M003

The calculator will ask for the 2nd vector

Press:
7
ENTER
5
ENTER
-2
R/S

The calculator will display X= [ -9, 13, 1 ], which is the cross product
Press R/S, and the calculator will display Y=28.6482..., which is the angle in DEG mode

4) Determinant and inverse matrix made after adding a 3rd row vector to former example:

3rd row vector: [ 1, 2, -6 ]

Press:
XEQ M028
1
ENTER
2
ENTER
-6
R/S

The calculator will display D=11, which is the determinant

Press R/S

The calculator will display 2nd and 3rd row vectors of inverse matrix in 3D vector form.

Stack values will be as follows, with entries in FDISP for easier readability:

Stack t: 1 (which is the determinant value)
Stack z: [ -2+4/11, 1+3/11, -9/11 ] (1st row vector of inverse matrix)
Stack y: [ 3+7/11, -1+8/11, 1+2/11 ] (2nd row vector of inverse matrix)
Stack x: [ 9/11, -4/11, 1/11] (3rd row vector of inverse matrix)

Hope no typo is ruining these examples...



Put a calculator into your life!
Visit this user's website Find all posts by this user
Quote this message in a reply
09-30-2023, 03:22 PM
Post: #4
RE: HP35S - Inverse of a 3x3 matrix (but also determinant, cross product, etc.)
This is perfect, TYVM. Now I feel confident to use your program. Very clear informaciĆ³n to test the PGRM. Pedro
Find all posts by this user
Quote this message in a reply
Post Reply 




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