\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \le -2.7467723558510264 \cdot 10^{111}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le 8.3119041352151465 \cdot 10^{-94}:\\
\;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}\\
\mathbf{elif}\;b \le 1.1455916387698242 \cdot 10^{-20}:\\
\;\;\;\;\frac{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}} \cdot \sqrt{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\end{array}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 VAR;
if ((b <= -2.7467723558510264e+111)) {
VAR = (1.0 * ((c / b) - (b / a)));
} else {
double VAR_1;
if ((b <= 8.311904135215147e-94)) {
VAR_1 = (1.0 / ((2.0 * a) / (-b + sqrt(((b * b) - (4.0 * (a * c)))))));
} else {
double VAR_2;
if ((b <= 1.1455916387698242e-20)) {
VAR_2 = (((0.0 + (4.0 * (a * c))) / (-b - (sqrt(sqrt(((b * b) - (4.0 * (a * c))))) * sqrt(sqrt(((b * b) - (4.0 * (a * c)))))))) / (2.0 * a));
} else {
VAR_2 = (-1.0 * (c / b));
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 33.7 |
|---|---|
| Target | 20.9 |
| Herbie | 9.5 |
if b < -2.7467723558510264e+111Initial program 47.2
Taylor expanded around -inf 3.4
Simplified3.4
if -2.7467723558510264e+111 < b < 8.311904135215147e-94Initial program 12.6
rmApplied clear-num12.7
if 8.311904135215147e-94 < b < 1.1455916387698242e-20Initial program 34.5
rmApplied flip-+34.5
Simplified17.7
rmApplied add-sqr-sqrt17.7
Applied sqrt-prod17.8
if 1.1455916387698242e-20 < b Initial program 55.0
Taylor expanded around inf 6.7
Final simplification9.5
herbie shell --seed 2020100 +o rules:numerics
(FPCore (a b c)
:name "quadp (p42, positive)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))))
(/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))