\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 -3.215444035007023 \cdot 10^{+149}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq -6.380181084755399 \cdot 10^{-238}:\\
\;\;\;\;\frac{\sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 1.0477879590735767 \cdot 10^{+99}:\\
\;\;\;\;\frac{c \cdot -2}{b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\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 -3.215444035007023e+149)
(/ (- b) a)
(if (<= b -6.380181084755399e-238)
(/ (- (sqrt (+ (* b b) (* a (* c -4.0)))) b) (* a 2.0))
(if (<= b 1.0477879590735767e+99)
(/ (* c -2.0) (+ b (sqrt (- (* b b) (* 4.0 (* a c))))))
(- (/ 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 <= -3.215444035007023e+149) {
tmp = -b / a;
} else if (b <= -6.380181084755399e-238) {
tmp = (sqrt((b * b) + (a * (c * -4.0))) - b) / (a * 2.0);
} else if (b <= 1.0477879590735767e+99) {
tmp = (c * -2.0) / (b + sqrt((b * b) - (4.0 * (a * c))));
} else {
tmp = -(c / b);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.6 |
|---|---|
| Target | 20.7 |
| Herbie | 6.7 |
if b < -3.21544403500702319e149Initial program 61.9
Simplified61.9
Taylor expanded around -inf 3.1
Simplified3.1
if -3.21544403500702319e149 < b < -6.38018108475539851e-238Initial program 7.2
Simplified7.2
rmApplied sub-neg_binary647.2
Simplified7.2
if -6.38018108475539851e-238 < b < 1.0477879590735767e99Initial program 30.8
Simplified30.8
rmApplied sub-neg_binary6430.8
Simplified30.8
rmApplied flip--_binary6430.9
Simplified16.6
Simplified16.6
rmApplied div-inv_binary6416.6
Applied times-frac_binary6415.8
Simplified10.2
Simplified10.2
rmApplied associate-*r/_binary6410.1
Simplified10.1
if 1.0477879590735767e99 < b Initial program 59.2
Simplified59.2
Taylor expanded around inf 2.4
Simplified2.4
Final simplification6.7
herbie shell --seed 2021118
(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)))