Average Error: 9.9 → 0.3
Time: 23.8s
Precision: 64
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -15233605608570183745536:\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{2}{\left(x \cdot x\right) \cdot x} + \frac{2}{{x}^{7}}\right)\\ \mathbf{elif}\;x \le 2.90855978378677886742036867493164367335 \cdot 10^{61}:\\ \;\;\;\;\frac{2}{\left(\left(x + 1\right) \cdot x\right) \cdot \left({x}^{3} - \left(1 \cdot 1\right) \cdot 1\right)} \cdot \left(x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{2}{\left(x \cdot x\right) \cdot x} + \frac{2}{{x}^{7}}\right)\\ \end{array}\]
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -15233605608570183745536:\\
\;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{2}{\left(x \cdot x\right) \cdot x} + \frac{2}{{x}^{7}}\right)\\

\mathbf{elif}\;x \le 2.90855978378677886742036867493164367335 \cdot 10^{61}:\\
\;\;\;\;\frac{2}{\left(\left(x + 1\right) \cdot x\right) \cdot \left({x}^{3} - \left(1 \cdot 1\right) \cdot 1\right)} \cdot \left(x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{2}{\left(x \cdot x\right) \cdot x} + \frac{2}{{x}^{7}}\right)\\

\end{array}
double f(double x) {
        double r8880704 = 1.0;
        double r8880705 = x;
        double r8880706 = r8880705 + r8880704;
        double r8880707 = r8880704 / r8880706;
        double r8880708 = 2.0;
        double r8880709 = r8880708 / r8880705;
        double r8880710 = r8880707 - r8880709;
        double r8880711 = r8880705 - r8880704;
        double r8880712 = r8880704 / r8880711;
        double r8880713 = r8880710 + r8880712;
        return r8880713;
}

double f(double x) {
        double r8880714 = x;
        double r8880715 = -1.5233605608570184e+22;
        bool r8880716 = r8880714 <= r8880715;
        double r8880717 = 2.0;
        double r8880718 = 5.0;
        double r8880719 = pow(r8880714, r8880718);
        double r8880720 = r8880717 / r8880719;
        double r8880721 = r8880714 * r8880714;
        double r8880722 = r8880721 * r8880714;
        double r8880723 = r8880717 / r8880722;
        double r8880724 = 7.0;
        double r8880725 = pow(r8880714, r8880724);
        double r8880726 = r8880717 / r8880725;
        double r8880727 = r8880723 + r8880726;
        double r8880728 = r8880720 + r8880727;
        double r8880729 = 2.908559783786779e+61;
        bool r8880730 = r8880714 <= r8880729;
        double r8880731 = 1.0;
        double r8880732 = r8880714 + r8880731;
        double r8880733 = r8880732 * r8880714;
        double r8880734 = 3.0;
        double r8880735 = pow(r8880714, r8880734);
        double r8880736 = r8880731 * r8880731;
        double r8880737 = r8880736 * r8880731;
        double r8880738 = r8880735 - r8880737;
        double r8880739 = r8880733 * r8880738;
        double r8880740 = r8880717 / r8880739;
        double r8880741 = r8880714 * r8880731;
        double r8880742 = r8880736 + r8880741;
        double r8880743 = r8880721 + r8880742;
        double r8880744 = r8880740 * r8880743;
        double r8880745 = r8880730 ? r8880744 : r8880728;
        double r8880746 = r8880716 ? r8880728 : r8880745;
        return r8880746;
}

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.3
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -1.5233605608570184e+22 or 2.908559783786779e+61 < x

    1. Initial program 14.7

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Using strategy rm
    3. Applied frac-sub50.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-add50.8

      \[\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. Taylor expanded around inf 0.6

      \[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{7}} + \left(2 \cdot \frac{1}{{x}^{3}} + 2 \cdot \frac{1}{{x}^{5}}\right)}\]
    6. Simplified0.6

      \[\leadsto \color{blue}{\frac{2}{{x}^{5}} + \left(\frac{2}{\left(x \cdot x\right) \cdot x} + \frac{2}{{x}^{7}}\right)}\]

    if -1.5233605608570184e+22 < x < 2.908559783786779e+61

    1. Initial program 6.1

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

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

      \[\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 flip3--5.4

      \[\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}^{3} - {1}^{3}}{x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)}}}\]
    7. Applied associate-*r/5.4

      \[\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}^{3} - {1}^{3}\right)}{x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)}}}\]
    8. Applied associate-/r/5.4

      \[\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}^{3} - {1}^{3}\right)} \cdot \left(x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)\right)}\]
    9. Simplified5.4

      \[\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(\left(x \cdot x\right) \cdot x - \left(1 \cdot 1\right) \cdot 1\right)}} \cdot \left(x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)\right)\]
    10. Taylor expanded around 0 0.1

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

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

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

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

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

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

      \[\leadsto \frac{2}{\left(\left(x + 1\right) \cdot x\right) \cdot \left({x}^{\color{blue}{3}} - \left(1 \cdot 1\right) \cdot 1\right)} \cdot \left(x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -15233605608570183745536:\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{2}{\left(x \cdot x\right) \cdot x} + \frac{2}{{x}^{7}}\right)\\ \mathbf{elif}\;x \le 2.90855978378677886742036867493164367335 \cdot 10^{61}:\\ \;\;\;\;\frac{2}{\left(\left(x + 1\right) \cdot x\right) \cdot \left({x}^{3} - \left(1 \cdot 1\right) \cdot 1\right)} \cdot \left(x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{2}{\left(x \cdot x\right) \cdot x} + \frac{2}{{x}^{7}}\right)\\ \end{array}\]

Reproduce

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

  :herbie-target
  (/ 2.0 (* x (- (* x x) 1.0)))

  (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))