Average Error: 10.4 → 0.1
Time: 25.6s
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 -2.540618527478878:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}\\ \mathbf{if}\;x \le 70172005.42724477:\\ \;\;\;\;-\left(2 \cdot \frac{1}{x} + \left(2 \cdot {x}^{3} + 2 \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes.
  2. if x < -2.540618527478878 or 70172005.42724477 < x

    1. Initial program 19.7

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Applied taylor 0.5

      \[\leadsto 2 \cdot \frac{1}{{x}^{3}} + \left(2 \cdot \frac{1}{{x}^{5}} + 2 \cdot \frac{1}{{x}^{7}}\right)\]
    3. 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)}\]
    4. Applied simplify 0.1

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

    if -2.540618527478878 < x < 70172005.42724477

    1. Initial program 0.9

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Applied taylor 0.0

      \[\leadsto -\left(2 \cdot \frac{1}{x} + \left(2 \cdot {x}^{3} + 2 \cdot x\right)\right)\]
    3. Taylor expanded around 0 0.0

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

Runtime

Time bar (total: 25.6s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1068028399 4028058041 2917032441 2563479541 765645300 1132738916)'
(FPCore (x)
  :name "3frac (problem 3.3.3)"

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

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