Post Reply 
(12C Platinum) Cubic Equation
01-12-2019, 09:27 AM (This post was last modified: 01-12-2019 09:55 AM by Gamo.)
Post: #1
(12C Platinum) Cubic Equation
ALG mode program solution of a Cubic Equation by Newton's Method.

f(x) = aX^3 + bX^2 + cX + d = 0

Successive approximations to a root are found by

Xi+1 = 2aXi^3 + bXi^2 -d / 3aXi^2 + 2bXi + c

Guess X0

------------------------------------------------------

Remark:

This program is use to solve for "REAL ROOT"

-------------------------------------------------------
Procedure:

f PRGM // Each new program or GTO 000

a [R/S] b [R/S] c [R/S] d [R/S] X0 [R/S]

Display shown each successive approximation until root is found.

If more than one Real Solutions enter another guess and [R/S]

Maximum of 3 Real Root.

-------------------------------------------------------
Example:

x^3 - 4x^2 + 6x - 24 = 0

f [PRGM] or [GTO] 000
1 [R/S]
4 [CHS] [R/S]
6 [R/S]
24 [CHS] [R/S]
20 [R/S] // My starting guess
Display successive approximation search and stop when root is found.

Answer Display 4

X=4

---------------------------------------------
-2x^3 + 3x^2 + 4x - 5 = 0

f [PRGM] or [GTO] 000
2 [CHS] [R/S]
3 [R/S]
4 [R/S]
5 [CHS] [R/S]

10 [R/S] ...............display 1.8508
0 [R/S] .................display 1
5 [CHS] [R/S] ..........display -1.3508
-----------------------------------------------
Program: ALG Mode
Code:

STO 0 R/S
STO 1 R/S
STO 2 R/S
STO 3 R/S
STO 4 x 2 x RCL 0 + RCL 1 x RCL 4 X^2 - RCL 3 ÷
(RCL 4 x 3 x RCL 0 + (RCL 1 x 2) x RCL 4 + RCL 2) = 
STO 5 - RCL 4 =
X=0
GTO 049
RCL 5
PSE
GTO 009
RCL 5
GTO 008

Gamo
Find all posts by this user
Quote this message in a reply
01-12-2019, 01:39 PM
Post: #2
RE: (12C Platinum) Cubic Equation
Hi Gamo

It might be better if iteration formula is *not* simplified:

X(i+1)= Xi - (aXi^3 + bXi^2 + cXi + d) / (3aXi^2 + 2bXi + c)

Simplified form may introduce subtraction cancellation error on the *last* iteration.

BTW, Professor Kahan had a systemetic way to get a good guess X0:
https://people.eecs.berkeley.edu/~wkahan.../Cubic.pdf, page 5

Using your examples:

f(x) = x^3 - 4x^2 + 6x - 24
f(4/3) = (-2.7475)³, f'(4/3) = 2/3 ≥ 0
guess = 4/3 - (-2.7475) ~ 4.0809
X = 4.0809 -> 4.0023 -> 4.0000

f(x) = -2x^3 + 3x^2 + 4x - 5
f(1/2)/-2 = (1.0772)³, f'(1/2)/-2 = -(1.6583)² < 0
guess = 1/2 - 1.324718 * max(1.0772, 1.6583) ~ -1.6968
X = -1.6968 -> -1.4145 -> -1.3536 -> -1.3508
Find all posts by this user
Quote this message in a reply
Post Reply 




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