Average Error: 9.5 → 0.2
Time: 28.4s
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 -1.0530127496367332:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}\\ \mathbf{if}\;x \le 103.89297904921952:\\ \;\;\;\;\left(\frac{\frac{1}{\sqrt{x + 1}}}{\sqrt{x + 1}} - \frac{2}{x}\right) + \frac{1}{x - 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{2}{{x}^{3}}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

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

    1. Initial program 20.2

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

      \[\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.3

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

    if -1.0530127496367332 < x < 103.89297904921952

    1. Initial program 0.0

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.0

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

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

    if 103.89297904921952 < x

    1. Initial program 18.0

      \[\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}}\]
    4. Using strategy rm
    5. Applied associate-/l/0.6

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

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

Runtime

Time bar (total: 28.4s)Debug logProfile

herbie shell --seed '#(1063185673 2139736501 2393378123 1907444849 1070993796 1007244912)' 
(FPCore (x)
  :name "3frac (problem 3.3.3)"

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

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