\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 1.7024537441103181 \cdot 10^{28}:\\
\;\;\;\;\frac{4 \cdot c}{\left(2 \cdot a\right) \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{4 \cdot c}{-4 \cdot 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 <= 1.702453744110318e+28)) {
VAR_2 = ((4.0 * c) / ((2.0 * a) * ((-b - sqrt(((b * b) - (4.0 * (a * c))))) / a)));
} else {
VAR_2 = ((4.0 * c) / (-4.0 * 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 | 7.0 |
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 < 1.702453744110318e+28Initial program 25.3
rmApplied flip-+25.6
Simplified17.8
rmApplied *-commutative17.8
Applied associate-*r*17.9
Applied associate-/l*15.6
Applied associate-/l/12.0
if 1.702453744110318e+28 < b Initial program 57.0
rmApplied flip-+57.0
Simplified28.1
rmApplied *-commutative28.1
Applied associate-*r*28.2
Applied associate-/l*29.9
Applied associate-/l/28.1
Taylor expanded around 0 4.9
Final simplification7.0
herbie shell --seed 2020078
(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)))