Average Error: 10.6 → 0.1
Time: 8.7s
Precision: 64
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\frac{\frac{2}{x \cdot x - 1 \cdot 1}}{x}\]
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\frac{\frac{2}{x \cdot x - 1 \cdot 1}}{x}
double f(double x) {
        double r101446 = 1.0;
        double r101447 = x;
        double r101448 = r101447 + r101446;
        double r101449 = r101446 / r101448;
        double r101450 = 2.0;
        double r101451 = r101450 / r101447;
        double r101452 = r101449 - r101451;
        double r101453 = r101447 - r101446;
        double r101454 = r101446 / r101453;
        double r101455 = r101452 + r101454;
        return r101455;
}

double f(double x) {
        double r101456 = 2.0;
        double r101457 = x;
        double r101458 = r101457 * r101457;
        double r101459 = 1.0;
        double r101460 = r101459 * r101459;
        double r101461 = r101458 - r101460;
        double r101462 = r101456 / r101461;
        double r101463 = r101462 / r101457;
        return r101463;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.6
Target0.3
Herbie0.1
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]

Derivation

  1. Initial program 10.6

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
  2. Using strategy rm
  3. Applied frac-sub26.2

    \[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 2}{\left(x + 1\right) \cdot x}} + \frac{1}{x - 1}\]
  4. Applied frac-add25.6

    \[\leadsto \color{blue}{\frac{\left(1 \cdot x - \left(x + 1\right) \cdot 2\right) \cdot \left(x - 1\right) + \left(\left(x + 1\right) \cdot x\right) \cdot 1}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}}\]
  5. Simplified26.0

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(1 \cdot x - \left(x + 1\right) \cdot 2, x - 1, \left(\left(x + 1\right) \cdot x\right) \cdot 1\right)}}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\]
  6. Taylor expanded around 0 0.3

    \[\leadsto \frac{\color{blue}{2}}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\]
  7. Using strategy rm
  8. Applied *-un-lft-identity0.3

    \[\leadsto \frac{\color{blue}{1 \cdot 2}}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\]
  9. Applied times-frac0.1

    \[\leadsto \color{blue}{\frac{1}{\left(x + 1\right) \cdot x} \cdot \frac{2}{x - 1}}\]
  10. Using strategy rm
  11. Applied pow10.1

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

    \[\leadsto \color{blue}{{\left(\frac{1}{\left(x + 1\right) \cdot x}\right)}^{1}} \cdot {\left(\frac{2}{x - 1}\right)}^{1}\]
  13. Applied pow-prod-down0.1

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

    \[\leadsto {\color{blue}{\left(\frac{\frac{2}{x \cdot x - 1 \cdot 1}}{x}\right)}}^{1}\]
  15. Final simplification0.1

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

Reproduce

herbie shell --seed 2020045 +o rules:numerics
(FPCore (x)
  :name "3frac (problem 3.3.3)"
  :precision binary64

  :herbie-target
  (/ 2 (* x (- (* x x) 1)))

  (+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))