(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 -0.00137820529123793)
(/ (+ x (- -1.0 x)) (* x (+ 1.0 x)))
(if (<= t_0 0.0)
(- (pow x -3.0) (pow x -2.0))
(- (cbrt (pow (+ 1.0 x) -3.0)) (/ 1.0 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 <= -0.00137820529123793) {
tmp = (x + (-1.0 - x)) / (x * (1.0 + x));
} else if (t_0 <= 0.0) {
tmp = pow(x, -3.0) - pow(x, -2.0);
} else {
tmp = cbrt(pow((1.0 + x), -3.0)) - (1.0 / x);
}
return tmp;
}
public static double code(double x) {
return (1.0 / (x + 1.0)) - (1.0 / x);
}
public static double code(double x) {
double t_0 = (1.0 / (1.0 + x)) - (1.0 / x);
double tmp;
if (t_0 <= -0.00137820529123793) {
tmp = (x + (-1.0 - x)) / (x * (1.0 + x));
} else if (t_0 <= 0.0) {
tmp = Math.pow(x, -3.0) - Math.pow(x, -2.0);
} else {
tmp = Math.cbrt(Math.pow((1.0 + x), -3.0)) - (1.0 / 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 <= -0.00137820529123793) tmp = Float64(Float64(x + Float64(-1.0 - x)) / Float64(x * Float64(1.0 + x))); elseif (t_0 <= 0.0) tmp = Float64((x ^ -3.0) - (x ^ -2.0)); else tmp = Float64(cbrt((Float64(1.0 + x) ^ -3.0)) - Float64(1.0 / 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, -0.00137820529123793], N[(N[(x + N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[Power[x, -3.0], $MachinePrecision] - N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], -3.0], $MachinePrecision], 1/3], $MachinePrecision] - N[(1.0 / x), $MachinePrecision]), $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 -0.00137820529123793:\\
\;\;\;\;\frac{x + \left(-1 - x\right)}{x \cdot \left(1 + x\right)}\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;{x}^{-3} - {x}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(1 + x\right)}^{-3}} - \frac{1}{x}\\
\end{array}



Bits error versus x
Results
if (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 1 x)) < -0.00137820529123793Initial program 0.0
Applied egg-rr0.0
if -0.00137820529123793 < (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 1 x)) < 0.0Initial program 29.0
Taylor expanded in x around inf 1.3
Applied egg-rr0.5
if 0.0 < (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 1 x)) Initial program 0.0
Applied egg-rr0.0
Final simplification0.2
herbie shell --seed 2022133
(FPCore (x)
:name "2frac (problem 3.3.1)"
:precision binary64
(- (/ 1.0 (+ x 1.0)) (/ 1.0 x)))