07-17-2018, 04:29 PM
Quadratic Solver had been done before, but I wanted accurate roots.
The school taught (-b +/- SQRT(b^2 - 4ac)) / (2a) may have one root that loses precision.
Example: z^2 - (5e9 + 1) z + 5e9 should have roots = 5e9 and 1
But, on my FX-115MS solver, I get roots = 5e9, 1.001 (only 3 digits accurate)
Besides, my FX-3650P does not have a quadratic solver, so here it is: (45 keys)
-- Solve for z: A z^2 + B z + C = 0
-- If real roots, roots saved in X, Y
-- If MATH ERROR (SQRT of negative number), complex roots = X(1 +/- SQRT(Y))
Redo above example, I get roots = 5e9, 1 :-)
Besides accuracy, other benefits of this program:
1. Roots are saved in variable X, Y, keeping internal precision.
-- A, B, C are also saved
2. Because of better precision, complex roots easier to recover its radical form:
-- Example roots of 3 z^2 + 7 z + 10 = 0:
Roots (from above program, recover fraction with FRAC key)
= (-1.166666667)(1 +/- SQRT(-1.448979592))
= (-7/6)(1 +/- SQRT(-71/49))
= -7/6 +/- SQRT(71)/6 i
3. Complex roots is warned with MATH ERROR (sqrt of negative number), roots = X(1 +/- SQRT(Y))
FX-115MS Solver only showed a tiny dot (r<=>i) on the upper right screen.
I only noticed it when both roots look exactly the "same"
Finally, I realized the roots are complex, but have the same real part ...
The school taught (-b +/- SQRT(b^2 - 4ac)) / (2a) may have one root that loses precision.
Example: z^2 - (5e9 + 1) z + 5e9 should have roots = 5e9 and 1
But, on my FX-115MS solver, I get roots = 5e9, 1.001 (only 3 digits accurate)
Besides, my FX-3650P does not have a quadratic solver, so here it is: (45 keys)
-- Solve for z: A z^2 + B z + C = 0
-- If real roots, roots saved in X, Y
-- If MATH ERROR (SQRT of negative number), complex roots = X(1 +/- SQRT(Y))
Code:
? -> A : ? -> B : ? -> C :
-B / 2A -> X :
1 - 4AC / B^2 -> Y :
X + X SQRT Y -> X PAUSE
C / AX -> Y
Redo above example, I get roots = 5e9, 1 :-)
Besides accuracy, other benefits of this program:
1. Roots are saved in variable X, Y, keeping internal precision.
-- A, B, C are also saved
2. Because of better precision, complex roots easier to recover its radical form:
-- Example roots of 3 z^2 + 7 z + 10 = 0:
Roots (from above program, recover fraction with FRAC key)
= (-1.166666667)(1 +/- SQRT(-1.448979592))
= (-7/6)(1 +/- SQRT(-71/49))
= -7/6 +/- SQRT(71)/6 i
3. Complex roots is warned with MATH ERROR (sqrt of negative number), roots = X(1 +/- SQRT(Y))
FX-115MS Solver only showed a tiny dot (r<=>i) on the upper right screen.
I only noticed it when both roots look exactly the "same"
Finally, I realized the roots are complex, but have the same real part ...