\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 -1.747572511563342 \cdot 10^{+134}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := c \cdot \left(a \cdot -4\right)\\
\mathbf{if}\;b \leq 3.9562943804830147 \cdot 10^{-153}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, t_0\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 2.3361535024269667 \cdot 10^{+101}:\\
\;\;\;\;\frac{t_0 \cdot \frac{0.5}{a}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\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.747572511563342e+134)
(- (/ c b) (/ b a))
(let* ((t_0 (* c (* a -4.0))))
(if (<= b 3.9562943804830147e-153)
(/ (- (sqrt (fma b b t_0)) b) (* a 2.0))
(if (<= b 2.3361535024269667e+101)
(/ (* t_0 (/ 0.5 a)) (+ 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 <= -1.747572511563342e+134) {
tmp = (c / b) - (b / a);
} else {
double t_0 = c * (a * -4.0);
double tmp_1;
if (b <= 3.9562943804830147e-153) {
tmp_1 = (sqrt(fma(b, b, t_0)) - b) / (a * 2.0);
} else if (b <= 2.3361535024269667e+101) {
tmp_1 = (t_0 * (0.5 / a)) / (b + sqrt(fma(a, (c * -4.0), (b * b))));
} else {
tmp_1 = -(c / b);
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 33.8 |
|---|---|
| Target | 20.8 |
| Herbie | 9.1 |
if b < -1.74757251156334196e134Initial program 55.4
Taylor expanded in b around -inf 3.1
if -1.74757251156334196e134 < b < 3.9562943804830147e-153Initial program 11.1
Applied fma-neg_binary6411.1
Simplified11.0
if 3.9562943804830147e-153 < b < 2.3361535024269667e101Initial program 39.2
Simplified39.2
Applied flip--_binary6439.2
Applied associate-*l/_binary6439.3
Simplified16.0
if 2.3361535024269667e101 < b Initial program 59.3
Taylor expanded in b around inf 2.5
Simplified2.5
Final simplification9.1
herbie shell --seed 2022097
(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)))