Average Error: 9.8 → 0.1
Time: 39.1s
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 -110.08052377573176:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{1}{\frac{x \cdot x}{\frac{2}{x}}}\\ \mathbf{if}\;x \le 113.16786286436555:\\ \;\;\;\;\left(\frac{1}{x \cdot x - 1} \cdot \left(x - 1\right) - \frac{2}{x}\right) + \frac{1}{x - 1}\\ \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

Original9.8
Target0.2
Herbie0.1
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -110.08052377573176

    1. Initial program 20.1

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Taylor expanded around inf 0.4

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

      \[\leadsto \color{blue}{\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}}\]
    4. Using strategy rm
    5. Applied clear-num0.4

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

    if -110.08052377573176 < x < 113.16786286436555

    1. Initial program 0.0

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

      \[\leadsto \left(\frac{1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x - 1}}} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    4. Applied associate-/r/0.0

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

      \[\leadsto \left(\color{blue}{\frac{1}{x \cdot x - 1}} \cdot \left(x - 1\right) - \frac{2}{x}\right) + \frac{1}{x - 1}\]

    if 113.16786286436555 < x

    1. Initial program 19.8

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Taylor expanded around inf 0.6

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

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

Runtime

Time bar (total: 39.1s)Debug logProfile

herbie shell --seed '#(1070227846 1561819246 480764335 4016816270 2602869839 2117310382)' 
(FPCore (x)
  :name "3frac (problem 3.3.3)"

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

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