\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\begin{array}{l}
t_0 := \frac{b}{a \cdot 2}\\
\mathbf{if}\;b \leq -9.578396010459488 \cdot 10^{+102}:\\
\;\;\;\;\left(\frac{c}{b} + \frac{b}{a} \cdot -0.5\right) - t_0\\
\mathbf{elif}\;b \leq 3.2185716802555982 \cdot 10^{-80}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2} - t_0\\
\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
(let* ((t_0 (/ b (* a 2.0))))
(if (<= b -9.578396010459488e+102)
(- (+ (/ c b) (* (/ b a) -0.5)) t_0)
(if (<= b 3.2185716802555982e-80)
(- (/ (sqrt (- (* b b) (* 4.0 (* c a)))) (* a 2.0)) t_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 t_0 = b / (a * 2.0);
double tmp;
if (b <= -9.578396010459488e+102) {
tmp = ((c / b) + ((b / a) * -0.5)) - t_0;
} else if (b <= 3.2185716802555982e-80) {
tmp = (sqrt((b * b) - (4.0 * (c * a))) / (a * 2.0)) - t_0;
} else {
tmp = -(c / b);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.1 |
|---|---|
| Target | 20.9 |
| Herbie | 10.0 |
if b < -9.5783960104594883e102Initial program 47.6
Simplified47.6
rmApplied div-sub_binary6447.6
Simplified47.6
Taylor expanded around -inf 3.6
Simplified3.6
if -9.5783960104594883e102 < b < 3.21857168025559822e-80Initial program 12.5
Simplified12.5
rmApplied div-sub_binary6412.5
Simplified12.5
if 3.21857168025559822e-80 < b Initial program 52.6
Simplified52.6
Taylor expanded around inf 9.6
Simplified9.6
Final simplification10.0
herbie shell --seed 2021207
(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)))