Average Error: 28.5 → 0.2
Time: 5.2m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -11443.841380881175:\\ \;\;\;\;(3 \cdot \left(\frac{-1}{x} + \frac{\frac{-1}{x}}{x \cdot x}\right) + \left(\frac{-1}{x \cdot x}\right))_*\\ \mathbf{elif}\;x \le 13390.753029545842:\\ \;\;\;\;(\left(\frac{x}{(x \cdot \left(x \cdot x\right) + 1)_*}\right) \cdot \left(x \cdot x + \left(1 - x\right)\right) + \left(\frac{-1 + \left(-x\right)}{x - 1}\right))_*\\ \mathbf{else}:\\ \;\;\;\;(3 \cdot \left(\frac{-1}{x} + \frac{\frac{-1}{x}}{x \cdot x}\right) + \left(\frac{-1}{x \cdot x}\right))_*\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -11443.841380881175 or 13390.753029545842 < 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.3

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

    if -11443.841380881175 < x < 13390.753029545842

    1. Initial program 0.1

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

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

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

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

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

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

Reproduce

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