\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 -1.5034552150273902 \cdot 10^{+45}:\\
\;\;\;\;\frac{\left(-b\right) - b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 3.22193770885194 \cdot 10^{-85}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\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 -1.5034552150273902e+45)
(/ (- (- b) b) (* 3.0 a))
(if (<= b 3.22193770885194e-85)
(/ (- (sqrt (fma b b (* c (* a -3.0)))) b) (* 3.0 a))
(* -0.5 (/ c b)))))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 <= -1.5034552150273902e+45) {
tmp = (-b - b) / (3.0 * a);
} else if (b <= 3.22193770885194e-85) {
tmp = (sqrt(fma(b, b, (c * (a * -3.0)))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
if b < -1.5034552150273902e45Initial program 37.8
Taylor expanded in b around -inf 6.0
Simplified6.0
if -1.5034552150273902e45 < b < 3.2219377088519399e-85Initial program 13.6
Applied fma-neg_binary6413.6
Simplified13.6
if 3.2219377088519399e-85 < b Initial program 53.7
Taylor expanded in b around inf 9.2
Final simplification10.4
herbie shell --seed 2021340
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))