Average Error: 0.0 → 0.0
Time: 9.7s
Precision: 64
\[\frac{1}{x - 1} + \frac{x}{x + 1}\]
\[\mathsf{fma}\left(\frac{1}{x \cdot x - 1 \cdot 1}, x + 1, \frac{x}{x + 1}\right)\]
\frac{1}{x - 1} + \frac{x}{x + 1}
\mathsf{fma}\left(\frac{1}{x \cdot x - 1 \cdot 1}, x + 1, \frac{x}{x + 1}\right)
double f(double x) {
        double r4954484 = 1.0;
        double r4954485 = x;
        double r4954486 = r4954485 - r4954484;
        double r4954487 = r4954484 / r4954486;
        double r4954488 = r4954485 + r4954484;
        double r4954489 = r4954485 / r4954488;
        double r4954490 = r4954487 + r4954489;
        return r4954490;
}

double f(double x) {
        double r4954491 = 1.0;
        double r4954492 = x;
        double r4954493 = r4954492 * r4954492;
        double r4954494 = r4954491 * r4954491;
        double r4954495 = r4954493 - r4954494;
        double r4954496 = r4954491 / r4954495;
        double r4954497 = r4954492 + r4954491;
        double r4954498 = r4954492 / r4954497;
        double r4954499 = fma(r4954496, r4954497, r4954498);
        return r4954499;
}

Error

Bits error versus x

Derivation

  1. Initial program 0.0

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

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

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

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

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

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (x)
  :name "Asymptote B"
  (+ (/ 1.0 (- x 1.0)) (/ x (+ x 1.0))))