Post Reply 
Quadratic Solver for Casio FX-3650P
07-17-2018, 10:52 PM (This post was last modified: 11-21-2018 04:43 PM by Albert Chan.)
Post: #2
RE: Quadratic Solver for Casio FX-3650P
Looks like solving quadratic equation accurately is harder than it look ...

Thomas Klemm article about solving quadratic equation is educational
http://www.hpmuseum.org/forum/thread-2181.html

Because FX-3650P does not have a ABS function, I had rearranged equation to produce the "bigger" root.

(-B +/- SQRT(B^2 - 4AC)) / (2A) = -B/(2A) * (1 +/- SQRT(1 - 4AC/B^2))

Bigger root (ignore sign) = -B/(2A) (1 + SQRT(1 - 4AC/B^2)) = X(1 + SQRT Y)

The problem with above is it may have worse precision for the "discriminant" Y

This is my second attempt (86 keys)

Code:
? -> A : ? -> B : ? -> C : B^2 - 4AC -> D : 
D >= 0 => GOTO 1 : -- real roots branch

-B/2A -> X PAUSE -- this version, return X +/- Y i for complex roots
SQRT -D / 2A -> Y PAUSE  -- Fall thru LBL1 to quit with MATH ERROR

LBL 1: SQRT D -> Y
B >= 0 => GOTO 2 : -Y -> Y : -- make sure B and Y have same sign

LBL2: -(B + Y) / 2A -> X PAUSE -- big root
C / AX -> Y -- small root
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Quadratic Solver for Casio FX-3650P - Albert Chan - 07-17-2018 10:52 PM



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