\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 \leq -1.511705281598505 \cdot 10^{+159}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -2.5067818285457853 \cdot 10^{-122}:\\
\;\;\;\;\begin{array}{l}
t_0 := \mathsf{fma}\left(4, y \cdot y, x \cdot x\right)\\
\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(x, \frac{x}{t_0}, \left(y \cdot \frac{y}{t_0}\right) \cdot -4\right)\right)\right)
\end{array}\\
\mathbf{elif}\;x \leq 1.9388453121044746 \cdot 10^{-153}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.53922962851806 \cdot 10^{+147}:\\
\;\;\;\;\begin{array}{l}
t_1 := y \cdot \left(4 \cdot y\right)\\
\frac{x \cdot x}{x \cdot x + t_1} - \frac{4 \cdot y}{\frac{\mathsf{fma}\left(x, x, t_1\right)}{y}}
\end{array}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
(FPCore (x y) :precision binary64 (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))
(FPCore (x y)
:precision binary64
(if (<= x -1.511705281598505e+159)
1.0
(if (<= x -2.5067818285457853e-122)
(let* ((t_0 (fma 4.0 (* y y) (* x x))))
(expm1 (log1p (fma x (/ x t_0) (* (* y (/ y t_0)) -4.0)))))
(if (<= x 1.9388453121044746e-153)
-1.0
(if (<= x 1.53922962851806e+147)
(let* ((t_1 (* y (* 4.0 y))))
(- (/ (* x x) (+ (* x x) t_1)) (/ (* 4.0 y) (/ (fma x x t_1) y))))
1.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 tmp;
if (x <= -1.511705281598505e+159) {
tmp = 1.0;
} else if (x <= -2.5067818285457853e-122) {
double t_0 = fma(4.0, (y * y), (x * x));
tmp = expm1(log1p(fma(x, (x / t_0), ((y * (y / t_0)) * -4.0))));
} else if (x <= 1.9388453121044746e-153) {
tmp = -1.0;
} else if (x <= 1.53922962851806e+147) {
double t_1 = y * (4.0 * y);
tmp = ((x * x) / ((x * x) + t_1)) - ((4.0 * y) / (fma(x, x, t_1) / y));
} else {
tmp = 1.0;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 31.0 |
|---|---|
| Target | 30.7 |
| Herbie | 12.1 |
if x < -1.51170528159850505e159 or 1.53922962851806007e147 < x Initial program 62.7
Taylor expanded in x around inf 8.4
if -1.51170528159850505e159 < x < -2.5067818285457853e-122Initial program 16.0
Applied div-sub_binary6416.0
Applied expm1-log1p-u_binary6416.0
Simplified16.0
Applied expm1-log1p-u_binary6416.0
Simplified16.3
if -2.5067818285457853e-122 < x < 1.93884531210447457e-153Initial program 28.8
Taylor expanded in x around 0 9.3
if 1.93884531210447457e-153 < x < 1.53922962851806007e147Initial program 15.7
Applied div-sub_binary6415.7
Applied associate-/l*_binary6415.2
Simplified15.2
Final simplification12.1
herbie shell --seed 2022088
(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))))