Average Error: 9.4 → 0.4
Time: 51.0s
Precision: 64
Internal Precision: 1152
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{x - 1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right) \le -169303.44399670232:\\ \;\;\;\;(\left(\frac{1}{{1}^{3} + {x}^{3}}\right) \cdot \left(\left(1 - x\right) + x \cdot x\right) + \left(\frac{-2}{x}\right))_* + \frac{1}{x - 1}\\ \mathbf{if}\;\frac{1}{x - 1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right) \le 1.8471126366865695 \cdot 10^{-06}:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{1}{{1}^{3} + {x}^{3}}\right) \cdot \left(\left(1 - x\right) + x \cdot x\right) + \left(\frac{-2}{x}\right))_* + \frac{1}{x - 1}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))) < -169303.44399670232 or 1.8471126366865695e-06 < (+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))

    1. Initial program 0.0

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

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

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

      \[\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}\]

    if -169303.44399670232 < (+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))) < 1.8471126366865695e-06

    1. Initial program 18.8

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

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

      \[\leadsto \color{blue}{\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}}\]
  3. Recombined 2 regimes into one program.
  4. Applied simplify0.4

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{1}{x - 1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right) \le -169303.44399670232:\\ \;\;\;\;(\left(\frac{1}{{1}^{3} + {x}^{3}}\right) \cdot \left(\left(1 - x\right) + x \cdot x\right) + \left(\frac{-2}{x}\right))_* + \frac{1}{x - 1}\\ \mathbf{if}\;\frac{1}{x - 1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right) \le 1.8471126366865695 \cdot 10^{-06}:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{1}{{1}^{3} + {x}^{3}}\right) \cdot \left(\left(1 - x\right) + x \cdot x\right) + \left(\frac{-2}{x}\right))_* + \frac{1}{x - 1}\\ \end{array}}\]

Runtime

Time bar (total: 51.0s)Debug logProfile

herbie shell --seed '#(1064300848 3212030778 2049303162 3567222883 2277747821 1384278011)' +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))))