Average Error: 14.6 → 0.4
Time: 4.4m
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x - 1}\]
\[-2 \cdot \mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\frac{1}{\mathsf{fma}\left(x, x, -1\right)}\right)\right)\right)\right)\]
\frac{1}{x + 1} - \frac{1}{x - 1}
-2 \cdot \mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\frac{1}{\mathsf{fma}\left(x, x, -1\right)}\right)\right)\right)\right)
double f(double x) {
        double r30253942 = 1.0;
        double r30253943 = x;
        double r30253944 = r30253943 + r30253942;
        double r30253945 = r30253942 / r30253944;
        double r30253946 = r30253943 - r30253942;
        double r30253947 = r30253942 / r30253946;
        double r30253948 = r30253945 - r30253947;
        return r30253948;
}

double f(double x) {
        double r30253949 = -2.0;
        double r30253950 = 1.0;
        double r30253951 = x;
        double r30253952 = -1.0;
        double r30253953 = fma(r30253951, r30253951, r30253952);
        double r30253954 = r30253950 / r30253953;
        double r30253955 = expm1(r30253954);
        double r30253956 = log1p(r30253955);
        double r30253957 = r30253949 * r30253956;
        return r30253957;
}

Error

Bits error versus x

Derivation

  1. Initial program 14.6

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

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

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

    \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x - 1}}} - \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
  6. Applied associate-/r/14.6

    \[\leadsto \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x - 1\right)} - \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
  7. Applied distribute-lft-out--14.0

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

    \[\leadsto \frac{1}{x \cdot x - 1 \cdot 1} \cdot \color{blue}{-2}\]
  9. Using strategy rm
  10. Applied log1p-expm1-u0.4

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\frac{1}{x \cdot x - 1 \cdot 1}\right)\right)\right)\right)} \cdot -2\]
  11. Simplified0.4

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

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

Reproduce

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