Average Error: 29.3 → 0.0
Time: 2.0m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.1873737832786784 \cdot 10^{+17}:\\ \;\;\;\;(\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 25063635.731109664:\\ \;\;\;\;\frac{(-3 \cdot x + -1)_*}{\left(1 + x\right) \cdot \left(x - 1\right)}\\ \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 < -2.1873737832786784e+17 or 25063635.731109664 < x

    1. Initial program 60.2

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\left(x + 1\right) \cdot \left(x - 1\right)}}\]
    4. 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)}\]
    5. 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}}\]

    if -2.1873737832786784e+17 < x < 25063635.731109664

    1. Initial program 0.8

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\left(x + 1\right) \cdot \left(x - 1\right)}}\]
    4. Taylor expanded around inf 0.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.1873737832786784 \cdot 10^{+17}:\\ \;\;\;\;(\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 25063635.731109664:\\ \;\;\;\;\frac{(-3 \cdot x + -1)_*}{\left(1 + x\right) \cdot \left(x - 1\right)}\\ \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 2019050 +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))