\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 -1.8145633063846896 \cdot 10^{+22}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq -1.3734960260801592 \cdot 10^{-159}:\\
\;\;\;\;\frac{\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{2}}{a}\\
\mathbf{elif}\;b \leq 2.4411469808920094 \cdot 10^{+104}:\\
\;\;\;\;\frac{c \cdot -2}{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 -1.8145633063846896e+22)
(- (/ c b) (/ b a))
(if (<= b -1.3734960260801592e-159)
(/ (/ (- (sqrt (- (* b b) (* 4.0 (* c a)))) b) 2.0) a)
(if (<= b 2.4411469808920094e+104)
(/ (* c -2.0) (+ 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 <= -1.8145633063846896e+22) {
tmp = (c / b) - (b / a);
} else if (b <= -1.3734960260801592e-159) {
tmp = ((sqrt((b * b) - (4.0 * (c * a))) - b) / 2.0) / a;
} else if (b <= 2.4411469808920094e+104) {
tmp = (c * -2.0) / (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 | 33.8 |
|---|---|
| Target | 20.2 |
| Herbie | 6.6 |
if b < -1.8145633063846896e22Initial program 34.8
Taylor expanded in b around -inf 6.5
if -1.8145633063846896e22 < b < -1.37349602608015923e-159Initial program 5.5
Applied associate-/r*_binary645.5
if -1.37349602608015923e-159 < b < 2.4411469808920094e104Initial program 28.3
Simplified28.4
Applied flip--_binary6428.7
Applied associate-*l/_binary6428.7
Simplified15.3
Taylor expanded in c around 0 9.5
if 2.4411469808920094e104 < b Initial program 60.0
Taylor expanded in b around inf 2.1
Simplified2.1
Final simplification6.6
herbie shell --seed 2022005
(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)))