(11C) CUBIC EQUATION
06-09-2018, 11:49 AM (This post was last modified: 06-11-2018 08:32 AM by Gamo.)
Post: #1
 Gamo Senior Member Posts: 747 Joined: Dec 2016
(11C) CUBIC EQUATION
This program finds the roots of cubic equation of the form

f(x) = X^3 + aX^2 + bX + c

where a, b and c are real.

It does so by extracting the first root, performing synthetic division,
and solving the resulting quadratic equation.

(This program was from HP-19C/HP-29C Applications Book, P.6 and here is the modified version for HP-11C)

Program: CUBIC EQUATION
Code:

LBL A
STO 1
Rv
STO 2
Rv
STO 3
EEX
CHS
4
STO 0
CLx
STO 4
RTN
-----------------------------------------------------------
LBL B
RCL 3
RCL 3
ABS
÷
STO 6
LSTx
RCL 1
ABS
+
RCL 0
-----------------------------------------------------------------------
LBL 0
10
x
X≤Y
GTO 0
STO 7
-------------------------------------------------------------------------
LBL 2
10
STO÷7
RCL 6
CHS
STO 6
------------------------------------------------------------------------
LBL 1
RCL 7
RCL 6
x
RCL 4
+
STO 5
RCL 4
X=Y
GTO 3
RCL 5
RCL 1
+
RCL 5
x
RCL 2
+
RCL 5
x
RCL 3
+
STO 8
ABS
RCL 0
X˃Y
GTO 3
RCL 5
STO 4
RCL 8
RCL 6
x
X˂0
GTO 1
GTO 2
-----------------------------------------------------------------------
LBL 3
RCL 5
R/S
RCL 1
+
CHS
STO 1
2
÷
ENTER
X^2
RCL 1
CHS
RCL 5
x
RCL 2
+
STO 3
-
R/S
√X
X<>Y
ABS
+
RCL 1
ENTER
ABS
÷
x
R/S
RCL 3
X<>Y
÷
RTN
--------------------------------------------------------------------------
LBL C   //  Complex Roots
CHS
√X
R/S

Usage:
c [ENTER] b [ENTER] a

[A] ---> 0
[B] ---> 1st Root

[R/S] ---> Discriminant // If D≥0 continue [R/S] [R/S] If D˂0 continue to [C]

[R/S] ---> 2nd Root
[R/S] ---> 3nd Root

[C] ---> Complex Roots // [X<>Y] (u in Y) and (v in X)

Put to USER MODE --> f USER

Example: X^3 - 6X^2 + 11X - 6 = 0

6 [CHS] [ENTER] 11 [ENTER] 6 [CHS]

[A] 0
[B] 3 // 1st root
[R/S] 0.25 // D is greater than or equal zero go ahead with R/S
[R/S] 2 // 2nd root
[R/S] 1 // 3th root

Answer of 3 roots are 3, 2 and 1
----------------------------------------------------------------------------------------
Example: X^3 - 4X^2 + 8X - 8 = 0

8 [CHS] [ENTER] 8 [ENTER] 4 [CHS]

[A] 0
[B] 2 // 1st root
[R/S] -3 // D is less than zero then use LBL C for complex roots
[C] 1.73 [X<>Y] 1 // 1.73 (Imaginary Part) and 1 (Real Part)