HP Forums

Full Version: (15C) 3 Equations with 3 Unknowns
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
HP-15C already got the Matrix Solver function but

the Setup Process is tedious and time-consuming.

With this little program it help to eliminate most of

the setup process, user only input data for the Rows and Columns.

-----------------------------------------------------------
Procedure: [USER] mode

Initialize press [D] display 3

Input Data press [R/S] on each rows from left to right

Press [E] Input Data [R/S] input data the columns from top to buttom

When done display should shown [ C 3 1 ]

[R/S] display answer for X
[R/S] display answer for Y
[R/S] display answer for Z
-----------------------------------------------------------
Program: input program in [USER] mode
Quote:LBL D
MATRIX 0
MATRIX 1
3 ENTER
DIM A
R/S
--------------------------------
LBL 1
STO A // Press [STO] [f] [A]
CLx
R/S
GTO 1
--------------------------------
LBL E
3 ENTER 1
DIM B
R/S
STO B // Press [STO] [f] [B]
R/S
STO B // Press [STO] [f] [B]
R/S
STO B // Press [STO] [f] [B]
RESULT C
-------------------------------------
RCL MATRIX B
RCL MATRIX A
÷
R/S
RCL C // Press [RCL] [f] [C]
R/S
RCL C // Press [RCL] [f] [C]
R/S
RCL C // Press [RCL] [f] [C]
R/S
----------------------------------------
PSE
RCL MATRIX A
MATRIX 9
X<>Y
RTN

Example: [USER] mode

4X + 2Y - 2Z = 8
X + Y + Z = 7
2X + 2Y + Z = 12

Press [D] display 3

4 [R/S] 2 [R/S] 2 [CHS] [R/S]
1 [R/S] 1 [R/S] 1 [R/S]
2 [R/S] 2 [R/S] 1 [R/S] display 1

Pres [E] display 1

8 [R/S] 7 [R/S] 12 [R/S] display [ C 3 1 ]

[R/S] display answer for X = 1
[R/S] display answer for Y = 4
[R/S] display answer for Z = 2

For Determinant press [X<>Y] display answer -2


Gamo 3/2024
A nice, useful, program!
Thank you!
It is a great program.

I kind of had to redo it a bit because of the USER mode and how I couldn't get the pointer (R0,R1) to advance on the HP 15C Collector's Edition.

Code:
  (34 steps)
LBL D
MATRIX 0
MATRIX 1
3
ENTER
DIM A
R/S

LBL 1
u STO A  (u = USER mode)
CLx
R/S
GTO 1

LBL E

ENTER 
1
DIM B
R/S
u STO B
R/S
u STO B
R/S
u STO B
RESULT C

RCL MATRIX B
RCL MATRIX A
÷
R/S

u RCL C
R/S
u RCL C
R/S
u RCL C
RTN
(03-16-2024 02:49 PM)Eddie W. Shore Wrote: [ -> ]It is a great program.

I kind of had to redo it a bit because of the USER mode and how I couldn't get the pointer (R0,R1) to advance on the HP 15C Collector's Edition.

Eddie,

I have not read the above closely, but are you suggesting you have found some behavior where the 15C and 15c CE act differently? If so, please try to isolate it and summarize the exact steps to perform on both, to see if there is indeed different behavior.

Thx
Eddie W. Shore: Thank for the interest with this program

In order to do the "Store and Recall" Matrix in program it have

to be in [USER] mode since it is store in Lable.

So to enter this the [f] key must be use like STO A

enter as [STO] [f] [A]

To run the Determinant somehow not work in program.

I try to program [RCL] [MATRIX] [A] [MATRIX] 9 and with this

in program also make the whole program to give wrong answer.

The X and Y give correct answer but not the Z

Gamo
Bonjour à toutes et à tous.

This program is a really good idea. Just having to press the (R/S) key saves time and avoids errors by limiting typing.

But why limit this only to the case where there are three equations?

The HP-15C is able to do much more! This is not a simple TI-30X PRO which is limited to two or three equation systems only.

[Image: attachment.php?aid=13380]

On the other hand, as we see on this screenshot, on the Ti X PRO there is a very nice feature: the equations are entered in order, left and right part for each row.

By memorizing the number of equations in the index register I, I was able to make the GAMO's code more general. I would like to share this new version with you so that anyone can test it and tell us if it is operational (or not).

The number of equations is given as a parameter at start. It uses the fact that the uSTO/uRCL matrix instructions are also used for conditional jumps at the end of each matrix.

As long as we're at it, and now that certain HP-15Cs have extended memory, the fact this new code is more complicated than that of GAMO proposed will no more be a problem. I hope that any larger system of equations will be easier to work out. Or at least as easy as with 3x3 GAMO's code.
In order to enter each equation as on the actual CASIO, TI or SHARP machines, namely in order, left part then right term line by line, the A matrix is reDIMed after each row entry.

