Average Error: 9.6 → 0.6
Time: 14.2s
Precision: 64
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\frac{\sqrt{2}}{\left(x + 1\right) \cdot x} \cdot \left(\frac{\sqrt{2}}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\right)\]
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\frac{\sqrt{2}}{\left(x + 1\right) \cdot x} \cdot \left(\frac{\sqrt{2}}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\right)
double f(double x) {
        double r94658 = 1.0;
        double r94659 = x;
        double r94660 = r94659 + r94658;
        double r94661 = r94658 / r94660;
        double r94662 = 2.0;
        double r94663 = r94662 / r94659;
        double r94664 = r94661 - r94663;
        double r94665 = r94659 - r94658;
        double r94666 = r94658 / r94665;
        double r94667 = r94664 + r94666;
        return r94667;
}

double f(double x) {
        double r94668 = 2.0;
        double r94669 = sqrt(r94668);
        double r94670 = x;
        double r94671 = 1.0;
        double r94672 = r94670 + r94671;
        double r94673 = r94672 * r94670;
        double r94674 = r94669 / r94673;
        double r94675 = r94670 * r94670;
        double r94676 = r94671 * r94671;
        double r94677 = r94675 - r94676;
        double r94678 = r94669 / r94677;
        double r94679 = r94678 * r94672;
        double r94680 = r94674 * r94679;
        return r94680;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 9.6

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

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

    \[\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. Using strategy rm
  6. Applied flip--25.1

    \[\leadsto \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 \color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}}}\]
  7. Applied associate-*r/25.1

    \[\leadsto \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}{\color{blue}{\frac{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x \cdot x - 1 \cdot 1\right)}{x + 1}}}\]
  8. Applied associate-/r/25.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 \cdot x - 1 \cdot 1\right)} \cdot \left(x + 1\right)}\]
  9. Taylor expanded around 0 2.7

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

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

    \[\leadsto \color{blue}{\left(\frac{\sqrt{2}}{\left(x + 1\right) \cdot x} \cdot \frac{\sqrt{2}}{x \cdot x - 1 \cdot 1}\right)} \cdot \left(x + 1\right)\]
  13. Applied associate-*l*0.6

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

    \[\leadsto \frac{\sqrt{2}}{\left(x + 1\right) \cdot x} \cdot \left(\frac{\sqrt{2}}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\right)\]

Reproduce

herbie shell --seed 2019304 
(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))))