\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 -3.00186750331876538 \cdot 10^{143}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \le -6.5918067244508319 \cdot 10^{-138}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)\right)\\
\mathbf{elif}\;x \le 1.9631464787281808 \cdot 10^{68}:\\
\;\;\;\;-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 ((x <= -3.0018675033187654e+143)) {
temp = 1.0;
} else {
double temp_1;
if ((x <= -6.591806724450832e-138)) {
temp_1 = expm1(log1p((((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y)))));
} else {
double temp_2;
if ((x <= 1.9631464787281808e+68)) {
temp_2 = -1.0;
} else {
temp_2 = 1.0;
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.9 |
|---|---|
| Target | 31.6 |
| Herbie | 14.0 |
if x < -3.0018675033187654e+143 or 1.9631464787281808e+68 < x Initial program 53.1
Taylor expanded around inf 11.5
if -3.0018675033187654e+143 < x < -6.591806724450832e-138Initial program 14.1
rmApplied expm1-log1p-u14.1
if -6.591806724450832e-138 < x < 1.9631464787281808e+68Initial program 24.7
Taylor expanded around 0 15.7
Final simplification14.0
herbie shell --seed 2020056 +o rules:numerics
(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))))