Average Error: 14.3 → 0.0
Time: 4.4s
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -232.232226491262992 \lor \neg \left(x \le 206.4399440620346\right):\\ \;\;\;\;\frac{-2}{{x}^{6}} - \mathsf{fma}\left(2, {x}^{\left(-2\right)}, 2 \cdot \frac{1}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x + 1} - \left(x + 1\right) \cdot \frac{1}{x \cdot x - 1 \cdot 1}\right) + \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(-\left(x + 1\right)\right) + \left(x + 1\right)\right)\\ \end{array}\]
\frac{1}{x + 1} - \frac{1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -232.232226491262992 \lor \neg \left(x \le 206.4399440620346\right):\\
\;\;\;\;\frac{-2}{{x}^{6}} - \mathsf{fma}\left(2, {x}^{\left(-2\right)}, 2 \cdot \frac{1}{{x}^{4}}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{x + 1} - \left(x + 1\right) \cdot \frac{1}{x \cdot x - 1 \cdot 1}\right) + \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(-\left(x + 1\right)\right) + \left(x + 1\right)\right)\\

\end{array}
double code(double x) {
	return ((1.0 / (x + 1.0)) - (1.0 / (x - 1.0)));
}
double code(double x) {
	double VAR;
	if (((x <= -232.232226491263) || !(x <= 206.43994406203456))) {
		VAR = ((-2.0 / pow(x, 6.0)) - fma(2.0, pow(x, -2.0), (2.0 * (1.0 / pow(x, 4.0)))));
	} else {
		VAR = (((1.0 / (x + 1.0)) - ((x + 1.0) * (1.0 / ((x * x) - (1.0 * 1.0))))) + ((1.0 / ((x * x) - (1.0 * 1.0))) * (-(x + 1.0) + (x + 1.0))));
	}
	return VAR;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -232.232226491263 or 206.43994406203456 < x

    1. Initial program 28.6

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

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

      \[\leadsto \color{blue}{\frac{-2}{{x}^{6}} - \mathsf{fma}\left(2, \frac{1}{{x}^{2}}, 2 \cdot \frac{1}{{x}^{4}}\right)}\]
    4. Using strategy rm
    5. Applied pow-flip0.0

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

    if -232.232226491263 < x < 206.43994406203456

    1. Initial program 0.0

      \[\frac{1}{x + 1} - \frac{1}{x - 1}\]
    2. Using strategy rm
    3. Applied flip--0.0

      \[\leadsto \frac{1}{x + 1} - \frac{1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}}}\]
    4. Applied associate-/r/0.0

      \[\leadsto \frac{1}{x + 1} - \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)}\]
    5. Applied add-sqr-sqrt0.3

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x + 1}} \cdot \sqrt{\frac{1}{x + 1}}} - \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
    6. Applied prod-diff0.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\frac{1}{x + 1}}, \sqrt{\frac{1}{x + 1}}, -\left(x + 1\right) \cdot \frac{1}{x \cdot x - 1 \cdot 1}\right) + \mathsf{fma}\left(-\left(x + 1\right), \frac{1}{x \cdot x - 1 \cdot 1}, \left(x + 1\right) \cdot \frac{1}{x \cdot x - 1 \cdot 1}\right)}\]
    7. Simplified0.0

      \[\leadsto \color{blue}{\left(\frac{1}{x + 1} - \left(x + 1\right) \cdot \frac{1}{x \cdot x - 1 \cdot 1}\right)} + \mathsf{fma}\left(-\left(x + 1\right), \frac{1}{x \cdot x - 1 \cdot 1}, \left(x + 1\right) \cdot \frac{1}{x \cdot x - 1 \cdot 1}\right)\]
    8. Simplified0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -232.232226491262992 \lor \neg \left(x \le 206.4399440620346\right):\\ \;\;\;\;\frac{-2}{{x}^{6}} - \mathsf{fma}\left(2, {x}^{\left(-2\right)}, 2 \cdot \frac{1}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x + 1} - \left(x + 1\right) \cdot \frac{1}{x \cdot x - 1 \cdot 1}\right) + \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(-\left(x + 1\right)\right) + \left(x + 1\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020103 +o rules:numerics
(FPCore (x)
  :name "Asymptote A"
  :precision binary64
  (- (/ 1 (+ x 1)) (/ 1 (- x 1))))