\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.2536209265264344 \cdot 10^{+135}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\mathbf{elif}\;b \leq -2.876451255905772 \cdot 10^{-196}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{2 \cdot a}\\
\mathbf{elif}\;b \leq 6.0079603322066756 \cdot 10^{+128}:\\
\;\;\;\;\frac{-2 \cdot c}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\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.2536209265264344e+135)
(/ (* b -2.0) (* 2.0 a))
(if (<= b -2.876451255905772e-196)
(/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) (* 2.0 a))
(if (<= b 6.0079603322066756e+128)
(/ (* -2.0 c) (+ b (sqrt (fma a (* c -4.0) (* b b)))))
(- (/ 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.2536209265264344e+135) {
tmp = (b * -2.0) / (2.0 * a);
} else if (b <= -2.876451255905772e-196) {
tmp = (sqrt((b * b) - (4.0 * (a * c))) - b) / (2.0 * a);
} else if (b <= 6.0079603322066756e+128) {
tmp = (-2.0 * c) / (b + sqrt(fma(a, (c * -4.0), (b * b))));
} else {
tmp = -(c / b);
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 33.6 |
|---|---|
| Target | 20.6 |
| Herbie | 6.3 |
if b < -1.2536209265264344e135Initial program 56.7
Taylor expanded in b around -inf 2.7
if -1.2536209265264344e135 < b < -2.8764512559057721e-196Initial program 6.7
Applied *-un-lft-identity_binary646.7
if -2.8764512559057721e-196 < b < 6.0079603322066756e128Initial program 30.4
Simplified30.4
Applied flip--_binary6430.5
Applied associate-*l/_binary6430.6
Simplified15.1
Taylor expanded in c around 0 9.5
if 6.0079603322066756e128 < b Initial program 60.8
Taylor expanded in b around inf 1.7
Simplified1.7
Final simplification6.3
herbie shell --seed 2022067
(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)))