HP Forums

Full Version: Casio FX-115MS bug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Tried solving a cubic using Casio FX-115MS:

1295/24 X³ - 1295/12 X² - 37/2 X + 0.248048 = 0

The calculator just crashed, with weird blinking random pixels ...

Same cubic, but scaled, avoided the crash:

f(X) = 1295 X³ - 2590 X² - 444 X + 5.953152 = 0

--> 3 roots = 2.157897584, -0.170399539, 0.012501955

Update: see my Kahan cubic solver post

k = -B/(3A) = 2590/(3*1295) = 2/3
f(k)/A = -0.816567 = -0.934682³
f'(k)/A = -1.67619 = -1.29468² < 0
guess = k - 1.324718 (-1) max(0.934682, 1.29468) = 2.38175
Newton: 2.38175 → 2.19240 → 2.15892 → 2.15790 → x = 2.157897584

Deflate cubic to quadratic: A X² + E X + F = 0
IF |x³| > |D/A| THEN (F=-D/x, E=(F-C)/x) ELSE (E=Ax+B, F=Ex+C)

Above example, it is the THEN case.
1295 X² + 204.4773715 X − 2.758774116 = 0 ⇒ roots = 0.01250195572, -0.1703995399
Post this problem on forum dedicated to casio
https://community.casiocalc.org
(10-31-2018 07:02 PM)Albert Chan Wrote: [ -> ]Tried solving a cubic using Casio FX-115MS:

1295/24 X³ - 1295/12 X² - 37/2 X + 0.248048 = 0

The calculator just crashed, with weird blinking random pixels ...

I got the same thing the first time I tried it. For the second time I tried it, it just blanked the screen for a couple of seconds, gave up, and went back to displaying the "a?" prompt!
Interestingly, On a Casio FX-115ES Plus, the correct roots are obtained whether the coefficients are scaled or not
The bug only shows if coefficient(s) were entered as an expression.
It were the excess precision internal digits that tripped the solver.

My guess is the algorithm assumed user entered a,b,c,d as numbers.
Even if user entered more digits than calculator can handle, it only keep (truncated) 10 sig. digits.

Example: 123.456789999 [=] [Ans] - 123, we only get back 0.4567899
Crashing Casio FX-115MS with only a 7 Big Grin

X³/7 + X²/7 - 7X + 7 = 0

Also can crash with other number instead of 7: 12, 13, 17, 18, 19, 21, 22 ...
Even if no crashing, the results are not very good.

if X = 100, X³ + X = 1000100

Solve X³ + X - 1000100 = 0 for X, should get back 100

Cubic solver gives back 100.0033332 ?

I thought maybe it is due to rounding errors, trying to deflate cubic to quadratic.
But, no. X = 100 is the only real root, the rest are complex: 50 ± √(7501) i

The equation were *already* a depressed cubic, with r = 1/3, s = -1000100/2
From Thomas Klemm cubic formula thread, using the same calculator (to be fair):

X = -2 √(r) sinh(1/3 * asinh(s/r^1.5)) = 100

Do this another way, with X = u - r/u, where u³ = -(s + sign(s) √(s² + r³))
With r this small, and s negative, u³ ~ -2s = 1000100

u ~ 100.0033332
X = u - r/u = 100

Edit: if discriminant s² + r³ < 0, X = u - r/u imaginary part cancelled out:

θ = acos(-s/(-r)^1.5) / 3
k = 2√(-r)
X = k*cos(θ), k*cos(θ + 120°), k*cos(θ + 240°), all real roots
I have 2 questions
1. Why do you expect the exact result? Generally the solving doesn't provide the exact result.
2. Why the result 100.0033332 isn't good? The difference is 0,003 (0,003%) only, according to me it is perfect result. Generally the deviation 3 - 5 % is a good results. At least for engineers.
Hi, klesl

I don't expect exact result. But the result seems not due to rounding errors.
Relative errors of 0.003% is not the upper bound. Try this:

X³ + 11 X - 1000100 = 0

Cubic Solver still returned real root of 100.0033332

For above cubic, u is still about 100.0033332, but r is now 11/3

X = u - r/u = 99.96666778, so Solver result only have 3 good digits.

If it is a generalized solver, maybe 3 or 4 good digits is enough.
But, this is a specialized Cubic Solver, with known formula for it.

