Average Error: 9.9 → 0.1
Time: 12.0s
Precision: 64
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\frac{\frac{2}{x \cdot x - 1}}{x}\]
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\frac{\frac{2}{x \cdot x - 1}}{x}
double f(double x) {
        double r1885809 = 1.0;
        double r1885810 = x;
        double r1885811 = r1885810 + r1885809;
        double r1885812 = r1885809 / r1885811;
        double r1885813 = 2.0;
        double r1885814 = r1885813 / r1885810;
        double r1885815 = r1885812 - r1885814;
        double r1885816 = r1885810 - r1885809;
        double r1885817 = r1885809 / r1885816;
        double r1885818 = r1885815 + r1885817;
        return r1885818;
}

double f(double x) {
        double r1885819 = 2.0;
        double r1885820 = x;
        double r1885821 = r1885820 * r1885820;
        double r1885822 = 1.0;
        double r1885823 = r1885821 - r1885822;
        double r1885824 = r1885819 / r1885823;
        double r1885825 = r1885824 / r1885820;
        return r1885825;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 9.9

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

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

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

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

    \[\leadsto \frac{\left(\left(x + 1\right) \cdot -2 + x\right) \cdot \left(x + -1\right) + \left(x + 1\right) \cdot x}{\color{blue}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x + -1\right)}}\]
  7. Taylor expanded around inf 0.3

    \[\leadsto \frac{\color{blue}{2}}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x + -1\right)}\]
  8. Using strategy rm
  9. Applied associate-/r*0.1

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

    \[\leadsto \frac{\frac{2}{\left(x + 1\right) \cdot x}}{\color{blue}{1 \cdot \left(x + -1\right)}}\]
  12. Applied *-un-lft-identity0.1

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

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

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

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

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

Reproduce

herbie shell --seed 2019128 
(FPCore (x)
  :name "3frac (problem 3.3.3)"

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

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