Average Error: 28.8 → 0.1
Time: 1.1m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -17835.962947013315:\\ \;\;\;\;(\left(\frac{\log \left(e^{\frac{-1}{x \cdot x}}\right)}{x}\right) \cdot 3 + \left(\frac{-1}{x \cdot x}\right))_* - \frac{3}{x}\\ \mathbf{elif}\;x \le 10615.219937138987:\\ \;\;\;\;(\left(\frac{x}{x \cdot x - 1}\right) \cdot \left(x - 1\right) + \left(-\frac{(x \cdot \left((\left(x \cdot x\right) \cdot x + 1)_*\right) + \left((\left(x \cdot x\right) \cdot x + 1)_*\right))_*}{(\left(x \cdot x - x\right) \cdot \left((x \cdot x + -1)_*\right) + \left((x \cdot x + -1)_*\right))_*}\right))_*\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{\log \left(e^{\frac{-1}{x \cdot x}}\right)}{x}\right) \cdot 3 + \left(\frac{-1}{x \cdot x}\right))_* - \frac{3}{x}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -17835.962947013315 or 10615.219937138987 < x

    1. Initial program 59.3

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

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

      \[\leadsto \color{blue}{(\left(\frac{\frac{-1}{x \cdot x}}{x}\right) \cdot 3 + \left(\frac{-1}{x \cdot x}\right))_* - \frac{3}{x}}\]
    4. Using strategy rm
    5. Applied add-log-exp0.0

      \[\leadsto (\left(\frac{\color{blue}{\log \left(e^{\frac{-1}{x \cdot x}}\right)}}{x}\right) \cdot 3 + \left(\frac{-1}{x \cdot x}\right))_* - \frac{3}{x}\]

    if -17835.962947013315 < x < 10615.219937138987

    1. Initial program 0.1

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied flip--0.1

      \[\leadsto \frac{x}{x + 1} - \frac{x + 1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}}}\]
    4. Applied associate-/r/0.1

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

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

      \[\leadsto \color{blue}{\frac{x}{x \cdot x - 1 \cdot 1} \cdot \left(x - 1\right)} - \frac{x + 1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
    7. Applied prod-diff0.1

      \[\leadsto \color{blue}{(\left(\frac{x}{x \cdot x - 1 \cdot 1}\right) \cdot \left(x - 1\right) + \left(-\left(x + 1\right) \cdot \frac{x + 1}{x \cdot x - 1 \cdot 1}\right))_* + (\left(-\left(x + 1\right)\right) \cdot \left(\frac{x + 1}{x \cdot x - 1 \cdot 1}\right) + \left(\left(x + 1\right) \cdot \frac{x + 1}{x \cdot x - 1 \cdot 1}\right))_*}\]
    8. Simplified0.1

      \[\leadsto (\left(\frac{x}{x \cdot x - 1 \cdot 1}\right) \cdot \left(x - 1\right) + \left(-\left(x + 1\right) \cdot \frac{x + 1}{x \cdot x - 1 \cdot 1}\right))_* + \color{blue}{0}\]
    9. Using strategy rm
    10. Applied flip3-+0.1

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

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

      \[\leadsto (\left(\frac{x}{x \cdot x - 1 \cdot 1}\right) \cdot \left(x - 1\right) + \left(-\frac{\color{blue}{(x \cdot \left((\left(x \cdot x\right) \cdot x + 1)_*\right) + \left((\left(x \cdot x\right) \cdot x + 1)_*\right))_*}}{\left(x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)\right) \cdot \left(x \cdot x - 1 \cdot 1\right)}\right))_* + 0\]
    13. Simplified0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -17835.962947013315:\\ \;\;\;\;(\left(\frac{\log \left(e^{\frac{-1}{x \cdot x}}\right)}{x}\right) \cdot 3 + \left(\frac{-1}{x \cdot x}\right))_* - \frac{3}{x}\\ \mathbf{elif}\;x \le 10615.219937138987:\\ \;\;\;\;(\left(\frac{x}{x \cdot x - 1}\right) \cdot \left(x - 1\right) + \left(-\frac{(x \cdot \left((\left(x \cdot x\right) \cdot x + 1)_*\right) + \left((\left(x \cdot x\right) \cdot x + 1)_*\right))_*}{(\left(x \cdot x - x\right) \cdot \left((x \cdot x + -1)_*\right) + \left((x \cdot x + -1)_*\right))_*}\right))_*\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{\log \left(e^{\frac{-1}{x \cdot x}}\right)}{x}\right) \cdot 3 + \left(\frac{-1}{x \cdot x}\right))_* - \frac{3}{x}\\ \end{array}\]

Reproduce

herbie shell --seed 2019093 +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))