Average Error: 0.0 → 0.0
Time: 7.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 r127594 = 1.0;
        double r127595 = x;
        double r127596 = r127595 - r127594;
        double r127597 = r127594 / r127596;
        double r127598 = r127595 + r127594;
        double r127599 = r127595 / r127598;
        double r127600 = r127597 + r127599;
        return r127600;
}

double f(double x) {
        double r127601 = 1.0;
        double r127602 = x;
        double r127603 = r127602 * r127602;
        double r127604 = r127601 * r127601;
        double r127605 = r127603 - r127604;
        double r127606 = r127601 / r127605;
        double r127607 = r127602 + r127601;
        double r127608 = r127602 / r127607;
        double r127609 = fma(r127606, r127607, r127608);
        return r127609;
}

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))))