\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\begin{array}{l}
\mathbf{if}\;b \leq -3.1102062341024787 \cdot 10^{+111}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.334233368061974 \cdot 10^{-50}:\\
\;\;\;\;\frac{\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
:precision binary64
(if (<= b -3.1102062341024787e+111)
(- (* 0.5 (/ c b)) (* 0.6666666666666666 (/ b a)))
(if (<= b 7.334233368061974e-50)
(/ (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) 3.0) a)
(* (/ c b) -0.5))))double code(double a, double b, double c) {
return (-b + sqrt((b * b) - ((3.0 * a) * c))) / (3.0 * a);
}
double code(double a, double b, double c) {
double tmp;
if (b <= -3.1102062341024787e+111) {
tmp = (0.5 * (c / b)) - (0.6666666666666666 * (b / a));
} else if (b <= 7.334233368061974e-50) {
tmp = ((sqrt((b * b) - (c * (a * 3.0))) - b) / 3.0) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -3.1102062341024787e111Initial program 50.4
Simplified50.4
Taylor expanded around -inf 3.7
if -3.1102062341024787e111 < b < 7.33423336806197363e-50Initial program 13.3
Simplified13.3
rmApplied associate-/r*_binary64_513713.4
if 7.33423336806197363e-50 < b Initial program 52.9
Simplified52.9
Taylor expanded around inf 8.3
Final simplification10.1
herbie shell --seed 2020342
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))