Average Error: 29.4 → 0.1
Time: 2.5m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -12666.926339530868:\\ \;\;\;\;(\left(\frac{\frac{-1}{x \cdot x}}{x}\right) \cdot 3 + \left(\frac{-1}{x \cdot x}\right))_* - \frac{3}{x}\\ \mathbf{elif}\;x \le 1.0098741307616452:\\ \;\;\;\;\log_* (1 + (e^{\sqrt{(e^{\log_* (1 + (x \cdot \left(\frac{1}{1 + x}\right) + \left(-\frac{1 + x}{x - 1}\right))_*)} - 1)^*} \cdot \sqrt{(e^{\log_* (1 + (x \cdot \left(\frac{1}{1 + x}\right) + \left(-\frac{1 + x}{x - 1}\right))_*)} - 1)^*}} - 1)^*)\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{\frac{-1}{x \cdot x}}{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 < -12666.926339530868 or 1.0098741307616452 < x

    1. Initial program 59.1

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied expm1-log1p-u59.2

      \[\leadsto \color{blue}{(e^{\log_* (1 + \left(\frac{x}{x + 1} - \frac{x + 1}{x - 1}\right))} - 1)^*}\]
    4. Taylor expanded around -inf 0.5

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

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

    if -12666.926339530868 < x < 1.0098741307616452

    1. Initial program 0.0

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied expm1-log1p-u0.1

      \[\leadsto \color{blue}{(e^{\log_* (1 + \left(\frac{x}{x + 1} - \frac{x + 1}{x - 1}\right))} - 1)^*}\]
    4. Using strategy rm
    5. Applied log1p-expm1-u0.1

      \[\leadsto \color{blue}{\log_* (1 + (e^{(e^{\log_* (1 + \left(\frac{x}{x + 1} - \frac{x + 1}{x - 1}\right))} - 1)^*} - 1)^*)}\]
    6. Using strategy rm
    7. Applied div-inv0.1

      \[\leadsto \log_* (1 + (e^{(e^{\log_* (1 + \left(\color{blue}{x \cdot \frac{1}{x + 1}} - \frac{x + 1}{x - 1}\right))} - 1)^*} - 1)^*)\]
    8. Applied fma-neg0.1

      \[\leadsto \log_* (1 + (e^{(e^{\log_* (1 + \color{blue}{(x \cdot \left(\frac{1}{x + 1}\right) + \left(-\frac{x + 1}{x - 1}\right))_*})} - 1)^*} - 1)^*)\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt0.1

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

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

Reproduce

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