(FPCore (x) :precision binary64 (- (/ 1.0 (+ x 1.0)) (/ 1.0 x)))
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (/ 1.0 (+ 1.0 x)) (/ -1.0 x))))
(if (<= t_0 -1000.0)
t_0
(if (<= t_0 0.0)
(+
(pow x -3.0)
(fma 1.0 (pow x -5.0) (fma -1.0 (pow x -2.0) (- (pow x -4.0)))))
(/ (/ (+ x (- -1.0 x)) (+ 1.0 x)) x)))))double code(double x) {
return (1.0 / (x + 1.0)) - (1.0 / x);
}
double code(double x) {
double t_0 = (1.0 / (1.0 + x)) + (-1.0 / x);
double tmp;
if (t_0 <= -1000.0) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = pow(x, -3.0) + fma(1.0, pow(x, -5.0), fma(-1.0, pow(x, -2.0), -pow(x, -4.0)));
} else {
tmp = ((x + (-1.0 - x)) / (1.0 + x)) / x;
}
return tmp;
}
function code(x) return Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(1.0 / x)) end
function code(x) t_0 = Float64(Float64(1.0 / Float64(1.0 + x)) + Float64(-1.0 / x)) tmp = 0.0 if (t_0 <= -1000.0) tmp = t_0; elseif (t_0 <= 0.0) tmp = Float64((x ^ -3.0) + fma(1.0, (x ^ -5.0), fma(-1.0, (x ^ -2.0), Float64(-(x ^ -4.0))))); else tmp = Float64(Float64(Float64(x + Float64(-1.0 - x)) / Float64(1.0 + x)) / x); end return tmp end
code[x_] := N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1000.0], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[Power[x, -3.0], $MachinePrecision] + N[(1.0 * N[Power[x, -5.0], $MachinePrecision] + N[(-1.0 * N[Power[x, -2.0], $MachinePrecision] + (-N[Power[x, -4.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\frac{1}{x + 1} - \frac{1}{x}
\begin{array}{l}
t_0 := \frac{1}{1 + x} + \frac{-1}{x}\\
\mathbf{if}\;t_0 \leq -1000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;{x}^{-3} + \mathsf{fma}\left(1, {x}^{-5}, \mathsf{fma}\left(-1, {x}^{-2}, -{x}^{-4}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + \left(-1 - x\right)}{1 + x}}{x}\\
\end{array}
if (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 1 x)) < -1e3Initial program 0.0
if -1e3 < (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 1 x)) < 0.0Initial program 28.9
Taylor expanded in x around inf 1.4
Simplified1.4
Applied egg-rr0.7
Applied egg-rr0.7
if 0.0 < (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 1 x)) Initial program 0.0
Applied egg-rr0.0
Final simplification0.4
herbie shell --seed 2022190
(FPCore (x)
:name "2frac (problem 3.3.1)"
:precision binary64
(- (/ 1.0 (+ x 1.0)) (/ 1.0 x)))