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

Error

Bits error versus x

Derivation

  1. Initial program 14.7

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

    \[\leadsto \color{blue}{\frac{1 \cdot \left(x - 1\right) - \left(x + 1\right) \cdot 1}{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
  3. Simplified13.9

    \[\leadsto \frac{\color{blue}{x - \left(2 + x\right)}}{\left(x + 1\right) \cdot \left(x - 1\right)} \]
  4. Simplified13.9

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

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

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

Reproduce

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