\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\begin{array}{l}
\mathbf{if}\;y \cdot \left(y \cdot 4\right) \leq 4.347777683403 \cdot 10^{-322}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 3.8018787503186285 \cdot 10^{-283}:\\
\;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\
\mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 4.0242122759004074 \cdot 10^{-85}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 1.33662301455546 \cdot 10^{+282}:\\
\;\;\;\;\log \left(e^{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}}\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}(FPCore (x y) :precision binary64 (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))
(FPCore (x y)
:precision binary64
(if (<= (* y (* y 4.0)) 4.347777683403e-322)
1.0
(if (<= (* y (* y 4.0)) 3.8018787503186285e-283)
(/ (- (* x x) (* y (* y 4.0))) (+ (* y (* y 4.0)) (* x x)))
(if (<= (* y (* y 4.0)) 4.0242122759004074e-85)
1.0
(if (<= (* y (* y 4.0)) 1.33662301455546e+282)
(log
(exp (/ (- (* x x) (* y (* y 4.0))) (+ (* y (* y 4.0)) (* x x)))))
-1.0)))))double code(double x, double y) {
return (((double) (((double) (x * x)) - ((double) (((double) (y * 4.0)) * y)))) / ((double) (((double) (x * x)) + ((double) (((double) (y * 4.0)) * y)))));
}
double code(double x, double y) {
double tmp;
if ((((double) (y * ((double) (y * 4.0)))) <= 4.347777683403e-322)) {
tmp = 1.0;
} else {
double tmp_1;
if ((((double) (y * ((double) (y * 4.0)))) <= 3.8018787503186285e-283)) {
tmp_1 = (((double) (((double) (x * x)) - ((double) (y * ((double) (y * 4.0)))))) / ((double) (((double) (y * ((double) (y * 4.0)))) + ((double) (x * x)))));
} else {
double tmp_2;
if ((((double) (y * ((double) (y * 4.0)))) <= 4.0242122759004074e-85)) {
tmp_2 = 1.0;
} else {
double tmp_3;
if ((((double) (y * ((double) (y * 4.0)))) <= 1.33662301455546e+282)) {
tmp_3 = ((double) log(((double) exp((((double) (((double) (x * x)) - ((double) (y * ((double) (y * 4.0)))))) / ((double) (((double) (y * ((double) (y * 4.0)))) + ((double) (x * x)))))))));
} else {
tmp_3 = -1.0;
}
tmp_2 = tmp_3;
}
tmp_1 = tmp_2;
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.8 |
|---|---|
| Target | 31.5 |
| Herbie | 12.9 |
if (*.f64 (*.f64 y 4.0) y) < 4.34778e-322 or 3.8018787503186285e-283 < (*.f64 (*.f64 y 4.0) y) < 4.0242122759004074e-85Initial program 25.5
Taylor expanded around inf 13.0
if 4.34778e-322 < (*.f64 (*.f64 y 4.0) y) < 3.8018787503186285e-283Initial program 13.9
if 4.0242122759004074e-85 < (*.f64 (*.f64 y 4.0) y) < 1.3366230145554599e282Initial program 16.6
rmApplied add-log-exp_binary6416.6
Simplified16.6
if 1.3366230145554599e282 < (*.f64 (*.f64 y 4.0) y) Initial program 60.3
Taylor expanded around 0 8.5
Final simplification12.9
herbie shell --seed 2020210
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2.0) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))
(/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))