Post Reply 
LIN-BAIRSTOW ALGORITHM for HP67/97 UPDATE!
08-12-2024, 02:47 PM (This post was last modified: 08-19-2024 10:48 PM by plore90.)
Post: #1
LIN-BAIRSTOW ALGORITHM for HP67/97 UPDATE!
Hello everyone,
here I am again to present my latest program on the LIN-BAISTROW algorithm for HP67/97. The program can find the real and/or complex roots of a polynomial from the 3rd degree to the 7th degree with real coefficients. In the manual contained in the zip file, everything is explained with various examples.
I hope that the program can be useful to some of you, and in any case of interest to you for educational purposes on Hp-67/97. The program as usual is written in a very basic way and is contained on two magnetic cards. Refining and compacting it, I think that it could be possible to arrive at the solution up to 8th degree polynomials... Anyone can try it or test it on the emulators of HP67 and HP97 of mister LIMPID FOX that are free for their use. As usual I will be grateful to anyone who reports bugs or makes improvements to the program.
Thanks for your attention
Plore90
****************
UPDATE!!!!

In the new attachment there is the version of the program "Lin-Bairstow" published on "HP-67/97 EUROPE User's Group" which allows to find the real and complex roots of a polynomial up to degree 18.

****************


Attached File(s)
.zip  6797_LIN-BAISTROW.zip (Size: 59.91 KB / Downloads: 13)
.pdf  LIN-BAIRSTOW HP-6797 GRADE_18.pdf (Size: 532.28 KB / Downloads: 5)
Find all posts by this user
Quote this message in a reply
08-12-2024, 09:23 PM
Post: #2
RE: LIN-BAIRSTOW ALGORITHM for HP67/97
Here are a few links for comparison: The programs for the HP-11C and the HP-15C use the built-in L.R. (linear regression) function to solve the system of linear equations.
Therefore they can not be translated as is to the HP-67/97.
But it should be possible to back-port Jean-Marc Baillard's program for the HP-41C to the HP-67/97.
Find all posts by this user
Quote this message in a reply
08-12-2024, 10:29 PM
Post: #3
RE: LIN-BAIRSTOW ALGORITHM for HP67/97
Hi Thomas,
Thanks for the insight and suggestions...
plore90
Find all posts by this user
Quote this message in a reply
08-14-2024, 01:46 PM (This post was last modified: 08-14-2024 05:42 PM by Thomas Klemm.)
Post: #4
RE: LIN-BAIRSTOW ALGORITHM for HP67/97
Here's a program that uses 112 lines.
A program B to solve the quadratic equation is also included.

Lin-Bairstow

This program is based on the Lin-Bairstow method to find the roots of a polynomial of degree \(n\):

\(P(x) = a_n x^n + a_{n-1} x^{n-1} + \cdots + a_2 x^2 + a_1 x + a_0 = 0\)

Code:
001: 31 25 11 : f LBL A
002: 00       : 0
003: 33 03    : STO 3
004: 33 04    : STO 4
005: 33 06    : STO 6
006: 33 07    : STO 7
007: 01       : 1
008: 00       : 0
009: 35 33    : h ST I
010: 31 25 00 : f LBL 0
011: 34 06    : RCL 6
012: 34 04    : RCL 4
013: 33 05    : STO 5
014: 34 02    : RCL 2
015: 71       : *
016: 51       : -
017: 34 03    : RCL 3
018: 33 04    : STO 4
019: 34 01    : RCL 1
020: 71       : *
021: 51       : -
022: 33 03    : STO 3
023: 34 24    : RCL (i)
024: 34 07    : RCL 7
025: 34 02    : RCL 2
026: 71       : *
027: 51       : -
028: 34 06    : RCL 6
029: 33 07    : STO 7
030: 34 01    : RCL 1
031: 71       : *
032: 51       : -
033: 33 06    : STO 6
034: 31 34    : f ISZ
035: 34 00    : RCL 0
036: 35 34    : h RC I
037: 32 71    : g x<=y
038: 22 00    : GTO 0
039: 34 03    : RCL 3
040: 34 07    : RCL 7
041: 71       : *
042: 34 04    : RCL 4
043: 34 06    : RCL 6
044: 71       : *
045: 51       : -
046: 34 05    : RCL 5
047: 34 06    : RCL 6
048: 71       : *
049: 34 04    : RCL 4
050: 34 07    : RCL 7
051: 71       : *
052: 51       : -
053: 34 05    : RCL 5
054: 34 03    : RCL 3
055: 71       : *
056: 34 04    : RCL 4
057: 32 54    : g x^2
058: 51       : -
059: 81       : /
060: 33 61 01 : STO + 1
061: 35 52    : h x<->y
062: 35 82    : h LSTx
063: 81       : /
064: 33 61 02 : STO + 2
065: 32 72    : g R->P
066: 31 24    : f RND
067: 31 61    : f x!=0
068: 22 11    : GTO A
069: 02       : 2
070: 33 51 00 : STO - 0
071: 01       : 1
072: 00       : 0
073: 35 33    : h ST I
074: 00       : 0
075: 41       : ENTER
076: 41       : ENTER
077: 41       : ENTER
078: 31 25 01 : f LBL 1
079: 35 53    : h Rv
080: 35 53    : h Rv
081: 34 24    : RCL (i)
082: 34 02    : RCL 2
083: 35 54    : h R^
084: 71       : *
085: 51       : -
086: 34 01    : RCL 1
087: 35 54    : h R^
088: 71       : *
089: 51       : -
090: 33 24    : STO (i)
091: 31 34    : f ISZ
092: 34 00    : RCL 0
093: 35 34    : h RC I
094: 32 71    : g x<=y
095: 22 01    : GTO 1
096: 35 22    : h RTN

