\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 -1.6533496348093263 \cdot 10^{136}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \le -8.5079988842821871 \cdot 10^{-92}:\\
\;\;\;\;\frac{x}{\frac{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}{x}} - \frac{y \cdot 4}{\frac{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}{y}}\\
\mathbf{elif}\;x \le 5.33120441752882848 \cdot 10^{-100}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \le 1.6140055087642122 \cdot 10^{150}:\\
\;\;\;\;\frac{x}{\frac{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}{x}} - \frac{y \cdot 4}{\frac{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}{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 <= -1.6533496348093263e+136)) {
VAR = 1.0;
} else {
double VAR_1;
if ((x <= -8.507998884282187e-92)) {
VAR_1 = ((x / (fma(x, x, ((y * 4.0) * y)) / x)) - ((y * 4.0) / (fma(x, x, ((y * 4.0) * y)) / y)));
} else {
double VAR_2;
if ((x <= 5.331204417528828e-100)) {
VAR_2 = -1.0;
} else {
double VAR_3;
if ((x <= 1.6140055087642122e+150)) {
VAR_3 = ((x / (fma(x, x, ((y * 4.0) * y)) / x)) - ((y * 4.0) / (fma(x, x, ((y * 4.0) * y)) / 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.3 |
if x < -1.6533496348093263e+136 or 1.6140055087642122e+150 < x Initial program 60.3
Taylor expanded around inf 8.8
if -1.6533496348093263e+136 < x < -8.507998884282187e-92 or 5.331204417528828e-100 < x < 1.6140055087642122e+150Initial program 15.6
rmApplied div-sub15.5
Simplified15.6
Simplified15.1
if -8.507998884282187e-92 < x < 5.331204417528828e-100Initial program 27.1
Taylor expanded around 0 11.6
Final simplification12.3
herbie shell --seed 2020100 +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))))