So the code below can be used for systems ranging from 1 to 6 equations on an original HP-15C (and certainly up to 7 on the extended HP-15Cs - please tell me).

[Image: attachment.php?aid=13381]

* Please note; the instructions on lines 016u STO A and 025u STO B must be entered in USER mode (and the small u must be visible in the code)

# The display format instructions from lines 015- and 024- can be modified at the user's convenience. These are respectively the numerical format for displaying the coefficients of the equations during inputs and the format of the final solutions of the system.

In this short version of my code, no provision for code exist to list the solutions by pressing only one key. System solutions have to be obtained in USER Mode keying (RCL)(C). The label of the solution is momentary display (nice feature when numerous variable are present).
If one prefer to just have to press on the (R/S) key, coding a loop at the end of the code can be easy achieved.

Here is an illustration of the input for the example of GAMO:
\( \left\{\begin{matrix} 4 & 2 & -2 \\ 1 & 1 & 1 \\ 2 & 2 & 1 \\ \end{matrix} \, \,
\left| \begin{matrix} 8 \\ 7 \\ 12 \\ \end{matrix}\right.\right\}\\ \)

[Image: attachment.php?aid=13379]

And a resolution of a system of 5 equations with 5 unknowns allowing us to verify on our HP-15C the results obtained here (YouTube video) using a Japanese FACOM 128B relay computer from 1958.


f USER 5 g RTN R/S
   1.        2 R/S 3 R/S 4 R/S 5 CHS R/S 6 R/S      -1.        3 R/S
   2.        1 R/S 1 R/S 2 CHS R/S CHS R/S CHS R/S   -2.        0.4 R/S
   3.        3 R/S 3 R/S 4 CHS R/S 1 R/S 6 CHS R/S   -3.        0.7 R/S
   4.        1 R/S 4 CHS R/S 5 R/S 6 CHS R/S 5 R/S   -4.        0.05 R/S
   5.        1 CHS R/S 2 CHS R/S 3 R/S 2 R/S 1 R/S   -5.        0.15 R/S
           C    5  1
RCL C        C  1,1        500.0000 -03     (= 1/2 )
RCL C        C  2,1        333.3333 -03     (= 1/3 )
RCL C        C  3,1        250.0000 -03     (= 1/4 )
RCL C        C  4,1        200.0000 -03     (= 1/5 )
RCL C        C  5,1        166.6667 -03     (= 1/6 )



Comments and suggestions are both welcome.
I had no intention of using the HP15C CE for matrix calculations, as the HP Prime is better in that regard. But on the way home from a business trip I was bored (as a passenger of course) so I read the HP15C CE manual and its matrix capabilities. Then when I opened this forum at home, this new thread jumped out at me. :-)

Here is a program to solve n linear equations:
1) type n and press A
2) entering the elements of matrix A and then matrix B using R/S
3) after entering all elements of both matrices, cycle through the resulting matrix C using R/S.

Code:
001    42,21,11    LBL A
002    42,16,0     MATRIX 0
003    36          ENTER
004    42,23,11    DIM A
005    1           1
006    42,23,12    DIM B
007    42,26,13    RESULT C
008    42,16,1     MATRIX 1
009    42,21,1     LBL 1
010    45,16,11    RCL MATRIX A
011    31          R/S
012    u 44 11     STO A
013    22 1        GTO 1
014    42,21,2     LBL 2
015    45,16,12    RCL MATRIX B
016    31          R/S
017    u 44 12     STO B
018    22 2        GTO 2
019    45,16,12    RCL MATRIX B
020    45,16,11    RCL MATRIX A
021    10          ÷
022    45 26       RCL RESULT
023    42,21,3     LBL 3
024    31          R/S
025    u 45 13     RCL C
026    22 3        GTO 3
027    22 3        GTO 3
Hi CHROMOS,

Nice code !

Your program is strangely close to the one I made before changing the order of the inputs. Not mixing matrix A and B inputs really shorten the code length.

Anyone who prefer to have easy listing of the solutions using only the R/S key, may simply add the line 022- to 027- from CHROMOS code at the end of my code version.
Thanks everyone that interest about this program.

I have made a little add-on to my program to include

the answer for the Determinant. The code look a bit

strange that have to put the [R/S] and [PSE] code in it in order

to run program smoothly without error.

Here is another example:

4X + 5Y - 2Z = -14
7X - Y + 2Z = 42
3X + Y + 4Z = 28

Go ahead and Press D then enter data each rolls from left to right

Then Press E and enter data column from top to buttom

Continue [R/S] answer should be

X = 4, Y = -4 and Z = 5

Press [X<>Y] to view Determinant and answer is -154

Gamo
Reference URL's