\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.765674528228214 \cdot 10^{+85}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 4.311454940969704 \cdot 10^{-304}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 5.69311637248718 \cdot 10^{+122}:\\
\;\;\;\;\frac{c \cdot -2}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\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.765674528228214e+85)
(- (/ c b) (/ b a))
(if (<= b 4.311454940969704e-304)
(/ (- (sqrt (- (* b b) (* 4.0 (* c a)))) b) (* a 2.0))
(if (<= b 5.69311637248718e+122)
(/ (* c -2.0) (+ b (sqrt (fma a (* c -4.0) (* b b)))))
(- (/ 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.765674528228214e+85) {
tmp = (c / b) - (b / a);
} else if (b <= 4.311454940969704e-304) {
tmp = (sqrt((b * b) - (4.0 * (c * a))) - b) / (a * 2.0);
} else if (b <= 5.69311637248718e+122) {
tmp = (c * -2.0) / (b + sqrt(fma(a, (c * -4.0), (b * b))));
} else {
tmp = -(c / b);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 29.8 |
|---|---|
| Target | 18.3 |
| Herbie | 5.8 |
if b < -3.765674528228214e85Initial program 27.0
Taylor expanded in b around -inf 2.7
if -3.765674528228214e85 < b < 4.31145494096970409e-304Initial program 8.2
Applied pow1_binary648.2
if 4.31145494096970409e-304 < b < 5.69311637248718012e122Initial program 32.7
Simplified32.7
Applied flip--_binary6433.0
Applied associate-*l/_binary6433.0
Simplified14.8
Taylor expanded in a around 0 8.5
if 5.69311637248718012e122 < b Initial program 59.7
Taylor expanded in b around inf 2.1
Simplified2.1
Final simplification5.8
herbie shell --seed 2022068
(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)))