\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 -3.877652638047906 \cdot 10^{+139}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666\\
\mathbf{elif}\;b \leq 4.889920063260302 \cdot 10^{-55}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5 + \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}} \cdot -0.375\\
\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 -3.877652638047906e+139)
(- (* 0.5 (/ c b)) (* (/ b a) 0.6666666666666666))
(if (<= b 4.889920063260302e-55)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(+ (* (/ c b) -0.5) (* (/ (* a (* c c)) (pow b 3.0)) -0.375)))))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 <= -3.877652638047906e+139) {
tmp = (0.5 * (c / b)) - ((b / a) * 0.6666666666666666);
} else if (b <= 4.889920063260302e-55) {
tmp = (sqrt((b * b) - (c * (a * 3.0))) - b) / (a * 3.0);
} else {
tmp = ((c / b) * -0.5) + (((a * (c * c)) / pow(b, 3.0)) * -0.375);
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
Results
if b < -3.877652638047906e139Initial program 59.1
Simplified59.1
Taylor expanded around -inf 2.8
Simplified2.8
if -3.877652638047906e139 < b < 4.8899200632603017e-55Initial program 12.7
if 4.8899200632603017e-55 < b Initial program 53.7
Simplified53.7
Taylor expanded around inf 19.8
Simplified19.8
Final simplification14.2
herbie shell --seed 2020339
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))