\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 \le -3.4362841072323272 \cdot 10^{150}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -3.8396732637812812 \cdot 10^{-74}:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\
\mathbf{elif}\;y \le 1.41284087263746274 \cdot 10^{-110}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \le 4.54642378775940041 \cdot 10^{-26}:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\
\mathbf{elif}\;y \le 2.97781259123946345 \cdot 10^{57}:\\
\;\;\;\;1\\
\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 temp;
if ((y <= -3.436284107232327e+150)) {
temp = -1.0;
} else {
double temp_1;
if ((y <= -3.839673263781281e-74)) {
temp_1 = (((x * x) - ((y * 4.0) * y)) / (sqrt(((x * x) + ((y * 4.0) * y))) * sqrt(((x * x) + ((y * 4.0) * y)))));
} else {
double temp_2;
if ((y <= 1.4128408726374627e-110)) {
temp_2 = 1.0;
} else {
double temp_3;
if ((y <= 4.5464237877594004e-26)) {
temp_3 = (((x * x) - ((y * 4.0) * y)) / (sqrt(((x * x) + ((y * 4.0) * y))) * sqrt(((x * x) + ((y * 4.0) * y)))));
} else {
double temp_4;
if ((y <= 2.9778125912394635e+57)) {
temp_4 = 1.0;
} else {
temp_4 = -1.0;
}
temp_3 = temp_4;
}
temp_2 = temp_3;
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.8 |
|---|---|
| Target | 31.5 |
| Herbie | 14.1 |
if y < -3.436284107232327e+150 or 2.9778125912394635e+57 < y Initial program 51.9
Taylor expanded around 0 12.1
if -3.436284107232327e+150 < y < -3.839673263781281e-74 or 1.4128408726374627e-110 < y < 4.5464237877594004e-26Initial program 15.5
rmApplied add-sqr-sqrt15.5
if -3.839673263781281e-74 < y < 1.4128408726374627e-110 or 4.5464237877594004e-26 < y < 2.9778125912394635e+57Initial program 24.8
Taylor expanded around inf 14.9
Final simplification14.1
herbie shell --seed 2020060
(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))))