\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 -2.8122428251785394 \cdot 10^{+127}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.5480753463744248 \cdot 10^{-296}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 1.435883796381114 \cdot 10^{+111}:\\
\;\;\;\;\frac{c \cdot -2}{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\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 -2.8122428251785394e+127)
(- (/ c b) (/ b a))
(if (<= b 1.5480753463744248e-296)
(/ (- (sqrt (- (* b b) (* 4.0 (* c a)))) b) (* a 2.0))
(if (<= b 1.435883796381114e+111)
(/ (* c -2.0) (+ b (sqrt (- (* b b) (* 4.0 (* c a))))))
(- (/ 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 <= -2.8122428251785394e+127) {
tmp = (c / b) - (b / a);
} else if (b <= 1.5480753463744248e-296) {
tmp = (sqrt((b * b) - (4.0 * (c * a))) - b) / (a * 2.0);
} else if (b <= 1.435883796381114e+111) {
tmp = (c * -2.0) / (b + sqrt((b * b) - (4.0 * (c * a))));
} else {
tmp = -(c / b);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.8 |
|---|---|
| Target | 20.9 |
| Herbie | 6.7 |
if b < -2.8122428251785394e127Initial program 53.4
Simplified53.4
Taylor expanded around -inf 2.8
if -2.8122428251785394e127 < b < 1.5480753463744248e-296Initial program 9.5
Simplified9.5
if 1.5480753463744248e-296 < b < 1.43588379638111404e111Initial program 33.2
Simplified33.2
rmApplied flip--_binary6433.3
Simplified15.7
Simplified15.7
rmApplied div-inv_binary6415.8
Applied times-frac_binary6415.0
Simplified8.1
Simplified8.1
rmApplied associate-*r/_binary648.0
Simplified8.0
if 1.43588379638111404e111 < b Initial program 60.9
Simplified60.9
Taylor expanded around inf 2.8
Simplified2.8
Final simplification6.7
herbie shell --seed 2020273
(FPCore (a b c)
:name "quadp (p42, positive)"
:precision binary64
:herbie-expected #f
: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)))