\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.587685883918172 \cdot 10^{+93}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq -2.647768469823155 \cdot 10^{-306}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 5.425482410905856 \cdot 10^{+139}:\\
\;\;\;\;-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 -2.587685883918172e+93)
(- (/ c b) (/ b a))
(if (<= b -2.647768469823155e-306)
(/ (- (sqrt (- (* b b) (* 4.0 (* c a)))) b) (* a 2.0))
(if (<= b 5.425482410905856e+139)
(* -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 <= -2.587685883918172e+93) {
tmp = (c / b) - (b / a);
} else if (b <= -2.647768469823155e-306) {
tmp = (sqrt((b * b) - (4.0 * (c * a))) - b) / (a * 2.0);
} else if (b <= 5.425482410905856e+139) {
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 | 33.5 |
|---|---|
| Target | 20.7 |
| Herbie | 6.5 |
if b < -2.5876858839181722e93Initial program 45.8
Simplified45.8
Taylor expanded around -inf 4.1
if -2.5876858839181722e93 < b < -2.64776846982315499e-306Initial program 8.9
if -2.64776846982315499e-306 < b < 5.4254824109058555e139Initial program 33.5
Simplified33.5
rmApplied flip--_binary64_5333.5
Simplified15.7
Simplified15.7
rmApplied *-un-lft-identity_binary64_7815.7
Applied times-frac_binary64_8413.5
Applied times-frac_binary64_848.2
Simplified8.2
Simplified8.2
if 5.4254824109058555e139 < b Initial program 62.1
Simplified62.1
Taylor expanded around inf 1.4
Simplified1.4
Final simplification6.5
herbie shell --seed 2020354
(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)))