(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
(FPCore (x) :precision binary64 (if (<= (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))) 0.001) (- (- (/ 3.0 x)) (fma (fma (pow x -3.0) (- x -3.0) (pow x -4.0)) 1.0 0.0)) (/ (- x (* (+ x 1.0) (/ (+ x 1.0) (+ x -1.0)))) (+ x 1.0))))
double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
double code(double x) {
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 0.001) {
tmp = -(3.0 / x) - fma(fma(pow(x, -3.0), (x - -3.0), pow(x, -4.0)), 1.0, 0.0);
} else {
tmp = (x - ((x + 1.0) * ((x + 1.0) / (x + -1.0)))) / (x + 1.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) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) <= 0.001) tmp = Float64(Float64(-Float64(3.0 / x)) - fma(fma((x ^ -3.0), Float64(x - -3.0), (x ^ -4.0)), 1.0, 0.0)); else tmp = Float64(Float64(x - Float64(Float64(x + 1.0) * Float64(Float64(x + 1.0) / Float64(x + -1.0)))) / Float64(x + 1.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_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.001], N[((-N[(3.0 / x), $MachinePrecision]) - N[(N[(N[Power[x, -3.0], $MachinePrecision] * N[(x - -3.0), $MachinePrecision] + N[Power[x, -4.0], $MachinePrecision]), $MachinePrecision] * 1.0 + 0.0), $MachinePrecision]), $MachinePrecision], N[(N[(x - N[(N[(x + 1.0), $MachinePrecision] * N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x - 1} \leq 0.001:\\
\;\;\;\;\left(-\frac{3}{x}\right) - \mathsf{fma}\left(\mathsf{fma}\left({x}^{-3}, x - -3, {x}^{-4}\right), 1, 0\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x - \left(x + 1\right) \cdot \frac{x + 1}{x + -1}}{x + 1}\\
\end{array}



Bits error versus x
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 1e-3Initial program 58.8
Taylor expanded in x around inf 0.6
Simplified0.3
Applied egg-rr0.8
Applied egg-rr0.3
if 1e-3 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 0.0
Applied egg-rr0.0
Final simplification0.2
herbie shell --seed 2022155
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))