\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}\;y \leq -7.17550285507751 \cdot 10^{+99}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -3.889439415150952 \cdot 10^{-35}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;y \leq -5.632296344258486 \cdot 10^{-143}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{elif}\;y \leq 1.4444647175745426 \cdot 10^{-110}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.2394672638586602 \cdot 10^{+113}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\mathsf{fma}\left(-4, y \cdot y, x \cdot x\right)}{\mathsf{fma}\left(x, x, t_0\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\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
(if (<= y -7.17550285507751e+99)
-1.0
(if (<= y -3.889439415150952e-35)
1.0
(let* ((t_0 (* y (* y 4.0))))
(if (<= y -5.632296344258486e-143)
(/ (- (* x x) t_0) (+ (* x x) t_0))
(if (<= y 1.4444647175745426e-110)
1.0
(if (<= y 1.2394672638586602e+113)
(log1p (expm1 (/ (fma -4.0 (* y y) (* x x)) (fma x x t_0))))
-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 (y <= -7.17550285507751e+99) {
tmp = -1.0;
} else if (y <= -3.889439415150952e-35) {
tmp = 1.0;
} else {
double t_0 = y * (y * 4.0);
double tmp_1;
if (y <= -5.632296344258486e-143) {
tmp_1 = ((x * x) - t_0) / ((x * x) + t_0);
} else if (y <= 1.4444647175745426e-110) {
tmp_1 = 1.0;
} else if (y <= 1.2394672638586602e+113) {
tmp_1 = log1p(expm1(fma(-4.0, (y * y), (x * x)) / fma(x, x, t_0)));
} else {
tmp_1 = -1.0;
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 32.1 |
|---|---|
| Target | 31.8 |
| Herbie | 14.6 |
if y < -7.17550285507750968e99 or 1.23946726385866024e113 < y Initial program 52.7
Simplified52.7
Taylor expanded in y around inf 10.1
if -7.17550285507750968e99 < y < -3.8894394151509519e-35 or -5.63229634425848629e-143 < y < 1.44446471757454257e-110Initial program 25.4
Simplified25.5
Taylor expanded in y around 0 16.9
if -3.8894394151509519e-35 < y < -5.63229634425848629e-143Initial program 16.6
if 1.44446471757454257e-110 < y < 1.23946726385866024e113Initial program 16.8
Simplified16.8
Applied log1p-expm1-u_binary6416.8
Final simplification14.6
herbie shell --seed 2021275
(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))))