\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 -4.100503925456705 \cdot 10^{+152}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.2869100423103602 \cdot 10^{-60}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{a \cdot 3} - \frac{b}{a \cdot 3}\\
\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 -4.100503925456705e+152)
(- (* 0.5 (/ c b)) (* 0.6666666666666666 (/ b a)))
(if (<= b 1.2869100423103602e-60)
(- (/ (sqrt (- (* b b) (* c (* a 3.0)))) (* a 3.0)) (/ b (* a 3.0)))
(* (/ 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 <= -4.100503925456705e+152) {
tmp = (0.5 * (c / b)) - (0.6666666666666666 * (b / a));
} else if (b <= 1.2869100423103602e-60) {
tmp = (sqrt((b * b) - (c * (a * 3.0))) / (a * 3.0)) - (b / (a * 3.0));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -4.1005039254567049e152Initial program 63.4
Simplified63.4
Taylor expanded around -inf 2.6
if -4.1005039254567049e152 < b < 1.28691004231036016e-60Initial program 12.7
Simplified12.7
rmApplied div-sub_binary6412.7
if 1.28691004231036016e-60 < b Initial program 53.5
Simplified53.5
Taylor expanded around inf 9.0
Final simplification10.2
herbie shell --seed 2020233
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))