(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))) 1.8052226380405045e-13) (- (- (/ -3.0 x) (+ (pow x -2.0) (/ 3.0 (pow x 3.0)))) (/ 1.0 (pow x 4.0))) (+ 1.0 (* x (+ x 3.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))) <= 1.8052226380405045e-13) {
tmp = ((-3.0 / x) - (pow(x, -2.0) + (3.0 / pow(x, 3.0)))) - (1.0 / pow(x, 4.0));
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x / (x + 1.0d0)) - ((x + 1.0d0) / (x - 1.0d0))
end function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((x / (x + 1.0d0)) - ((x + 1.0d0) / (x - 1.0d0))) <= 1.8052226380405045d-13) then
tmp = (((-3.0d0) / x) - ((x ** (-2.0d0)) + (3.0d0 / (x ** 3.0d0)))) - (1.0d0 / (x ** 4.0d0))
else
tmp = 1.0d0 + (x * (x + 3.0d0))
end if
code = tmp
end function
public static double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
public static double code(double x) {
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 1.8052226380405045e-13) {
tmp = ((-3.0 / x) - (Math.pow(x, -2.0) + (3.0 / Math.pow(x, 3.0)))) - (1.0 / Math.pow(x, 4.0));
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
def code(x): return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))
def code(x): tmp = 0 if ((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 1.8052226380405045e-13: tmp = ((-3.0 / x) - (math.pow(x, -2.0) + (3.0 / math.pow(x, 3.0)))) - (1.0 / math.pow(x, 4.0)) else: tmp = 1.0 + (x * (x + 3.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))) <= 1.8052226380405045e-13) tmp = Float64(Float64(Float64(-3.0 / x) - Float64((x ^ -2.0) + Float64(3.0 / (x ^ 3.0)))) - Float64(1.0 / (x ^ 4.0))); else tmp = Float64(1.0 + Float64(x * Float64(x + 3.0))); end return tmp end
function tmp = code(x) tmp = (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0)); end
function tmp_2 = code(x) tmp = 0.0; if (((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 1.8052226380405045e-13) tmp = ((-3.0 / x) - ((x ^ -2.0) + (3.0 / (x ^ 3.0)))) - (1.0 / (x ^ 4.0)); else tmp = 1.0 + (x * (x + 3.0)); end tmp_2 = 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], 1.8052226380405045e-13], N[(N[(N[(-3.0 / x), $MachinePrecision] - N[(N[Power[x, -2.0], $MachinePrecision] + N[(3.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x * N[(x + 3.0), $MachinePrecision]), $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 1.8052226380405045 \cdot 10^{-13}:\\
\;\;\;\;\left(\frac{-3}{x} - \left({x}^{-2} + \frac{3}{{x}^{3}}\right)\right) - \frac{1}{{x}^{4}}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}



Bits error versus x
Results
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 1.80522e-13Initial program 59.4
Taylor expanded in x around inf 0.5
Simplified0.2
Applied pow2_binary640.2
Applied pow-flip_binary640.2
Simplified0.2
if 1.80522e-13 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 0.4
Taylor expanded in x around 0 1.5
Simplified1.5
Final simplification0.8
herbie shell --seed 2022131
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))