Average Error: 14.7 → 0.1
Time: 14.1s
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 r7530239 = 1.0;
        double r7530240 = x;
        double r7530241 = r7530240 + r7530239;
        double r7530242 = r7530239 / r7530241;
        double r7530243 = r7530240 - r7530239;
        double r7530244 = r7530239 / r7530243;
        double r7530245 = r7530242 - r7530244;
        return r7530245;
}

double f(double x) {
        double r7530246 = 2.0;
        double r7530247 = -r7530246;
        double r7530248 = x;
        double r7530249 = 1.0;
        double r7530250 = r7530248 + r7530249;
        double r7530251 = r7530247 / r7530250;
        double r7530252 = r7530248 - r7530249;
        double r7530253 = r7530251 / r7530252;
        double r7530254 = r7530253 * r7530249;
        return r7530254;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 14.7

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

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

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

    \[\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.7

    \[\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.1

    \[\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.3

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

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

    \[\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}{x + 1}}{x - 1}}\]
  13. Final simplification0.1

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

Reproduce

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