Average Error: 9.5 → 0.1
Time: 40.0s
Precision: 64
Internal Precision: 1152
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -116.08850033593242:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{\frac{2}{x}}{x \cdot x}\right) + \frac{2}{{x}^{5}}\\ \mathbf{if}\;x \le 131.68721628398322:\\ \;\;\;\;\frac{1}{1 + x} + \left(\frac{1}{x - 1} - \frac{2}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{\frac{2}{x}}{x \cdot x}\right) + \frac{2}{{x}^{5}}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -116.08850033593242 or 131.68721628398322 < x

    1. Initial program 18.8

      \[\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}^{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 -116.08850033593242 < x < 131.68721628398322

    1. Initial program 0.0

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;x \le -116.08850033593242:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{\frac{2}{x}}{x \cdot x}\right) + \frac{2}{{x}^{5}}\\ \mathbf{if}\;x \le 131.68721628398322:\\ \;\;\;\;\frac{1}{1 + x} + \left(\frac{1}{x - 1} - \frac{2}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{\frac{2}{x}}{x \cdot x}\right) + \frac{2}{{x}^{5}}\\ \end{array}}\]

Runtime

Time bar (total: 40.0s)Debug log

herbie shell --seed '#(633950927 2092594946 1442981 2827247922 2812758452 390991499)' 
(FPCore (x)
  :name "3frac (problem 3.3.3)"

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

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