Average Error: 14.0 → 0.4
Time: 4.3s
Precision: binary64
\[\frac{1}{x + 1} - \frac{1}{x - 1} \]
\[\frac{1}{\mathsf{fma}\left(x, x, -1\right)} \cdot -2 \]
\frac{1}{x + 1} - \frac{1}{x - 1}
\frac{1}{\mathsf{fma}\left(x, x, -1\right)} \cdot -2
(FPCore (x) :precision binary64 (- (/ 1.0 (+ x 1.0)) (/ 1.0 (- x 1.0))))
(FPCore (x) :precision binary64 (* (/ 1.0 (fma x x -1.0)) -2.0))
double code(double x) {
	return (1.0 / (x + 1.0)) - (1.0 / (x - 1.0));
}
double code(double x) {
	return (1.0 / fma(x, x, -1.0)) * -2.0;
}

Error

Bits error versus x

Derivation

  1. Initial program 14.0

    \[\frac{1}{x + 1} - \frac{1}{x - 1} \]
  2. Applied add-cube-cbrt_binary6425.6

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

    \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x - 1}}} - \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}\right) \cdot \sqrt[3]{\frac{1}{x - 1}} \]
  4. Applied associate-/r/_binary6428.3

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{x \cdot x - 1 \cdot 1}, x - 1, -\sqrt[3]{\frac{1}{x - 1}} \cdot \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\frac{1}{x - 1}}, \sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}, \sqrt[3]{\frac{1}{x - 1}} \cdot \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}\right)\right)} \]
  6. Simplified27.3

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

    \[\leadsto \frac{1}{\mathsf{fma}\left(x, x, -1\right)} \cdot \left(x - \left(2 + x\right)\right) + \color{blue}{0} \]
  8. Taylor expanded in x around 0 0.4

    \[\leadsto \frac{1}{\mathsf{fma}\left(x, x, -1\right)} \cdot \color{blue}{-2} + 0 \]
  9. Final simplification0.4

    \[\leadsto \frac{1}{\mathsf{fma}\left(x, x, -1\right)} \cdot -2 \]

Reproduce

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