Registers

\(\begin{matrix}
R_0 & 10 + n \\
R_1 & p \\
R_2 & q \\
R_3 & c = c_j \\
R_4 & {c}′ = c_{j+1} \\
R_5 & {c}'' = c_{j+2} \\
R_6 & b = b_i \\
R_7 & {b}′ = b_{i+1} \\
R_8 & \\
R_9 & \\
R_{10} & a_n \\
R_{11} & a_{n-1} \\
R_{12} & a_{n-2} \\
R_{13} & \cdots \\
R_{14} & \cdots \\
\end{matrix}\)

Quadratic Solver

This program solves the quadratic equation: \(T(x)=x^2+px+q=0\)

Code:
097: 31 25 12 : f LBL B
098: 34 01    : RCL 1
099: 02       : 2
100: 42       : CHS
101: 81       : /
102: 41       : ENTER
103: 41       : ENTER
104: 32 54    : g x^2
105: 34 02    : RCL 2
106: 51       : -
107: 31 54    : f sqrt
108: 51       : -
109: 35 52    : h x<->y
110: 35 82    : h LSTx
111: 61       : +
112: 35 22    : h RTN

Just be aware that this program can't find complex roots. Instead an Error will be displayed.
However it's easy to find the complex solutions. Just use:

CHS
\(\sqrt{x}\)

The solutions then are: \(Y \pm iX\)


Example

\(P(x)=2x^5-9x^4+15x^3+65x^2-267x+234=0\)

Insert coefficients

Code:
CL REG
2      STO 0
-9     STO 1
15     STO 2
65     STO 3
-267   STO 4
234    STO 5
P<>S

Initialization

Store \(10 + n\) in register \(0\) and initialize \(p = q = 1\).

Code:
15  STO 0
1   STO 1
    STO 2

Run program

Code:
A            14.0000

RCL 1         1.5000
RCL 2        -4.5000

P<>S
RCL 0         2.0000
RCL 1       -12.0000
RCL 2        42.0000
RCL 3       -52.0000
P<>S

Code:
B             1.5000
x<>y         -3.0000

Conclusion

\(2x^5-9x^4+15x^3+65x^2-267x+234=\)
\((x^2+1.5x-4.5)(2x^3-12x^2+42x-52)\)

Solutions

For \(x^2+1.5x-4.5=0\):
\(x_1=1.5\)
\(x_2=-3\)

Initialize guess

Code:
1   STO 1
    STO 2

Run program again

Code:
A             12.0000

RCL 1         -4.0000
RCL 2         13.0000

P<>S
RCL 0          2.0000
RCL 1         -4.0000
P<>S

Code:
B               Error
CLx           -9.0000
CHS            9.0000
√x             3.0000
x<>y           2.0000

Code:
P<>S
RCL 1         -4.0000
RCL 0          2.0000
÷             -2.0000
CHS            2.0000
P<>S

Conclusion

\(2x^3-12x^2+42x-52=\)
\((x^2-4x+13)(2x-4)\)

Solutions

For \(x^2-4x+13=0\):
\(x_3=2+3i\)
\(x_4=2-3i\)

For \(2x-4=0\):
\(x_5=2\)

Summary

Factors

\(2x^5-9x^4+15x^3+65x^2-267x+234=\)
\((x^2+1.5x-4.5)(x^2-4x+13)(2x-4)=\)
\((x-1.5)(x+3)(x^2-4x+13)2(x-2)=\)
\((2x-3)(x+3)(x^2-4x+13)(x-2)\)

Solutions

\(x_1=1.5\)
\(x_2=-3\)
\(x_3=2+3i\)
\(x_4=2-3i\)
\(x_5=2\)
Find all posts by this user
Quote this message in a reply
08-14-2024, 03:28 PM
Post: #5
RE: LIN-BAIRSTOW ALGORITHM for HP67/97
Thanks so much Thomas!!!!
Find all posts by this user
Quote this message in a reply
08-14-2024, 05:29 PM
Post: #6
RE: LIN-BAIRSTOW ALGORITHM for HP67/97
Let me add a few notes:
  • The program is based on the similar program for the HP-11C.
  • As I'm not that familiar with the HP-67, there may be room for improvements.
  • With \(10\) secondary registers, polynomials up to degree \(n = 9\) can be solved.
  • However, this can easily be extended to \(n = 14\) by using registers A-E.
  • As registers 8 and 9 are not used, we could start with register 8 instead of register 10.
  • This means the maximum degree is \(n = 16\).
  • For this to work, some minor code changes are required.
  • However, entering the coefficients becomes cumbersome, so I don't think it's generally worth it.
  • The listing can be used with this online HP-67 emulator.
  • The program is slow, so you have plenty of time watching the blinkenlicht.
Here is the data for the emulator from the example above:
Code:
DATA
26
00: 15
01: 1
02: 1
03: 0
04: 0
05: 0
06: 0
07: 0
08: 0
09: 0
10: 2
11: -9
12: 15
13: 65
14: -267
15: 234
16: 0
17: 0
18: 0
19: 0
20: 0
21: 0
22: 0
23: 0
24: 0
25: 0
Find all posts by this user
Quote this message in a reply
08-14-2024, 09:35 PM
Post: #7
RE: LIN-BAIRSTOW ALGORITHM for HP67/97
Thank's Thomas
Paolo
Find all posts by this user
Quote this message in a reply
Post Reply 




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