\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 -2.927344967182997 \cdot 10^{+61}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.0256547290587156 \cdot 10^{-73}:\\
\;\;\;\;\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\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 -2.927344967182997e+61)
(- (* 0.5 (/ c b)) (* 0.6666666666666666 (/ b a)))
(if (<= b 1.0256547290587156e-73)
(/ (/ (- (sqrt (- (* b b) (* 3.0 (* c a)))) 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 <= -2.927344967182997e+61) {
tmp = (0.5 * (c / b)) - (0.6666666666666666 * (b / a));
} else if (b <= 1.0256547290587156e-73) {
tmp = ((sqrt((b * b) - (3.0 * (c * a))) - 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 < -2.9273449671829972e61Initial program 41.0
Simplified41.0
Taylor expanded around -inf 5.2
if -2.9273449671829972e61 < b < 1.0256547290587156e-73Initial program 13.7
Simplified13.7
rmApplied associate-/r*_binary64_479613.8
Simplified13.8
if 1.0256547290587156e-73 < b Initial program 53.7
Simplified53.7
Taylor expanded around inf 8.9
Final simplification10.2
herbie shell --seed 2021023
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))