\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}\;x \cdot x \leq 1.55715602789528 \cdot 10^{-289}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 1.622883590444815 \cdot 10^{-225}:\\
\;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\
\mathbf{elif}\;x \cdot x \leq 3.938995416799686 \cdot 10^{-128}:\\
\;\;\;\;-1 + 0.5 \cdot \frac{x \cdot x}{y \cdot y}\\
\mathbf{elif}\;x \cdot x \leq 9.560203192398091 \cdot 10^{+187}:\\
\;\;\;\;\frac{x \cdot x}{x \cdot x + y \cdot \left(y \cdot 4\right)} - \frac{y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\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 (<= (* x x) 1.55715602789528e-289)
-1.0
(if (<= (* x x) 1.622883590444815e-225)
(/ (- (* x x) (* y (* y 4.0))) (+ (* x x) (* y (* y 4.0))))
(if (<= (* x x) 3.938995416799686e-128)
(+ -1.0 (* 0.5 (/ (* x x) (* y y))))
(if (<= (* x x) 9.560203192398091e+187)
(-
(/ (* x x) (+ (* x x) (* y (* y 4.0))))
(/ (* y (* y 4.0)) (+ (* x x) (* y (* y 4.0)))))
1.0)))))double code(double x, double y) {
return ((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y));
}
double code(double x, double y) {
double tmp;
if ((x * x) <= 1.55715602789528e-289) {
tmp = -1.0;
} else if ((x * x) <= 1.622883590444815e-225) {
tmp = ((x * x) - (y * (y * 4.0))) / ((x * x) + (y * (y * 4.0)));
} else if ((x * x) <= 3.938995416799686e-128) {
tmp = -1.0 + (0.5 * ((x * x) / (y * y)));
} else if ((x * x) <= 9.560203192398091e+187) {
tmp = ((x * x) / ((x * x) + (y * (y * 4.0)))) - ((y * (y * 4.0)) / ((x * x) + (y * (y * 4.0))));
} else {
tmp = 1.0;
}
return tmp;
}








Bits error versus x








Bits error versus y
Results
| Original | 31.9 |
|---|---|
| Target | 31.6 |
| Herbie | 13.1 |
| Alternative 1 | |
|---|---|
| Error | 13.0 |
| Cost | 3140 |
| Alternative 2 | |
|---|---|
| Error | 13.1 |
| Cost | 3012 |
| Alternative 3 | |
|---|---|
| Error | 16.2 |
| Cost | 706 |
| Alternative 4 | |
|---|---|
| Error | 31.9 |
| Cost | 64 |

if (*.f64 x x) < 1.5571560278952801e-289Initial program 8.2
if 1.5571560278952801e-289 < (*.f64 x x) < 1.6228835904448149e-225Initial program 13.8
Simplified13.8
if 1.6228835904448149e-225 < (*.f64 x x) < 3.9389954167996858e-128Initial program 17.4
Taylor expanded around 0 22.3
Simplified22.3
Simplified22.3
if 3.9389954167996858e-128 < (*.f64 x x) < 9.5602031923980912e187Initial program 17.3
rmApplied div-sub_binary64_1849717.3
Simplified17.3
Simplified17.3
Simplified17.3
if 9.5602031923980912e187 < (*.f64 x x) Initial program 11.4
Final simplification13.1
herbie shell --seed 2021044
(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))))