\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 -2.60391653418792414 \cdot 10^{59}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \le -4.352408394580921 \cdot 10^{21}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \le -1.2849439179793821 \cdot 10^{-40}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \le 1.70625720008210268 \cdot 10^{-27}:\\
\;\;\;\;-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 VAR;
if ((x <= -2.603916534187924e+59)) {
VAR = 1.0;
} else {
double VAR_1;
if ((x <= -4.352408394580921e+21)) {
VAR_1 = -1.0;
} else {
double VAR_2;
if ((x <= -1.284943917979382e-40)) {
VAR_2 = 1.0;
} else {
double VAR_3;
if ((x <= 1.7062572000821027e-27)) {
VAR_3 = -1.0;
} 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 | 30.6 |
|---|---|
| Target | 30.3 |
| Herbie | 16.4 |
if x < -2.603916534187924e+59 or -4.352408394580921e+21 < x < -1.284943917979382e-40 or 1.7062572000821027e-27 < x Initial program 38.4
Taylor expanded around inf 17.2
if -2.603916534187924e+59 < x < -4.352408394580921e+21 or -1.284943917979382e-40 < x < 1.7062572000821027e-27Initial program 22.1
Taylor expanded around 0 15.5
Final simplification16.4
herbie shell --seed 2020092 +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))))