Average Error: 14.4 → 0.2
Time: 2.2m
Precision: 64
Internal Precision: 832
\[\frac{1}{x + 1} - \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{x + 1} - \frac{1}{x - 1} \le 9.413749473058141 \cdot 10^{-184}:\\ \;\;\;\;\left(-\left(\frac{2}{{x}^{6}} + \frac{\frac{2}{x}}{x}\right)\right) - \frac{2}{{x}^{4}}\\ \mathbf{else}:\\ \;\;\;\;\frac{(x \cdot x + 1)_* - x}{(\left(x \cdot x\right) \cdot x + 1)_*} - \frac{1}{x - 1}\\ \end{array}\]

Error

Bits error versus x

Try it out

  1. Inputs

  2. Original Output:

    Herbie Output:

Derivation

  1. Split input into 2 regimes
  2. if (- (/ 1 (+ x 1)) (/ 1 (- x 1))) < 9.413749473058141e-184

    1. Initial program 28.6

      \[\frac{1}{x + 1} - \frac{1}{x - 1}\]
    2. Taylor expanded around inf 1.0

      \[\leadsto \color{blue}{-\left(2 \cdot \frac{1}{{x}^{6}} + \left(2 \cdot \frac{1}{{x}^{4}} + 2 \cdot \frac{1}{{x}^{2}}\right)\right)}\]
    3. Applied simplify1.0

      \[\leadsto \color{blue}{\left(\frac{-2}{x \cdot x} + \frac{-2}{{x}^{6}}\right) - \frac{2}{{x}^{4}}}\]
    4. Using strategy rm
    5. Applied associate-/r*0.4

      \[\leadsto \left(\color{blue}{\frac{\frac{-2}{x}}{x}} + \frac{-2}{{x}^{6}}\right) - \frac{2}{{x}^{4}}\]

    if 9.413749473058141e-184 < (- (/ 1 (+ x 1)) (/ 1 (- x 1)))

    1. Initial program 0.0

      \[\frac{1}{x + 1} - \frac{1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt0.0

      \[\leadsto \frac{1}{x + 1} - \color{blue}{\left(\sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}\right) \cdot \sqrt[3]{\frac{1}{x - 1}}}\]
    4. Applied flip3-+0.0

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

      \[\leadsto \color{blue}{\frac{1}{{x}^{3} + {1}^{3}} \cdot \left(x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)\right)} - \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}\right) \cdot \sqrt[3]{\frac{1}{x - 1}}\]
    6. Applied prod-diff0.0

      \[\leadsto \color{blue}{(\left(\frac{1}{{x}^{3} + {1}^{3}}\right) \cdot \left(x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)\right) + \left(-\sqrt[3]{\frac{1}{x - 1}} \cdot \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}\right)\right))_* + (\left(-\sqrt[3]{\frac{1}{x - 1}}\right) \cdot \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}\right) + \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}\right)\right))_*}\]
    7. Applied simplify0.0

      \[\leadsto \color{blue}{\left(\frac{(x \cdot x + 1)_* - x}{(\left(x \cdot x\right) \cdot x + 1)_*} - \frac{1}{x - 1}\right)} + (\left(-\sqrt[3]{\frac{1}{x - 1}}\right) \cdot \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}\right) + \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}\right)\right))_*\]
    8. Applied simplify0.0

      \[\leadsto \left(\frac{(x \cdot x + 1)_* - x}{(\left(x \cdot x\right) \cdot x + 1)_*} - \frac{1}{x - 1}\right) + \color{blue}{0}\]
  3. Recombined 2 regimes into one program.
  4. Applied simplify0.2

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{1}{x + 1} - \frac{1}{x - 1} \le 9.413749473058141 \cdot 10^{-184}:\\ \;\;\;\;\left(-\left(\frac{2}{{x}^{6}} + \frac{\frac{2}{x}}{x}\right)\right) - \frac{2}{{x}^{4}}\\ \mathbf{else}:\\ \;\;\;\;\frac{(x \cdot x + 1)_* - x}{(\left(x \cdot x\right) \cdot x + 1)_*} - \frac{1}{x - 1}\\ \end{array}}\]

Runtime

Time bar (total: 2.2m)Debug logProfile

herbie shell --seed '#(1072361757 3390613284 2339397988 1175251238 145061547 3101881848)' +o rules:numerics
(FPCore (x)
  :name "Asymptote A"
  (- (/ 1 (+ x 1)) (/ 1 (- x 1))))