(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (+ x -1.0) (+ x 1.0))))
(if (<= x -2900.0)
(+
(/ -1.0 (* x x))
(+ (/ -3.0 (pow x 3.0)) (+ (/ -3.0 x) (/ -1.0 (pow x 4.0)))))
(if (<= x 3200.0)
(/ (fma x t_0 (fma -1.0 x -1.0)) (+ x -1.0))
(/
(+ -3.0 (+ (/ 2.0 x) (fma -2.0 (pow x -2.0) (* 2.0 (pow x -3.0)))))
(* (+ x 1.0) t_0))))))double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double tmp;
if (x <= -2900.0) {
tmp = (-1.0 / (x * x)) + ((-3.0 / pow(x, 3.0)) + ((-3.0 / x) + (-1.0 / pow(x, 4.0))));
} else if (x <= 3200.0) {
tmp = fma(x, t_0, fma(-1.0, x, -1.0)) / (x + -1.0);
} else {
tmp = (-3.0 + ((2.0 / x) + fma(-2.0, pow(x, -2.0), (2.0 * pow(x, -3.0))))) / ((x + 1.0) * t_0);
}
return tmp;
}
function code(x) return Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) end
function code(x) t_0 = Float64(Float64(x + -1.0) / Float64(x + 1.0)) tmp = 0.0 if (x <= -2900.0) tmp = Float64(Float64(-1.0 / Float64(x * x)) + Float64(Float64(-3.0 / (x ^ 3.0)) + Float64(Float64(-3.0 / x) + Float64(-1.0 / (x ^ 4.0))))); elseif (x <= 3200.0) tmp = Float64(fma(x, t_0, fma(-1.0, x, -1.0)) / Float64(x + -1.0)); else tmp = Float64(Float64(-3.0 + Float64(Float64(2.0 / x) + fma(-2.0, (x ^ -2.0), Float64(2.0 * (x ^ -3.0))))) / Float64(Float64(x + 1.0) * t_0)); end return tmp end
code[x_] := N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2900.0], N[(N[(-1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(N[(-3.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-3.0 / x), $MachinePrecision] + N[(-1.0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3200.0], N[(N[(x * t$95$0 + N[(-1.0 * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(-3.0 + N[(N[(2.0 / x), $MachinePrecision] + N[(-2.0 * N[Power[x, -2.0], $MachinePrecision] + N[(2.0 * N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
t_0 := \frac{x + -1}{x + 1}\\
\mathbf{if}\;x \leq -2900:\\
\;\;\;\;\frac{-1}{x \cdot x} + \left(\frac{-3}{{x}^{3}} + \left(\frac{-3}{x} + \frac{-1}{{x}^{4}}\right)\right)\\
\mathbf{elif}\;x \leq 3200:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, t_0, \mathsf{fma}\left(-1, x, -1\right)\right)}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-3 + \left(\frac{2}{x} + \mathsf{fma}\left(-2, {x}^{-2}, 2 \cdot {x}^{-3}\right)\right)}{\left(x + 1\right) \cdot t_0}\\
\end{array}



Bits error versus x
if x < -2900Initial program 58.8
Taylor expanded in x around inf 0.3
Simplified0.0
if -2900 < x < 3200Initial program 0.1
Applied egg-rr0.1
Taylor expanded in x around 0 0.1
Simplified0.1
if 3200 < x Initial program 59.4
Applied egg-rr59.3
Taylor expanded in x around inf 0.0
Simplified0.0
Applied egg-rr0.0
Final simplification0.0
herbie shell --seed 2022156
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))