\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.540932896291113 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\
\mathbf{elif}\;b \leq 4.458754763303836 \cdot 10^{-44}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right) + \mathsf{fma}\left(-c, a \cdot 3, c \cdot \left(a \cdot 3\right)\right)} - 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 -1.540932896291113e+151)
(fma 0.5 (/ c b) (* (/ b a) -0.6666666666666666))
(if (<= b 4.458754763303836e-44)
(/
(-
(sqrt
(+ (fma b b (* c (* a -3.0))) (fma (- c) (* a 3.0) (* c (* 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 <= -1.540932896291113e+151) {
tmp = fma(0.5, (c / b), ((b / a) * -0.6666666666666666));
} else if (b <= 4.458754763303836e-44) {
tmp = (sqrt(fma(b, b, (c * (a * -3.0))) + fma(-c, (a * 3.0), (c * (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
if b < -1.540932896291113e151Initial program 63.1
Taylor expanded in b around -inf 2.2
Simplified2.2
if -1.540932896291113e151 < b < 4.4587547633038359e-44Initial program 13.0
Applied prod-diff_binary6413.0
if 4.4587547633038359e-44 < b Initial program 54.4
Taylor expanded in b around inf 7.1
Final simplification9.6
herbie shell --seed 2022082
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))