\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.5, {\left(\frac{x}{y}\right)}^{2}, -1\right)\\
\mathbf{if}\;y \leq -5.217929847352783 \cdot 10^{+148}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \frac{\mathsf{fma}\left(-4, y \cdot y, x \cdot x\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\
\mathbf{if}\;y \leq -2.542146711786574 \cdot 10^{-111}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.1008163448544512 \cdot 10^{-116}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.494591362659238 \cdot 10^{-74}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 0.7272173049803466:\\
\;\;\;\;\mathsf{fma}\left(\frac{y \cdot y}{x \cdot x}, -8, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\end{array}
(FPCore (x y) :precision binary64 (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))
(FPCore (x y)
:precision binary64
(let* ((t_0 (fma 0.5 (pow (/ x y) 2.0) -1.0)))
(if (<= y -5.217929847352783e+148)
t_0
(let* ((t_1 (/ (fma -4.0 (* y y) (* x x)) (fma x x (* y (* y 4.0))))))
(if (<= y -2.542146711786574e-111)
t_1
(if (<= y 1.1008163448544512e-116)
1.0
(if (<= y 5.494591362659238e-74)
t_1
(if (<= y 0.7272173049803466)
(fma (/ (* y y) (* x x)) -8.0 1.0)
t_0))))))))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 t_0 = fma(0.5, pow((x / y), 2.0), -1.0);
double tmp;
if (y <= -5.217929847352783e+148) {
tmp = t_0;
} else {
double t_1 = fma(-4.0, (y * y), (x * x)) / fma(x, x, (y * (y * 4.0)));
double tmp_1;
if (y <= -2.542146711786574e-111) {
tmp_1 = t_1;
} else if (y <= 1.1008163448544512e-116) {
tmp_1 = 1.0;
} else if (y <= 5.494591362659238e-74) {
tmp_1 = t_1;
} else if (y <= 0.7272173049803466) {
tmp_1 = fma(((y * y) / (x * x)), -8.0, 1.0);
} else {
tmp_1 = t_0;
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 31.7 |
|---|---|
| Target | 31.4 |
| Herbie | 13.3 |
if y < -5.2179298473527829e148 or 0.727217304980346646 < y Initial program 47.8
Simplified47.8
Taylor expanded in y around inf 17.4
Simplified17.4
Taylor expanded in x around 0 17.4
Simplified12.0
if -5.2179298473527829e148 < y < -2.542146711786574e-111 or 1.10081634485445124e-116 < y < 5.494591362659238e-74Initial program 15.9
Simplified15.9
if -2.542146711786574e-111 < y < 1.10081634485445124e-116Initial program 27.9
Simplified28.0
Taylor expanded in y around 0 10.0
if 5.494591362659238e-74 < y < 0.727217304980346646Initial program 14.8
Simplified14.8
Taylor expanded in y around 0 28.0
Simplified28.0
Final simplification13.3
herbie shell --seed 2021225
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2.0) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))
(/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))