\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\begin{array}{l}
\mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -3.4228789922799377 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot -1.5}{3} \cdot \frac{\frac{c}{b}}{a}\\
\end{array}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 VAR;
if ((((-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)) <= -3.4228789922799377e-07)) {
VAR = ((fma(b, b, -((b * b) - ((3.0 * a) * c))) / (-b - sqrt(((b * b) - ((3.0 * a) * c))))) / (3.0 * a));
} else {
VAR = (((a * -1.5) / 3.0) * ((c / b) / a));
}
return VAR;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)) < -3.4228789922799377e-07Initial program 18.4
rmApplied flip-+18.4
Simplified17.6
if -3.4228789922799377e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)) Initial program 44.0
Taylor expanded around inf 10.6
rmApplied *-un-lft-identity10.6
Applied times-frac10.5
Applied associate-*r*10.4
Simplified10.4
rmApplied times-frac10.4
Final simplification14.8
herbie shell --seed 2020103 +o rules:numerics
(FPCore (a b c)
:name "Cubic critical, narrow range"
:precision binary64
:pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))