\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 -6.97667166683124 \cdot 10^{+151}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.1002458180329022 \cdot 10^{-285}:\\
\;\;\;\;\frac{\sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 6.266607124371804 \cdot 10^{+134}:\\
\;\;\;\;-2 \cdot \frac{c}{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 -6.97667166683124e+151)
(- (/ c b) (/ b a))
(if (<= b 1.1002458180329022e-285)
(/ (- (sqrt (+ (* b b) (* a (* c -4.0)))) b) (* a 2.0))
(if (<= b 6.266607124371804e+134)
(* -2.0 (/ c (+ 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 <= -6.97667166683124e+151) {
tmp = (c / b) - (b / a);
} else if (b <= 1.1002458180329022e-285) {
tmp = (sqrt((b * b) + (a * (c * -4.0))) - b) / (a * 2.0);
} else if (b <= 6.266607124371804e+134) {
tmp = -2.0 * (c / (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 | 34.2 |
|---|---|
| Target | 21.3 |
| Herbie | 6.5 |
if b < -6.97667166683124e151Initial program 62.7
Simplified62.7
Taylor expanded around -inf 1.9
if -6.97667166683124e151 < b < 1.100245818032902e-285Initial program 9.5
Simplified9.5
rmApplied sub-neg_binary64_4129.5
Simplified9.6
if 1.100245818032902e-285 < b < 6.26660712437180398e134Initial program 34.2
Simplified34.2
rmApplied flip--_binary64_39434.2
Simplified15.7
Simplified15.7
rmApplied *-un-lft-identity_binary64_41915.7
Applied times-frac_binary64_42513.4
Applied times-frac_binary64_4257.9
Simplified7.9
Simplified7.9
if 6.26660712437180398e134 < b Initial program 61.7
Simplified61.7
Taylor expanded around inf 1.6
Simplified1.6
Final simplification6.5
herbie shell --seed 2020355
(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)))