Even worse case may be possible (example, by adding X² term)

Update: Let Y = X - 100, hoping for better luck:

Y³ + 300 Y² + 30011 Y + 1000 = 0

Expecting Y correction of -0.03333222. Instead, I got +0.003333223
Cubic Solver get the sign wrong ! (Relative error of 110% !)
Solving roots reciprocal, with coefficients in reversed order :

X³ + 11 X - 1000100 = 0

Let x = 100/X, above turns to -1.0001 x³ + 0.0011 x² + 1 = 0
Cubic Solver get x = 1.000333299, X = 100/x = 99.96668121

Doing the same for Y=X-100, y=1/Y, solved X is even better:
Y³ + 300 Y² + 30011 Y + 1000 = 0 => 1000 y³ + 30011 y² + 300 y + 1 = 0
Cubic Solver get y = -30.00100144, X = 100 + 1/y = 99.96666778

Of course, since Y ~ 0, we could just iterate Y = (Y³ + 300 Y² + 1000) ÷ -30011
We have Y = 0 -> -0.033321115 -> -0.033332213 -> -0.03333222 (converged)
X = 100 + Y = 99.96666778
(11-07-2018 08:15 PM)Albert Chan Wrote: [ -> ]The equation were *already* a depressed cubic, with r = 1/3, s = -1000100/2 ...
Do this another way, with X = u - r/u, where u³ = -(s + sign(s) √(s² + r³))
With r this small, and s negative, u³ ~ -2s = 1000100

u ~ 100.0033332
X = u - r/u = 100

I think I figured out the reason for loss of precision.
Instead of using above formula, it uses this:

X³ + (3r)X + (2s) = 0

X = ³√(-s + √(s² + r³)) + ³√(-s - √(s² + r³))

Above example, subtraction cancellation dropped the last term, we get X ~ u + 0 = u

Comment on previous posts:

Post #9: Y = X-100 had no effect, because Cubic Solver revert it back to depressed cubic.

Post #10: root reciprocal suffer less rounding errors because dropped term are smaller.
x = 0.00036663 (shift to depress cubic) + 0.9999666689 + 0.0000001344 (dropped) = 1.000333299
Solving cubic with hyperbolic sine formula, discovered Casio FX-115MS asinh bug
(asinh bug also hit my Casio FX-3650P ...)

Solve X³ + 11 X - 1000100 = 0 for X, using formula X = -2 √(r) sinh(1/3 * asinh(s/r^1.5))

asinh(s/r^1.5)) = asinh(-500050/(11/3)^1.5) = asinh(-71220.70789) = -11.86817286 ???

Even my pocket Casio FX-260Solar get this right, asinh(-71220.70789) = -11.86668608

My guess the problem is the Quadratic Solver subtraction cancellation.

Solving asinh(x) = (exp(x) - 1/exp(x))/2 = -71220.70789, solver gives exp(x) = 7.01e-6
x = ln(7.01e-6) = -11.86817286 (same as the produced bug)

As a temporary fix, force asinh to use big root:

asinh(x) = sign(x) * asinh(|x|)
asinh(-71220.70789) = -1 * asinh(+71220.70789) = -11.86668608
(11-24-2018 07:25 PM)Albert Chan Wrote: [ -> ]Solving cubic with hyperbolic sine formula, discovered Casio FX-115MS asinh bug
(asinh bug also hit my Casio FX-3650P ...)

Solve X³ + 11 X - 1000100 = 0 for X, using formula X = -2 √(r) sinh(1/3 * asinh(s/r^1.5))

asinh(s/r^1.5)) = asinh(-500050/(11/3)^1.5) = asinh(-71220.70789) = -11.86817286 ???

Even my pocket Casio FX-260Solar get this right, asinh(-71220.70789) = -11.86668608

Even the TI-35X and TI-36X SOLAR manage to get this one correct, although this parameter is too large to be affected by the Texas Instruments Logarithm Bug. (They are nice calculators, especially the versions with the rubber keys, but it's a shame about this bug.)
Both my 9750G+ and GII gets it "right", but the two FX-82s (TL/MS) don't. Interestingly, the Canon F-804P gets it right. I'm puzzled as to why the two calculators dating to 2000-ish are getting it wrong.

(Post 319)
Reference URL's