Average Error: 0.0 → 0.0
Time: 9.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 r3626783 = 1.0;
        double r3626784 = x;
        double r3626785 = r3626784 - r3626783;
        double r3626786 = r3626783 / r3626785;
        double r3626787 = r3626784 + r3626783;
        double r3626788 = r3626784 / r3626787;
        double r3626789 = r3626786 + r3626788;
        return r3626789;
}

double f(double x) {
        double r3626790 = 1.0;
        double r3626791 = x;
        double r3626792 = r3626791 * r3626791;
        double r3626793 = r3626790 * r3626790;
        double r3626794 = r3626792 - r3626793;
        double r3626795 = r3626790 / r3626794;
        double r3626796 = r3626791 + r3626790;
        double r3626797 = r3626791 / r3626796;
        double r3626798 = fma(r3626795, r3626796, r3626797);
        return r3626798;
}

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