Average Error: 29.9 → 0.2
Time: 3.8s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[-\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(3, x, 1\right)}{x + 1}\right)\right)}{x - 1}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
-\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(3, x, 1\right)}{x + 1}\right)\right)}{x - 1}
double f(double x) {
        double r100401 = x;
        double r100402 = 1.0;
        double r100403 = r100401 + r100402;
        double r100404 = r100401 / r100403;
        double r100405 = r100401 - r100402;
        double r100406 = r100403 / r100405;
        double r100407 = r100404 - r100406;
        return r100407;
}

double f(double x) {
        double r100408 = 3.0;
        double r100409 = x;
        double r100410 = 1.0;
        double r100411 = fma(r100408, r100409, r100410);
        double r100412 = r100409 + r100410;
        double r100413 = r100411 / r100412;
        double r100414 = log1p(r100413);
        double r100415 = expm1(r100414);
        double r100416 = r100409 - r100410;
        double r100417 = r100415 / r100416;
        double r100418 = -r100417;
        return r100418;
}

Error

Bits error versus x

Derivation

  1. Initial program 29.9

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

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

    \[\leadsto \frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\color{blue}{x \cdot x - 1 \cdot 1}}\]
  5. Taylor expanded around 0 15.1

    \[\leadsto \frac{\color{blue}{-\left(3 \cdot x + 1\right)}}{x \cdot x - 1 \cdot 1}\]
  6. Using strategy rm
  7. Applied distribute-frac-neg15.1

    \[\leadsto \color{blue}{-\frac{3 \cdot x + 1}{x \cdot x - 1 \cdot 1}}\]
  8. Simplified0.2

    \[\leadsto -\color{blue}{\frac{\frac{\mathsf{fma}\left(3, x, 1\right)}{x + 1}}{x - 1}}\]
  9. Using strategy rm
  10. Applied expm1-log1p-u0.2

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

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

Reproduce

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