\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.353329681310028 \cdot 10^{+154}:\\
\;\;\;\;\frac{-b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 5.58280276704199 \cdot 10^{-129}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 9.382688758558198 \cdot 10^{+153}:\\
\;\;\;\;\left(\frac{a \cdot \left(c \cdot -4\right) + 0 \cdot \left(b \cdot b\right)}{b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}} \cdot \left(\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}\right)\right) \cdot \frac{\sqrt[3]{0.5}}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\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.353329681310028e+154)
(/ (- b) (* a 2.0))
(if (<= b 5.58280276704199e-129)
(/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) (* a 2.0))
(if (<= b 9.382688758558198e+153)
(*
(*
(/
(+ (* a (* c -4.0)) (* 0.0 (* b b)))
(+ b (sqrt (- (* b b) (* 4.0 (* a c))))))
(* (cbrt 0.5) (cbrt 0.5)))
(/ (cbrt 0.5) a))
0.0))))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.353329681310028e+154) {
tmp = -b / (a * 2.0);
} else if (b <= 5.58280276704199e-129) {
tmp = (sqrt((b * b) - (4.0 * (a * c))) - b) / (a * 2.0);
} else if (b <= 9.382688758558198e+153) {
tmp = ((((a * (c * -4.0)) + (0.0 * (b * b))) / (b + sqrt((b * b) - (4.0 * (a * c))))) * (cbrt(0.5) * cbrt(0.5))) * (cbrt(0.5) / a);
} else {
tmp = 0.0;
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.8 |
|---|---|
| Target | 21.7 |
| Herbie | 22.1 |
if b < -1.3533296813100281e154Initial program 64.0
Simplified64.0
Taylor expanded around inf 52.3
if -1.3533296813100281e154 < b < 5.58280276704198988e-129Initial program 12.0
Simplified12.0
if 5.58280276704198988e-129 < b < 9.38268875855819839e153Initial program 42.3
Simplified42.3
rmApplied div-inv_binary6442.3
Simplified42.3
rmApplied *-un-lft-identity_binary6442.3
Applied add-cube-cbrt_binary6442.5
Applied times-frac_binary6442.5
Applied associate-*r*_binary6442.5
Simplified42.5
rmApplied flip--_binary6442.5
Simplified16.0
Simplified16.0
if 9.38268875855819839e153 < b Initial program 63.9
Simplified63.9
Taylor expanded around 0 37.7
Final simplification22.1
herbie shell --seed 2020285
(FPCore (a b c)
:name "quadp (p42, positive)"
:precision binary64
:herbie-expected #f
: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)))