\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq 1.437284399471815:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right) + \mathsf{fma}\left(-c, 4 \cdot a, c \cdot \left(4 \cdot a\right)\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(2, \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}}, \mathsf{fma}\left(5, \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}}, \frac{c}{b} + \frac{c \cdot \left(c \cdot a\right)}{{b}^{3}}\right)\right)\\
\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 1.437284399471815)
(/
(-
(sqrt
(+ (fma b b (* c (* a -4.0))) (fma (- c) (* 4.0 a) (* c (* 4.0 a)))))
b)
(* a 2.0))
(-
(fma
2.0
(/ (* (* a a) (pow c 3.0)) (pow b 5.0))
(fma
5.0
(/ (* (pow a 3.0) (pow c 4.0)) (pow b 7.0))
(+ (/ c b) (/ (* c (* c a)) (pow b 3.0))))))))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 <= 1.437284399471815) {
tmp = (sqrt(fma(b, b, (c * (a * -4.0))) + fma(-c, (4.0 * a), (c * (4.0 * a)))) - b) / (a * 2.0);
} else {
tmp = -fma(2.0, (((a * a) * pow(c, 3.0)) / pow(b, 5.0)), fma(5.0, ((pow(a, 3.0) * pow(c, 4.0)) / pow(b, 7.0)), ((c / b) + ((c * (c * a)) / pow(b, 3.0)))));
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus c
if b < 1.43728439947181497Initial program 12.0
Applied prod-diff_binary6411.9
if 1.43728439947181497 < b Initial program 31.5
Taylor expanded in b around inf 4.4
Simplified4.4
Final simplification5.6
herbie shell --seed 2022077
(FPCore (a b c)
:name "Quadratic roots, narrow range"
:precision binary64
:pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))