(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
(FPCore (x)
:precision binary64
(let* ((t_0 (* x (+ x -1.0))) (t_1 (/ 1.0 (* x x))) (t_2 (pow (+ x 1.0) 2.0)))
(if (<= x -380000.0)
(- (/ -3.0 x) t_1)
(if (<= x 12000.0)
(/
(/
(+ (pow t_0 3.0) (pow (- t_2) 3.0))
(+ (pow t_0 2.0) (+ (* t_2 t_2) (* t_0 t_2))))
(fma x x -1.0))
(+ (/ -3.0 x) (- (/ -3.0 (pow x 3.0)) t_1))))))double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
double code(double x) {
double t_0 = x * (x + -1.0);
double t_1 = 1.0 / (x * x);
double t_2 = pow((x + 1.0), 2.0);
double tmp;
if (x <= -380000.0) {
tmp = (-3.0 / x) - t_1;
} else if (x <= 12000.0) {
tmp = ((pow(t_0, 3.0) + pow(-t_2, 3.0)) / (pow(t_0, 2.0) + ((t_2 * t_2) + (t_0 * t_2)))) / fma(x, x, -1.0);
} else {
tmp = (-3.0 / x) + ((-3.0 / pow(x, 3.0)) - t_1);
}
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(x * Float64(x + -1.0)) t_1 = Float64(1.0 / Float64(x * x)) t_2 = Float64(x + 1.0) ^ 2.0 tmp = 0.0 if (x <= -380000.0) tmp = Float64(Float64(-3.0 / x) - t_1); elseif (x <= 12000.0) tmp = Float64(Float64(Float64((t_0 ^ 3.0) + (Float64(-t_2) ^ 3.0)) / Float64((t_0 ^ 2.0) + Float64(Float64(t_2 * t_2) + Float64(t_0 * t_2)))) / fma(x, x, -1.0)); else tmp = Float64(Float64(-3.0 / x) + Float64(Float64(-3.0 / (x ^ 3.0)) - t_1)); 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[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(x + 1.0), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[x, -380000.0], N[(N[(-3.0 / x), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[x, 12000.0], N[(N[(N[(N[Power[t$95$0, 3.0], $MachinePrecision] + N[Power[(-t$95$2), 3.0], $MachinePrecision]), $MachinePrecision] / N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(N[(t$95$2 * t$95$2), $MachinePrecision] + N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(-3.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]]]]]]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
t_0 := x \cdot \left(x + -1\right)\\
t_1 := \frac{1}{x \cdot x}\\
t_2 := {\left(x + 1\right)}^{2}\\
\mathbf{if}\;x \leq -380000:\\
\;\;\;\;\frac{-3}{x} - t_1\\
\mathbf{elif}\;x \leq 12000:\\
\;\;\;\;\frac{\frac{{t_0}^{3} + {\left(-t_2\right)}^{3}}{{t_0}^{2} + \left(t_2 \cdot t_2 + t_0 \cdot t_2\right)}}{\mathsf{fma}\left(x, x, -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-3}{x} + \left(\frac{-3}{{x}^{3}} - t_1\right)\\
\end{array}



Bits error versus x
if x < -3.8e5Initial program 59.4
Applied egg-rr61.8
Taylor expanded in x around inf 0.4
Simplified0.1
if -3.8e5 < x < 12000Initial program 0.1
Applied egg-rr0.1
Applied egg-rr0.1
if 12000 < x Initial program 59.0
Taylor expanded in x around inf 0.3
Simplified0.0
Final simplification0.1
herbie shell --seed 2022166
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))