Average Error: 0.0 → 0.0
Time: 10.8s
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 r4892826 = 1.0;
        double r4892827 = x;
        double r4892828 = r4892827 - r4892826;
        double r4892829 = r4892826 / r4892828;
        double r4892830 = r4892827 + r4892826;
        double r4892831 = r4892827 / r4892830;
        double r4892832 = r4892829 + r4892831;
        return r4892832;
}

double f(double x) {
        double r4892833 = 1.0;
        double r4892834 = x;
        double r4892835 = r4892834 * r4892834;
        double r4892836 = r4892833 * r4892833;
        double r4892837 = r4892835 - r4892836;
        double r4892838 = r4892833 / r4892837;
        double r4892839 = r4892834 + r4892833;
        double r4892840 = r4892834 / r4892839;
        double r4892841 = fma(r4892838, r4892839, r4892840);
        return r4892841;
}

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 2019169 +o rules:numerics
(FPCore (x)
  :name "Asymptote B"
  (+ (/ 1.0 (- x 1.0)) (/ x (+ x 1.0))))