Average Error: 9.8 → 1.1
Time: 52.3s
Precision: 64
Internal Precision: 1088
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;\left(\sqrt[3]{\frac{2}{x \cdot x}} \cdot \frac{\sqrt[3]{\frac{2}{x \cdot x}}}{x}\right) \cdot \sqrt[3]{\frac{\frac{2}{x}}{x}} + \left(\frac{2}{{x}^{5}} + \frac{2}{{x}^{7}}\right) \le -1.7995936082741617 \cdot 10^{-25}:\\ \;\;\;\;\frac{\left(x - 1\right) \cdot \left(x - 2 \cdot \left(1 + x\right)\right) + x \cdot \left(1 + x\right)}{\left(x - 1\right) \cdot \left(x \cdot \left(1 + x\right)\right)}\\ \mathbf{if}\;\left(\sqrt[3]{\frac{2}{x \cdot x}} \cdot \frac{\sqrt[3]{\frac{2}{x \cdot x}}}{x}\right) \cdot \sqrt[3]{\frac{\frac{2}{x}}{x}} + \left(\frac{2}{{x}^{5}} + \frac{2}{{x}^{7}}\right) \le 1.0690408468969486 \cdot 10^{-70}:\\ \;\;\;\;\left(\frac{2}{{x}^{5}} + \frac{2}{{x}^{7}}\right) + \frac{\frac{2}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - 2\right) - x \cdot 2}{x \cdot \left(1 + x\right)} + \frac{1}{x - 1}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.8
Target0.2
Herbie1.1
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]

Derivation

  1. Split input into 3 regimes
  2. if (+ (+ (/ 2 (pow x 7)) (/ 2 (pow x 5))) (* (* (/ (cbrt (/ 2 (* x x))) x) (cbrt (/ 2 (* x x)))) (cbrt (/ (/ 2 x) x)))) < -1.7995936082741617e-25

    1. Initial program 0.7

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

    if -1.7995936082741617e-25 < (+ (+ (/ 2 (pow x 7)) (/ 2 (pow x 5))) (* (* (/ (cbrt (/ 2 (* x x))) x) (cbrt (/ 2 (* x x)))) (cbrt (/ (/ 2 x) x)))) < 1.0690408468969486e-70

    1. Initial program 18.0

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Taylor expanded around inf 0.5

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

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

    if 1.0690408468969486e-70 < (+ (+ (/ 2 (pow x 7)) (/ 2 (pow x 5))) (* (* (/ (cbrt (/ 2 (* x x))) x) (cbrt (/ 2 (* x x)))) (cbrt (/ (/ 2 x) x))))

    1. Initial program 3.9

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\left(\sqrt[3]{\frac{2}{x \cdot x}} \cdot \frac{\sqrt[3]{\frac{2}{x \cdot x}}}{x}\right) \cdot \sqrt[3]{\frac{\frac{2}{x}}{x}} + \left(\frac{2}{{x}^{5}} + \frac{2}{{x}^{7}}\right) \le -1.7995936082741617 \cdot 10^{-25}:\\ \;\;\;\;\frac{\left(x - 1\right) \cdot \left(x - 2 \cdot \left(1 + x\right)\right) + x \cdot \left(1 + x\right)}{\left(x - 1\right) \cdot \left(x \cdot \left(1 + x\right)\right)}\\ \mathbf{if}\;\left(\sqrt[3]{\frac{2}{x \cdot x}} \cdot \frac{\sqrt[3]{\frac{2}{x \cdot x}}}{x}\right) \cdot \sqrt[3]{\frac{\frac{2}{x}}{x}} + \left(\frac{2}{{x}^{5}} + \frac{2}{{x}^{7}}\right) \le 1.0690408468969486 \cdot 10^{-70}:\\ \;\;\;\;\left(\frac{2}{{x}^{5}} + \frac{2}{{x}^{7}}\right) + \frac{\frac{2}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - 2\right) - x \cdot 2}{x \cdot \left(1 + x\right)} + \frac{1}{x - 1}\\ \end{array}}\]

Runtime

Time bar (total: 52.3s)Debug logProfile

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

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

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