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




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 33.9 |
|---|---|
| Target | 20.9 |
| Herbie | 10.5 |
if b < -3.7381913579193229e116Initial program 51.5
Taylor expanded in b around -inf 4.3
if -3.7381913579193229e116 < b < 1.8003917164795666e-89Initial program 12.4
Applied +-commutative_binary6412.4
Taylor expanded in b around 0 12.4
Simplified12.4
if 1.8003917164795666e-89 < b Initial program 51.9
Taylor expanded in b around inf 10.6
Simplified10.6
Final simplification10.5
herbie shell --seed 2022019
(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)))