Average Error: 10.0 → 0.1
Time: 29.5s
Precision: 64
Ground Truth: 128
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -8.658073314327725 \cdot 10^{-05}:\\ \;\;\;\;\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \frac{\frac{2}{x}}{{x}^2}\right)\\ \mathbf{if}\;x \le 3.570692152999792:\\ \;\;\;\;\left(x + \left({x}^3 + \frac{1}{x}\right)\right) \cdot \left(-2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \frac{\frac{2}{x}}{{x}^2}\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original10.0
Comparison0.6
Herbie0.1
\[ \frac{2}{x \cdot \left({x}^2 - 1\right)} \]

Derivation

  1. Split input into 2 regimes.
  2. if x < -8.658073314327725e-05 or 3.570692152999792 < x

    1. Initial program 19.9

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

      \[\leadsto 2 \cdot \frac{1}{{x}^{5}} + \left(2 \cdot \frac{1}{{x}^{7}} + 2 \cdot \frac{1}{{x}^{3}}\right)\]
    3. Taylor expanded around inf 0.6

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

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

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

    if -8.658073314327725e-05 < x < 3.570692152999792

    1. Initial program 0.1

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

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

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

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

Runtime

Total time: 29.5s Debug log

Please include this information when filing a bug report:

herbie --seed '#(773770014 1796468937 2800673231 3017960497 2849053408 1647740057)'
(FPCore (x)
  :name "NMSE problem 3.3.3"

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

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