Post Reply 
(SR-56) Programmieren mit dem Taschenrechner SR-56
09-16-2024, 07:15 PM (This post was last modified: 09-16-2024 09:09 PM by Thomas Klemm.)
Post: #11
RE: (SR-56) Programmieren mit dem Taschenrechner SR-56
Cubic equation \(x^3 + ax^2 + bx + c = 0\)

A real root is calculated using Newton's approximation method.
Then the roots \(x_2\) and \(x_3\) are calculated from the quadratic equation \(x^2 + px + x = 0\) with \(p = a + x_1\) and \(q = x_1^2 + a x_1 + b\).

This is a translation of the program on page 108 for the HP-25:
Code:
01: 24 00    : RCL 0        ; x_i
02: 14 74    : f PAUSE      ; >>> x_i <<<
03: 24 01    : RCL 1        ; a
04: 51       : +            ; a+x_i
05: 23 04    : STO 4        ; R4 = a+x_i
06: 24 00    : RCL 0        ; x_i
07: 61       : *            ; x_i*(a+x_i)
08: 23 07    : STO 7        ; R7 = x_i*(a+x_i)
09: 24 02    : RCL 2        ; b
10: 51       : +            ; x_i*(a+x_i)+b
11: 23 05    : STO 5        ; R5 = x_i*(a+x_i)+b
12: 24 00    : RCL 0        ; x_i
13: 61       : *            ; x_i*(x_i*(a+x_i)+b)
14: 24 03    : RCL 3        ; c
15: 51       : +            ; x_i*(x_i*(a+x_i)+b)+c = f(x_i)
16: 24 07    : RCL 7        ; x_i*(a+x_i)
17: 24 00    : RCL 0        ; x_i
18: 15 02    : g x^2        ; x_i^2
19: 51       : +            ; 2x_i^2+ax_i
20: 24 05    : RCL 5        ; x_i*(a+x_i)+b
21: 51       : +            ; 3x_i^2+2ax_i+b = f'(x_i)
22: 71       : /            ; Δx = f(x_i)/f'(x_i)
23: 23 41 00 : STO - 0      ; x_{i+1} = x_i - Δx
24: 15 03    : g ABS        ; |Δx|
25: 24 06    : RCL 6        ; ε
26: 14 41    : f x<y        ; ε < |Δx|
27: 13 01    : GTO 01       ; not enough
28: 24 00    : RCL 0        ; x_1
29: 74       : R/S          ; === x_1 ===
30: 24 04    : RCL 4        ; p = a+x_1
31: 02       : 2            ; 2     p
32: 71       : /            ; p/2
33: 32       : CHS          ; -p/2
34: 31       : ENTER        ; -p/2   -p/2
35: 31       : ENTER        ; -p/2   -p/2     -p/2
36: 15 02    : g x^2        ; p^2/4  -p/2     -p/2
37: 24 05    : RCL 5        ; q = x_i*(a+x_i)+b p^2/4   -p/2    -p/2
38: 41       : -            ; D = p^2/4 - q     -p/2    -p/2    -p/2
39: 15 51    : g x>=0       ; D >= 0
40: 13 45    : GTO 45       ; 2 real roots
41: 32       : CHS          ; -D    -p/2    -p/2    -p/2
42: 14 02    : f SQRT       ; Im z_{2,3} = √-D
43: 21       : x<->y        ; Re z_{2,3} = -p/2
44: 13 00    : GTO 00       ; === z_{2,3} ===
45: 14 02    : f SQRT       ; √D  -p/2    -p/2    -p/2
46: 41       : -            ; x_3 = -p/2 - √D     -p/2
47: 21       : x<->y        ; -p/2      x_3
48: 14 73    : f LASTx      ; √D        -p/2      x_3
49: 51       : +            ; x_2 = -p/2 + √D     x_3

Examples

Set degree of accuracy:

EEX -6 STO 6



\(x^3 -19x^2 + 81x + 101 = 0\)
\(x_0 = 1\)

1 STO 0
-19 STO 1
81 STO 2
101 STO 3

f CLEAR PRGM
R/S

-1.000000000

R/S

10.00000000

x<->y

1.000000000

\(
\begin{align}
x_1 &= -1 \\
x_2 &= 10 + i \\
x_3 &= 10 - i \\
\end{align}
\)



\(x^3 -13x^2 + 20x + 100 = 0\)
\(x_0 = 2\)

2 STO 0
-13 STO 1
20 STO 2
100 STO 3

f CLEAR PRGM
R/S

5.000000000

R/S

10.00000000

x<->y

-1.999999999

\(
\begin{align}
x_1 &= 5 \\
x_2 &= 10 \\
x_3 &= -2 \\
\end{align}
\)



It is interesting that we can squeeze the 86 unmerged steps of the SR-56 into the 49 maximum steps of the HP-25.
It seems to me that the quality of these programs is better than that of the Applications Library.
For examples, compare "Greatest Common Divisor/Least Common Multiple" with "Größter gemeinsamer Teiler und kleinstes gemeinsames Vielfaches".
Or then "First Order Differential Equations" with "Runge-Kutta-Verfahren für Differentialgleichungen 1. Ordnung": the latter uses 4th order while the former uses only 3rd order.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (SR-56) Programmieren mit dem Taschenrechner SR-56 - Thomas Klemm - 09-16-2024 07:15 PM



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