\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq -5.1650230199605083 \cdot 10^{+76}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\mathbf{elif}\;b \leq 1.6513411710612578 \cdot 10^{-261}:\\
\;\;\;\;\frac{\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{2}}{a}\\
\mathbf{elif}\;b \leq 2.0607811355006304 \cdot 10^{+52}:\\
\;\;\;\;\frac{-2 \cdot c}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(FPCore (a b c)
:precision binary64
(if (<= b -5.1650230199605083e+76)
(/ (* b -2.0) (* 2.0 a))
(if (<= b 1.6513411710612578e-261)
(/ (/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) 2.0) a)
(if (<= b 2.0607811355006304e+52)
(/ (* -2.0 c) (+ b (sqrt (fma a (* c -4.0) (* b b)))))
(- (/ c b))))))double code(double a, double b, double c) {
return (-b + sqrt((b * b) - (4.0 * (a * c)))) / (2.0 * a);
}
double code(double a, double b, double c) {
double tmp;
if (b <= -5.1650230199605083e+76) {
tmp = (b * -2.0) / (2.0 * a);
} else if (b <= 1.6513411710612578e-261) {
tmp = ((sqrt((b * b) - (4.0 * (a * c))) - b) / 2.0) / a;
} else if (b <= 2.0607811355006304e+52) {
tmp = (-2.0 * c) / (b + sqrt(fma(a, (c * -4.0), (b * b))));
} else {
tmp = -(c / b);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 34.5 |
|---|---|
| Target | 20.9 |
| Herbie | 7.3 |
if b < -5.1650230199605083e76Initial program 42.8
Taylor expanded in b around -inf 5.6
if -5.1650230199605083e76 < b < 1.6513411710612578e-261Initial program 10.3
Applied associate-/r*_binary6410.3
if 1.6513411710612578e-261 < b < 2.06078113550063e52Initial program 32.6
Simplified32.6
Applied flip--_binary6432.6
Applied associate-*l/_binary6432.7
Simplified17.5
Taylor expanded in a around 0 8.6
if 2.06078113550063e52 < b Initial program 57.2
Taylor expanded in b around inf 3.9
Simplified3.9
Final simplification7.3
herbie shell --seed 2021329
(FPCore (a b c)
:name "quadp (p42, positive)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))))
(/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))