Post Reply 
(35S) Determinant of a 3x3 matrix (plus cross product): the shortest way.
06-26-2022, 07:42 AM (This post was last modified: 06-28-2022 07:02 PM by Roberto Volpi.)
Post: #1
(35S) Determinant of a 3x3 matrix (plus cross product): the shortest way.
Taking advantage of the HP35S vector support, a determinant of a 3x3 squared matrix can be computed with just 10 lines of programs:

001 LBL M
002 XEQ X
003 STO G
004 SF 10
005 (EQN) 3RD VECTOR
006 CF 10
007 (EQN) [REGZ, REGY, REGX]*
008 RCL G
009 x
010 RTN

* to insert REGX in program mode press EQN, R down, and select X

INSTRUCTIONS:

The elements of our 3x3 matrix will be input as row vectors, just by typing the values separated by ENTER.

EX. calculate the determinant of the following 3x3 matrix:

[3, 5, 2
9, 7, 2
11, 0, 0]

- input the 1st row: 3 ENTER 5 ENTER 2
- press XEQ M and the HP35S will display: 2ND VECTOR
- input the 2nd row: 9 ENTER 7 ENTER 2
- press R/S and the HP35S will display: 3RD VECTOR
- input the 3rd row: 11 ENTER 0 ENTER ENTER (as the "0" is repeated)
- press R/S and the HP35S will display the result: -44

It does not work? Well, also the subroutine X needs to be inserted.

It is a short standalone program of just 10 lines to compute the cross product of a 2 vectors of 3 elements.

001 LBL X
002 SF 10
003 STO C
004 R down
005 STO B
006 R down
007 (EQN) 2ND VECTOR
008 CF 10
009 (EQN) [BxREGX-CxREGY,CxREGZ-REGTxREGX,REGTxREGY-BxREGZ]
010 RTN


INTRUCTIONS:

The elements of our vectors will be input just by typing the values separated by ENTER.

EX. calculate the cross products of these 2 vectors:
[3, 5, 2] and [9, 7, 2]

- input the 1st vector: 3 ENTER 5 ENTER 2
- press XEQ X and the HP35S will prompt: 2ND VECTOR
- input the 2nd vector: 9 ENTER 7 ENTER 2
- press R/S and the HP35S will display the result: [-4, 12, -24]

Enjoy!



Put a calculator into your life!
Visit this user's website Find all posts by this user
Quote this message in a reply
06-26-2022, 08:52 AM
Post: #2
RE: (35S) Determinant of a 3x3 matrix (plus cross product): the shortest way.
Somewhat related from HP 35s - my first thoughts: Message #20:
Code:
X001 LBL X
X002 ABS
X003 CLx
X004 LASTx
X005 RDN
X006 RDN
X007 [
      [0,[0,0,-1]*REGT,[0,1,0]*REGT]*REGZ,
      [[0,0,1]*REGT,0,[-1,0,0]*REGT]*REGZ,
      [[0,-1,0]*REGT,[1,0,0]*REGT,0]*REGZ
     ]
X008 REGZ
X009 RDN
X010 RTN
Lines 2-4 and 8-9 could be omitted. They copy T to Z and X to LASTx.

Now that we have the cross-product of two vectors it's easy to calculate the determinant: just calculate the scalar product with the third vector.
Find all posts by this user
Quote this message in a reply
06-26-2022, 09:01 AM
Post: #3
RE: (35S) Determinant of a 3x3 matrix (plus cross product): the shortest way.
You might also be interested in these links:
Find all posts by this user
Quote this message in a reply
06-26-2022, 09:07 AM (This post was last modified: 06-26-2022 09:09 AM by Roberto Volpi.)
Post: #4
RE: (35S) Determinant of a 3x3 matrix (plus cross product): the shortest way.
(06-26-2022 09:01 AM)Thomas Klemm Wrote:  You might also be interested in these links:

The list of related items may be in fact endless.

Matrices are an interesting subject and lot of HP35S users have submitted great programs to add matrix calculation features, à la HP15C.



Put a calculator into your life!
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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