\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.3283658121427655 \cdot 10^{154}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \le -4.5816256426164583 \cdot 10^{-130}:\\
\;\;\;\;\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 1.06788602209214735 \cdot 10^{-153}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \le 8.80241802012499797:\\
\;\;\;\;\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 1.0209900440301217 \cdot 10^{44}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \le 3.49858220287038617 \cdot 10^{165}:\\
\;\;\;\;\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.3283658121427655e+154)) {
VAR = 1.0;
} else {
double VAR_1;
if ((x <= -4.581625642616458e-130)) {
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 <= 1.0678860220921474e-153)) {
VAR_2 = -1.0;
} else {
double VAR_3;
if ((x <= 8.802418020124998)) {
VAR_3 = ((x / (fma(x, x, ((y * 4.0) * y)) / x)) - ((y * 4.0) / (fma(x, x, ((y * 4.0) * y)) / y)));
} else {
double VAR_4;
if ((x <= 1.0209900440301217e+44)) {
VAR_4 = -1.0;
} else {
double VAR_5;
if ((x <= 3.498582202870386e+165)) {
VAR_5 = ((x / (fma(x, x, ((y * 4.0) * y)) / x)) - ((y * 4.0) / (fma(x, x, ((y * 4.0) * y)) / y)));
} else {
VAR_5 = 1.0;
}
VAR_4 = VAR_5;
}
VAR_3 = VAR_4;
}
VAR_2 = VAR_3;
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.5 |
|---|---|
| Target | 31.3 |
| Herbie | 12.9 |
if x < -1.3283658121427655e+154 or 3.498582202870386e+165 < x Initial program 64.0
Taylor expanded around inf 8.2
if -1.3283658121427655e+154 < x < -4.581625642616458e-130 or 1.0678860220921474e-153 < x < 8.802418020124998 or 1.0209900440301217e+44 < x < 3.498582202870386e+165Initial program 16.9
rmApplied div-sub16.9
Simplified16.9
Simplified16.4
if -4.581625642616458e-130 < x < 1.0678860220921474e-153 or 8.802418020124998 < x < 1.0209900440301217e+44Initial program 28.1
Taylor expanded around 0 11.3
Final simplification12.9
herbie shell --seed 2020079 +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))))