Average Error: 29.2 → 0.2
Time: 1.1m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -11107.160299140298:\\ \;\;\;\;(\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.009821353901925:\\ \;\;\;\;(e^{\log_* (1 + e^{\log \left((x \cdot \left(\frac{1}{1 + x}\right) + \left(\left(1 + x\right) \cdot \frac{-1}{x - 1}\right))_*\right)})} - 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 < -11107.160299140298 or 1.009821353901925 < x

    1. Initial program 58.9

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. 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)}\]
    3. 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 -11107.160299140298 < x < 1.009821353901925

    1. Initial program 0.1

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

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\left(x + 1\right) \cdot \frac{1}{x - 1}}\]
    4. Applied div-inv0.1

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

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

      \[\leadsto (x \cdot \left(\frac{1}{x + 1}\right) + \left(-\frac{1}{x - 1} \cdot \left(x + 1\right)\right))_* + \color{blue}{0}\]
    7. Using strategy rm
    8. Applied expm1-log1p-u0.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -11107.160299140298:\\ \;\;\;\;(\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.009821353901925:\\ \;\;\;\;(e^{\log_* (1 + e^{\log \left((x \cdot \left(\frac{1}{1 + x}\right) + \left(\left(1 + x\right) \cdot \frac{-1}{x - 1}\right))_*\right)})} - 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 2019053 +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))