Average Error: 10.1 → 0.1
Time: 6.5s
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.3416378887887987 \cdot 10^{-05}:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{\frac{2}{x}}{x}}{x}\\ \mathbf{if}\;x \le 1843.611849545597:\\ \;\;\;\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{\frac{2}{x}}{x}}{x}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 3 regimes.
  2. if x < -2.3416378887887987e-05

    1. Initial program 21.3

      \[\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}}\]
    5. Using strategy rm
    6. Applied associate-/r* 0.1

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

      \[\leadsto \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\color{blue}{\frac{2}{{x}^2}}}{x}\]
    8. Using strategy rm
    9. Applied square-mult 0.1

      \[\leadsto \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{\color{blue}{x \cdot x}}}{x}\]
    10. Applied associate-/r* 0.1

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

    if -2.3416378887887987e-05 < x < 1843.611849545597

    1. Initial program 0.1

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]

    if 1843.611849545597 < x

    1. Initial program 19.1

      \[\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}}\]
    5. Using strategy rm
    6. Applied associate-/r* 0.1

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

      \[\leadsto \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\color{blue}{\frac{2}{{x}^2}}}{x}\]
    8. Using strategy rm
    9. Applied square-mult 0.1

      \[\leadsto \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{\color{blue}{x \cdot x}}}{x}\]
    10. Applied associate-/r* 0.1

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

Runtime

Time bar (total: 6.5s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064555532 179913862 452496668 2441903500 287849034 462453547)'
(FPCore (x)
  :name "3frac (problem 3.3.3)"

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

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