\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.7863758169125638 \cdot 10^{138}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le -4.96206905407944466 \cdot 10^{-170}:\\
\;\;\;\;\frac{1}{\frac{a}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b} \cdot 2}\\
\mathbf{elif}\;b \le 2.73926902980269393 \cdot 10^{102}:\\
\;\;\;\;\frac{1}{2} \cdot \left(1 \cdot \frac{c}{\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{4}}\right)\\
\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.7863758169125638e+138)) {
VAR = (1.0 * ((c / b) - (b / a)));
} else {
double VAR_1;
if ((b <= -4.962069054079445e-170)) {
VAR_1 = (1.0 / ((a / (sqrt(((b * b) - (4.0 * (a * c)))) - b)) * 2.0));
} else {
double VAR_2;
if ((b <= 2.739269029802694e+102)) {
VAR_2 = ((1.0 / 2.0) * (1.0 * (c / ((-b - sqrt(((b * b) - (4.0 * (a * c))))) / 4.0))));
} 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 | 34.2 |
|---|---|
| Target | 20.9 |
| Herbie | 6.4 |
if b < -2.7863758169125638e+138Initial program 58.6
Taylor expanded around -inf 2.6
Simplified2.6
if -2.7863758169125638e+138 < b < -4.962069054079445e-170Initial program 5.2
rmApplied clear-num5.4
Simplified5.4
if -4.962069054079445e-170 < b < 2.739269029802694e+102Initial program 29.4
rmApplied flip-+29.6
Simplified17.2
rmApplied clear-num17.3
Simplified17.3
rmApplied div-inv17.3
Applied times-frac17.3
Simplified10.7
if 2.739269029802694e+102 < b Initial program 60.1
Taylor expanded around inf 2.3
Final simplification6.4
herbie shell --seed 2020078 +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)))