(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))))
(if (<= (+ t_0 (/ (- -1.0 x) (+ x -1.0))) 0.0)
(+ (+ (/ -3.0 x) (/ (/ -1.0 x) x)) (/ -3.0 (pow x 3.0)))
(+ t_0 (exp (- (log1p x) (log1p (- x))))))))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 tmp;
if ((t_0 + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = ((-3.0 / x) + ((-1.0 / x) / x)) + (-3.0 / pow(x, 3.0));
} else {
tmp = t_0 + exp((log1p(x) - log1p(-x)));
}
return tmp;
}
public static double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
public static double code(double x) {
double t_0 = x / (x + 1.0);
double tmp;
if ((t_0 + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = ((-3.0 / x) + ((-1.0 / x) / x)) + (-3.0 / Math.pow(x, 3.0));
} else {
tmp = t_0 + Math.exp((Math.log1p(x) - Math.log1p(-x)));
}
return tmp;
}
def code(x): return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))
def code(x): t_0 = x / (x + 1.0) tmp = 0 if (t_0 + ((-1.0 - x) / (x + -1.0))) <= 0.0: tmp = ((-3.0 / x) + ((-1.0 / x) / x)) + (-3.0 / math.pow(x, 3.0)) else: tmp = t_0 + math.exp((math.log1p(x) - math.log1p(-x))) 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)) tmp = 0.0 if (Float64(t_0 + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) <= 0.0) tmp = Float64(Float64(Float64(-3.0 / x) + Float64(Float64(-1.0 / x) / x)) + Float64(-3.0 / (x ^ 3.0))); else tmp = Float64(t_0 + exp(Float64(log1p(x) - log1p(Float64(-x))))); 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]}, If[LessEqual[N[(t$95$0 + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(-1.0 / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(-3.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[Exp[N[(N[Log[1 + x], $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;t_0 + \frac{-1 - x}{x + -1} \leq 0:\\
\;\;\;\;\left(\frac{-3}{x} + \frac{\frac{-1}{x}}{x}\right) + \frac{-3}{{x}^{3}}\\
\mathbf{else}:\\
\;\;\;\;t_0 + e^{\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)}\\
\end{array}
Results
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 0.0Initial program 59.4
Simplified59.4
Applied egg-rr59.4
Taylor expanded in x around inf 0.6
Simplified0.3
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 0.5
Simplified0.5
Applied egg-rr1.3
Final simplification0.8
herbie shell --seed 2022211
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))