Average Error: 14.7 → 0.0
Time: 2.5s
Precision: binary64
\[\frac{1}{x + 1} - \frac{1}{x - 1} \]
\[\begin{array}{l} t_0 := -2 \cdot {x}^{-2} + \left(\frac{-2}{{x}^{6}} - \frac{2}{{x}^{4}}\right)\\ \mathbf{if}\;x \leq -220.90960044263244:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 218.49470597842105:\\ \;\;\;\;\frac{1}{x + 1} + \mathsf{fma}\left(x, x, x + 1\right) \cdot \frac{-1}{{x}^{3} + -1}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x) :precision binary64 (- (/ 1.0 (+ x 1.0)) (/ 1.0 (- x 1.0))))
(FPCore (x)
 :precision binary64
 (let* ((t_0
         (+
          (* -2.0 (pow x -2.0))
          (- (/ -2.0 (pow x 6.0)) (/ 2.0 (pow x 4.0))))))
   (if (<= x -220.90960044263244)
     t_0
     (if (<= x 218.49470597842105)
       (+
        (/ 1.0 (+ x 1.0))
        (* (fma x x (+ x 1.0)) (/ -1.0 (+ (pow x 3.0) -1.0))))
       t_0))))
double code(double x) {
	return (1.0 / (x + 1.0)) - (1.0 / (x - 1.0));
}
double code(double x) {
	double t_0 = (-2.0 * pow(x, -2.0)) + ((-2.0 / pow(x, 6.0)) - (2.0 / pow(x, 4.0)));
	double tmp;
	if (x <= -220.90960044263244) {
		tmp = t_0;
	} else if (x <= 218.49470597842105) {
		tmp = (1.0 / (x + 1.0)) + (fma(x, x, (x + 1.0)) * (-1.0 / (pow(x, 3.0) + -1.0)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x)
	return Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(1.0 / Float64(x - 1.0)))
end
function code(x)
	t_0 = Float64(Float64(-2.0 * (x ^ -2.0)) + Float64(Float64(-2.0 / (x ^ 6.0)) - Float64(2.0 / (x ^ 4.0))))
	tmp = 0.0
	if (x <= -220.90960044263244)
		tmp = t_0;
	elseif (x <= 218.49470597842105)
		tmp = Float64(Float64(1.0 / Float64(x + 1.0)) + Float64(fma(x, x, Float64(x + 1.0)) * Float64(-1.0 / Float64((x ^ 3.0) + -1.0))));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_] := N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(N[(-2.0 * N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-2.0 / N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] - N[(2.0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -220.90960044263244], t$95$0, If[LessEqual[x, 218.49470597842105], N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x * x + N[(x + 1.0), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(N[Power[x, 3.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\frac{1}{x + 1} - \frac{1}{x - 1}
\begin{array}{l}
t_0 := -2 \cdot {x}^{-2} + \left(\frac{-2}{{x}^{6}} - \frac{2}{{x}^{4}}\right)\\
\mathbf{if}\;x \leq -220.90960044263244:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 218.49470597842105:\\
\;\;\;\;\frac{1}{x + 1} + \mathsf{fma}\left(x, x, x + 1\right) \cdot \frac{-1}{{x}^{3} + -1}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -220.90960044263244 or 218.49470597842105 < x

    1. Initial program 29.4

      \[\frac{1}{x + 1} - \frac{1}{x - 1} \]
    2. Taylor expanded in x around inf 0.8

      \[\leadsto \color{blue}{-\left(2 \cdot \frac{1}{{x}^{4}} + \left(2 \cdot \frac{1}{{x}^{6}} + 2 \cdot \frac{1}{{x}^{2}}\right)\right)} \]
    3. Simplified0.8

      \[\leadsto \color{blue}{\frac{-2}{x \cdot x} + \left(\frac{-2}{{x}^{6}} - \frac{2}{{x}^{4}}\right)} \]
    4. Applied egg-rr0.0

      \[\leadsto \color{blue}{-2 \cdot {x}^{-2}} + \left(\frac{-2}{{x}^{6}} - \frac{2}{{x}^{4}}\right) \]

    if -220.90960044263244 < x < 218.49470597842105

    1. Initial program 0.0

      \[\frac{1}{x + 1} - \frac{1}{x - 1} \]
    2. Applied egg-rr0.0

      \[\leadsto \frac{1}{x + 1} - \color{blue}{\frac{1}{{x}^{3} + -1} \cdot \mathsf{fma}\left(x, x, 1 + x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -220.90960044263244:\\ \;\;\;\;-2 \cdot {x}^{-2} + \left(\frac{-2}{{x}^{6}} - \frac{2}{{x}^{4}}\right)\\ \mathbf{elif}\;x \leq 218.49470597842105:\\ \;\;\;\;\frac{1}{x + 1} + \mathsf{fma}\left(x, x, x + 1\right) \cdot \frac{-1}{{x}^{3} + -1}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot {x}^{-2} + \left(\frac{-2}{{x}^{6}} - \frac{2}{{x}^{4}}\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022153 
(FPCore (x)
  :name "Asymptote A"
  :precision binary64
  (- (/ 1.0 (+ x 1.0)) (/ 1.0 (- x 1.0))))