Average Error: 10.0 → 0.1
Time: 23.9s
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{\frac{2}{x}}{{x}^2} + \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right)\\ \mathbf{if}\;x \le 3.570692152999792:\\ \;\;\;\;\left(-2\right) \cdot \left(x + \left({x}^3 + \frac{1}{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{x}}{{x}^2} + \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\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. Using strategy rm
    3. Applied add-cube-cbrt 19.9

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}}\right)}^3}\]
    4. Applied taylor 1.0

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

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

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

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

Runtime

Total time: 23.9s 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))))