Average Error: 10.4 → 0.1
Time: 21.4s
Precision: 64
Internal Precision: 128
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -110.56724252360748 \lor \neg \left(x \le 119.42445688643173\right):\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{\frac{2}{x}}{x \cdot x} + \frac{2}{{x}^{7}}\right)\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{1}{(\left(x \cdot x\right) \cdot x + 1)_*}\right) \cdot \left(x \cdot x + \left(1 - x\right)\right) + \left(\frac{-2}{x}\right))_* + \frac{1}{x - 1}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -110.56724252360748 or 119.42445688643173 < x

    1. Initial program 20.4

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

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

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

    if -110.56724252360748 < x < 119.42445688643173

    1. Initial program 0.1

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

      \[\leadsto \left(\frac{1}{\color{blue}{\frac{{x}^{3} + {1}^{3}}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}}} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    4. Applied associate-/r/0.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -110.56724252360748 \lor \neg \left(x \le 119.42445688643173\right):\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{\frac{2}{x}}{x \cdot x} + \frac{2}{{x}^{7}}\right)\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{1}{(\left(x \cdot x\right) \cdot x + 1)_*}\right) \cdot \left(x \cdot x + \left(1 - x\right)\right) + \left(\frac{-2}{x}\right))_* + \frac{1}{x - 1}\\ \end{array}\]

Reproduce

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

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

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