Average Error: 0.0 → 0.0
Time: 1.3s
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 r121790 = 1.0;
        double r121791 = x;
        double r121792 = r121791 - r121790;
        double r121793 = r121790 / r121792;
        double r121794 = r121791 + r121790;
        double r121795 = r121791 / r121794;
        double r121796 = r121793 + r121795;
        return r121796;
}

double f(double x) {
        double r121797 = 1.0;
        double r121798 = x;
        double r121799 = r121798 * r121798;
        double r121800 = r121797 * r121797;
        double r121801 = r121799 - r121800;
        double r121802 = r121797 / r121801;
        double r121803 = r121798 + r121797;
        double r121804 = r121798 / r121803;
        double r121805 = fma(r121802, r121803, r121804);
        return r121805;
}

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