\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 -8.049570799378294 \cdot 10^{+77}:\\
\;\;\;\;\frac{-0.5 \cdot \left(4 \cdot c\right)}{b \cdot 2}\\
\mathbf{elif}\;b \leq 1.0118934187104876 \cdot 10^{-285}:\\
\;\;\;\;-0.5 \cdot \left(4 \cdot \frac{c}{b - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\right)\\
\mathbf{elif}\;b \leq 1.2458172873965611 \cdot 10^{+125}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(2 \cdot \frac{b}{a} - 2 \cdot \frac{c}{b}\right)\\
\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 -8.049570799378294e+77)
(/ (* -0.5 (* 4.0 c)) (* b 2.0))
(if (<= b 1.0118934187104876e-285)
(* -0.5 (* 4.0 (/ c (- b (sqrt (- (* b b) (* 4.0 (* c a))))))))
(if (<= b 1.2458172873965611e+125)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* 2.0 a))
(* -0.5 (- (* 2.0 (/ b a)) (* 2.0 (/ 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 <= -8.049570799378294e+77) {
tmp = (-0.5 * (4.0 * c)) / (b * 2.0);
} else if (b <= 1.0118934187104876e-285) {
tmp = -0.5 * (4.0 * (c / (b - sqrt((b * b) - (4.0 * (c * a))))));
} else if (b <= 1.2458172873965611e+125) {
tmp = (-b - sqrt((b * b) - (4.0 * (c * a)))) / (2.0 * a);
} else {
tmp = -0.5 * ((2.0 * (b / a)) - (2.0 * (c / b)));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.2 |
|---|---|
| Target | 21.3 |
| Herbie | 6.6 |
if b < -8.0495707993782937e77Initial program 58.8
Simplified58.8
rmApplied flip-+_binary6458.8
Simplified31.3
rmApplied *-un-lft-identity_binary6431.3
Applied *-un-lft-identity_binary6431.3
Applied times-frac_binary6431.3
Applied times-frac_binary6431.3
Simplified31.3
Simplified28.6
Taylor expanded around -inf 2.9
Simplified2.9
rmApplied associate-*r/_binary642.9
Applied associate-*r/_binary642.9
Applied associate-*r/_binary642.9
if -8.0495707993782937e77 < b < 1.01189341871048762e-285Initial program 30.6
Simplified30.6
rmApplied flip-+_binary6430.7
Simplified16.4
rmApplied *-un-lft-identity_binary6416.4
Applied *-un-lft-identity_binary6416.4
Applied times-frac_binary6416.4
Applied times-frac_binary6416.4
Simplified16.4
Simplified9.5
if 1.01189341871048762e-285 < b < 1.2458172873965611e125Initial program 8.5
if 1.2458172873965611e125 < b Initial program 54.3
Simplified54.3
Taylor expanded around inf 3.0
Final simplification6.6
herbie shell --seed 2021173
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))