Average Error: 9.9 → 0.3
Time: 46.0s
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 -17360.73116012661:\\ \;\;\;\;\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^3} + \frac{2}{{x}^{5}}\right)\\ \mathbf{if}\;x \le 151370699.13763306:\\ \;\;\;\;\frac{\left(\left(x - 2\right) - 2 \cdot x\right) \cdot \left(x - 1\right) + \left(x + x \cdot x\right)}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^3} + \frac{2}{{x}^{5}}\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original9.9
Comparison0.2
Herbie0.3
\[ \frac{2}{x \cdot \left({x}^2 - 1\right)} \]

Derivation

  1. Split input into 2 regimes.
  2. if x < -17360.73116012661 or 151370699.13763306 < x

    1. Initial program 19.8

      \[\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}^{7}} + 2 \cdot \frac{1}{{x}^{5}}\right)\]
    3. Taylor expanded around inf 0.5

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

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

    if -17360.73116012661 < x < 151370699.13763306

    1. Initial program 0.4

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

      \[\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 frac-add 0.1

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

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

Runtime

Total time: 46.0s Debug log

Please report a bug with the following info:

herbie --seed '#(2140466705 3761342866 2084043251 1728887453 1128069928 3759225552)'
(FPCore (x)
  :name "NMSE problem 3.3.3"

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

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