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 r5748311 = 1.0;
        double r5748312 = x;
        double r5748313 = r5748312 - r5748311;
        double r5748314 = r5748311 / r5748313;
        double r5748315 = r5748312 + r5748311;
        double r5748316 = r5748312 / r5748315;
        double r5748317 = r5748314 + r5748316;
        return r5748317;
}

double f(double x) {
        double r5748318 = 1.0;
        double r5748319 = x;
        double r5748320 = r5748319 * r5748319;
        double r5748321 = r5748318 * r5748318;
        double r5748322 = r5748320 - r5748321;
        double r5748323 = r5748318 / r5748322;
        double r5748324 = r5748319 + r5748318;
        double r5748325 = r5748319 / r5748324;
        double r5748326 = fma(r5748323, r5748324, r5748325);
        return r5748326;
}

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