\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.3199871431635179 \cdot 10^{+153}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := c \cdot \left(a \cdot -4\right)\\
\mathbf{if}\;b \leq -2.07694009677386 \cdot 10^{-291}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, t_0\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 5.718007789643402 \cdot 10^{-35}:\\
\;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \mathsf{hypot}\left(b, \sqrt{t_0}\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.3199871431635179e+153)
(- (/ c b) (/ b a))
(let* ((t_0 (* c (* a -4.0))))
(if (<= b -2.07694009677386e-291)
(/ (- (sqrt (fma b b t_0)) b) (* a 2.0))
(if (<= b 5.718007789643402e-35)
(* 2.0 (/ c (- (- b) (hypot b (sqrt 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 tmp;
if (b <= -1.3199871431635179e+153) {
tmp = (c / b) - (b / a);
} else {
double t_0 = c * (a * -4.0);
double tmp_1;
if (b <= -2.07694009677386e-291) {
tmp_1 = (sqrt(fma(b, b, t_0)) - b) / (a * 2.0);
} else if (b <= 5.718007789643402e-35) {
tmp_1 = 2.0 * (c / (-b - hypot(b, sqrt(t_0))));
} else {
tmp_1 = -(c / b);
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 34.3 |
|---|---|
| Target | 21.0 |
| Herbie | 8.0 |
if b < -1.3199871431635179e153Initial program 63.7
Taylor expanded around -inf 1.6
if -1.3199871431635179e153 < b < -2.0769400967738599e-291Initial program 8.8
rmApplied fma-neg_binary648.8
Simplified8.8
if -2.0769400967738599e-291 < b < 5.71800778964340195e-35Initial program 22.5
rmApplied flip-+_binary6422.6
Simplified16.4
Simplified16.4
rmApplied *-un-lft-identity_binary6416.4
Applied times-frac_binary6416.4
Applied times-frac_binary6416.4
Simplified16.4
Simplified12.6
if 5.71800778964340195e-35 < b Initial program 54.9
Taylor expanded around inf 6.8
Simplified6.8
Final simplification8.0
herbie shell --seed 2021210
(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)))