Average Error: 10.6 → 0.1
Time: 1.6m
Precision: 64
Internal Precision: 1152
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \le -2.258843033009386 \cdot 10^{-05}:\\ \;\;\;\;\left(\frac{\frac{1}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}}{\sqrt[3]{x + 1}} - \frac{2}{x}\right) + \frac{1}{x - 1}\\ \mathbf{if}\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \le 1.902255310993117 \cdot 10^{-05}:\\ \;\;\;\;\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\frac{1}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}}{\sqrt[3]{x + 1}} - \frac{2}{x}\right) + \frac{1}{x - 1}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))) < -2.258843033009386e-05 or 1.902255310993117e-05 < (+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))

    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-cube-cbrt0.1

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

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

    if -2.258843033009386e-05 < (+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))) < 1.902255310993117e-05

    1. Initial program 20.7

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. 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)}\]
    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 2 regimes into one program.

Runtime

Time bar (total: 1.6m)Debug logProfile

herbie shell --seed '#(1070609872 3456127585 2380521889 2328837196 1765472538 734540918)' +o rules:numerics
(FPCore (x)
  :name "3frac (problem 3.3.3)"

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

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