Post Reply 
(32S) Polynomial Root Finder from 32SII manual
11-20-2024, 01:56 PM (This post was last modified: 11-21-2024 07:10 PM by naddy.)
Post: #1
(32S) Polynomial Root Finder from 32SII manual
The 32SII manual includes a Polynomial Root Finder program that finds the roots of a polynomial of order 2 through 5 with real coefficients. It barely fits the available memory. Can this be adapted to the 32S?

Yes, it can! Fortunately the 32S has six more bytes of user memory, allowing the necessary tweaks.

There are only two small changes required, so I won't list the whole program here, which can be typed in from the 32SII manual. (Note that even without changes the checksums are not compatible between the 32S and 32SII.)

(1) Replace
Code:
S03 250
with
Code:
S03 16
S04 x²

The 32SII can store integers 0..254 in a short 1.5-byte instruction. The 32S only does this for 0..99. The number 250 would take 9.5 bytes, and the program would exceed the available user memory. The number is the initial guess for SOLVE, so the exact value doesn't matter here. 16² = 256 is close enough to 250.

(2) Replace
Code:
Q10 R↑
with
Code:
Q10 R↓
Q11 R↓
Q12 R↓

The 32S simply does not have R↑. Three times R↓ is equivalent.

With those changes, the 32S checksums are:
Code:
LBL P  004.5  CHKSUM=91A0
LBL I  010.5  CHKSUM=6429
LBL H  006.0  CHKSUM=9C94
LBL J  010.5  CHKSUM=9BB4
LBL S  016.5  CHKSUM=DAB9
LBL Q  037.5  CHKSUM=9276
LBL B  006.0  CHKSUM=F0F0
LBL C  010.5  CHKSUM=305E
LBL E  019.5  CHKSUM=3098
LBL D  060.0  CHKSUM=8FA4
LBL F  061.5  CHKSUM=E961
LBL T  003.0  CHKSUM=F81A
LBL N  015.0  CHKSUM=5E7D
LBL U  012.0  CHKSUM=BE7A

When you try the first example \(x^5 - x^4 - 101x^3 + 101x^2 + 100x - 100 = 0\), be aware that the 32S will present the roots in a different order. This is due to SOLVE finding a different root first. I checked, and the implementations of SOLVE on the 15C, 32S, and 32SII all behave slightly differently.

The best calculator is the one you actually use.
Find all posts by this user
Quote this message in a reply
11-21-2024, 11:35 AM
Post: #2
RE: (32S) Polynomial Root Finder from 32SII manual
(11-20-2024 01:56 PM)naddy Wrote:  (1) Replace
Code:
S03 250
with
Code:
S03 16
S04 x²

The 32SII can store integers 0..254 in a short 1.5-byte instruction. The 32S only does this for 0..99. The number 250 would take 9.5 bytes, and the program would exceed the available user memory. The number is the initial guess for SOLVE, so the exact value doesn't matter here. 16² = 256 is close enough to 250.

Very nice !

Quote:When you try the first example \(x^5 - x^4 - 101x^3 + 101x^2 + 100x - 100 = 0\), be aware that the 32S will present the roots in a different order. This is due to SOLVE finding a different root first. I checked, and the implementations of SOLVE on the 15C, 32S, and 32SII all behave slightly differently.

I didn't recall it but indeed the 32SII and 32S SOLVE work differently.
Using the same initial guesses -250 and 250 for the example \(x^5 - x^4 - 101x^3 + 101x^2 + 100x - 100 = 0\), the 32S solver finds the root 10 (exactly) after several iterations, whereas the 32SII finds the root 1 almost immediately (probably by chance), but with a medium accuracy (0.999999998734) due to the multiplicity of this root.
I will comment more on SOLVE differences in an other thread to come.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
11-21-2024, 05:01 PM (This post was last modified: 11-21-2024 05:01 PM by Albert Chan.)
Post: #3
RE: (32S) Polynomial Root Finder from 32SII manual
(11-21-2024 11:35 AM)J-F Garnier Wrote:  Using the same initial guesses -250 and 250 for the example \(x^5 - x^4 - 101x^3 + 101x^2 + 100x - 100 = 0\), the 32S solver finds the root 10 (exactly) after several iterations, whereas the 32SII finds the root 1 almost immediately (probably by chance), but with a medium accuracy (0.999999998734) due to the multiplicity of this root.

The guesses were ±b, where b=256 originally, 250 with this patch.
Guess is so huge, f(±b) ≈ (±b)^5 - (±b)^4 = b^4 * (±b - 1)

--> Secant line is f(x) ≈ b^4 * (x - 1)

f(x) ≈ 0 --> x ≈ 1, which suggested HP 32SII does secant root on 1st try.
Find all posts by this user
Quote this message in a reply
Post Reply 




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