\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 \le -8.1561596166685901 \cdot 10^{125}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \le -8.2517187188967945 \cdot 10^{-93}:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\
\mathbf{elif}\;x \le 1.70327835954175013 \cdot 10^{-103}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \le 9.5532984912586814 \cdot 10^{94}:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}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 VAR;
if ((x <= -8.15615961666859e+125)) {
VAR = 1.0;
} else {
double VAR_1;
if ((x <= -8.251718718896794e-93)) {
VAR_1 = (((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y)));
} else {
double VAR_2;
if ((x <= 1.7032783595417501e-103)) {
VAR_2 = -1.0;
} else {
double VAR_3;
if ((x <= 9.553298491258681e+94)) {
VAR_3 = (((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y)));
} else {
VAR_3 = 1.0;
}
VAR_2 = VAR_3;
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.3 |
|---|---|
| Target | 31.0 |
| Herbie | 12.6 |
if x < -8.15615961666859e+125 or 9.553298491258681e+94 < x Initial program 52.7
Taylor expanded around inf 10.4
if -8.15615961666859e+125 < x < -8.251718718896794e-93 or 1.7032783595417501e-103 < x < 9.553298491258681e+94Initial program 15.5
if -8.251718718896794e-93 < x < 1.7032783595417501e-103Initial program 27.2
Taylor expanded around 0 11.6
Final simplification12.6
herbie shell --seed 2020100
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< (/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4))) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4)))) 2) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))))
(/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))))