\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 -1.866959106508209 \cdot 10^{-6}:\\
\;\;\;\;\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{-1.5 \cdot \frac{\sqrt{a}}{\sqrt[3]{1} \cdot \sqrt[3]{1}}}{\frac{3 \cdot a}{\frac{c}{\sqrt{b}}}} \cdot \frac{\frac{\sqrt{a} \cdot 1}{\sqrt[3]{1}}}{\sqrt{b}}\\
\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 temp;
if ((((-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)) <= -1.8669591065082085e-06)) {
temp = ((fma(b, b, -((b * b) - ((3.0 * a) * c))) / (-b - sqrt(((b * b) - ((3.0 * a) * c))))) / (3.0 * a));
} else {
temp = (((-1.5 * (sqrt(a) / (cbrt(1.0) * cbrt(1.0)))) / ((3.0 * a) / (c / sqrt(b)))) * (((sqrt(a) * 1.0) / cbrt(1.0)) / sqrt(b)));
}
return temp;
}



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)) < -1.8669591065082085e-06Initial program 17.7
rmApplied flip-+17.7
Simplified16.9
if -1.8669591065082085e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)) Initial program 41.4
Taylor expanded around inf 12.4
rmApplied *-un-lft-identity12.4
Applied *-un-lft-identity12.4
Applied associate-*r*12.4
Applied times-frac12.4
Applied associate-*r*12.3
Applied associate-/l*12.3
rmApplied add-sqr-sqrt12.4
Applied associate-/r*12.5
Applied associate-/r/12.5
Applied add-cube-cbrt12.5
Applied add-sqr-sqrt12.6
Applied associate-*l*12.6
Applied times-frac12.6
Applied associate-*r*12.6
Applied times-frac12.6
Final simplification15.0
herbie shell --seed 2020066 +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)))