Average Error: 14.8 → 0.1
Time: 14.8s
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x - 1}\]
\[\frac{\frac{-2}{x + 1}}{x - 1} \cdot 1\]
\frac{1}{x + 1} - \frac{1}{x - 1}
\frac{\frac{-2}{x + 1}}{x - 1} \cdot 1
double f(double x) {
        double r4430097 = 1.0;
        double r4430098 = x;
        double r4430099 = r4430098 + r4430097;
        double r4430100 = r4430097 / r4430099;
        double r4430101 = r4430098 - r4430097;
        double r4430102 = r4430097 / r4430101;
        double r4430103 = r4430100 - r4430102;
        return r4430103;
}

double f(double x) {
        double r4430104 = 2.0;
        double r4430105 = -r4430104;
        double r4430106 = x;
        double r4430107 = 1.0;
        double r4430108 = r4430106 + r4430107;
        double r4430109 = r4430105 / r4430108;
        double r4430110 = r4430106 - r4430107;
        double r4430111 = r4430109 / r4430110;
        double r4430112 = r4430111 * r4430107;
        return r4430112;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 14.8

    \[\frac{1}{x + 1} - \frac{1}{x - 1}\]
  2. Using strategy rm
  3. Applied flip--29.2

    \[\leadsto \frac{1}{x + 1} - \frac{1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}}}\]
  4. Applied associate-/r/29.2

    \[\leadsto \frac{1}{x + 1} - \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)}\]
  5. Applied flip-+14.8

    \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x - 1}}} - \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
  6. Applied associate-/r/14.8

    \[\leadsto \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x - 1\right)} - \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
  7. Applied distribute-lft-out--14.2

    \[\leadsto \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(x - 1\right) - \left(x + 1\right)\right)}\]
  8. Taylor expanded around 0 0.4

    \[\leadsto \frac{1}{x \cdot x - 1 \cdot 1} \cdot \color{blue}{\left(-2\right)}\]
  9. Using strategy rm
  10. Applied div-inv0.4

    \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{x \cdot x - 1 \cdot 1}\right)} \cdot \left(-2\right)\]
  11. Applied associate-*l*0.4

    \[\leadsto \color{blue}{1 \cdot \left(\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(-2\right)\right)}\]
  12. Simplified0.1

    \[\leadsto 1 \cdot \color{blue}{\frac{\frac{-2}{1 + x}}{x - 1}}\]
  13. Final simplification0.1

    \[\leadsto \frac{\frac{-2}{x + 1}}{x - 1} \cdot 1\]

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x)
  :name "Asymptote A"
  (- (/ 1.0 (+ x 1.0)) (/ 1.0 (- x 1.0))))