Average Error: 0.0 → 0.0
Time: 2.4s
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 r127270 = 1.0;
        double r127271 = x;
        double r127272 = r127271 - r127270;
        double r127273 = r127270 / r127272;
        double r127274 = r127271 + r127270;
        double r127275 = r127271 / r127274;
        double r127276 = r127273 + r127275;
        return r127276;
}

double f(double x) {
        double r127277 = 1.0;
        double r127278 = x;
        double r127279 = r127278 * r127278;
        double r127280 = r127277 * r127277;
        double r127281 = r127279 - r127280;
        double r127282 = r127277 / r127281;
        double r127283 = r127278 + r127277;
        double r127284 = r127278 / r127283;
        double r127285 = fma(r127282, r127283, r127284);
        return r127285;
}

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