Average Error: 0.0 → 0.0
Time: 5.2s
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 r208722 = 1.0;
        double r208723 = x;
        double r208724 = r208723 - r208722;
        double r208725 = r208722 / r208724;
        double r208726 = r208723 + r208722;
        double r208727 = r208723 / r208726;
        double r208728 = r208725 + r208727;
        return r208728;
}

double f(double x) {
        double r208729 = 1.0;
        double r208730 = x;
        double r208731 = r208730 * r208730;
        double r208732 = r208729 * r208729;
        double r208733 = r208731 - r208732;
        double r208734 = r208729 / r208733;
        double r208735 = r208730 + r208729;
        double r208736 = r208730 / r208735;
        double r208737 = fma(r208734, r208735, r208736);
        return r208737;
}

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 2020045 +o rules:numerics
(FPCore (x)
  :name "Asymptote B"
  :precision binary64
  (+ (/ 1 (- x 1)) (/ x (+ x 1))))