Average Error: 29.0 → 0.1
Time: 1.4m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -14049.463499426724:\\ \;\;\;\;(\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 14429.31640719436:\\ \;\;\;\;\frac{\frac{\left(x - 1\right) \cdot \left(x \cdot x\right) - \left(\frac{1 + x}{x - 1} \cdot \left(1 + x\right)\right) \cdot \left(\left(1 + x\right) \cdot \left(1 + x\right)\right)}{\left(x - 1\right) \cdot \left(\left(1 + x\right) \cdot \left(1 + x\right)\right)}}{\frac{x}{1 + x} + \frac{1 + x}{x - 1}}\\ \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 < -14049.463499426724 or 14429.31640719436 < x

    1. Initial program 59.2

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

      \[\leadsto \color{blue}{\frac{\frac{x}{x + 1} \cdot \frac{x}{x + 1} - \frac{x + 1}{x - 1} \cdot \frac{x + 1}{x - 1}}{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}}\]
    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}}\]
    6. Using strategy rm
    7. 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 -14049.463499426724 < x < 14429.31640719436

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\frac{\frac{x}{x + 1} \cdot \frac{x}{x + 1} - \frac{x + 1}{x - 1} \cdot \frac{x + 1}{x - 1}}{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}}\]
    4. Using strategy rm
    5. Applied associate-*l/0.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -14049.463499426724:\\ \;\;\;\;(\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 14429.31640719436:\\ \;\;\;\;\frac{\frac{\left(x - 1\right) \cdot \left(x \cdot x\right) - \left(\frac{1 + x}{x - 1} \cdot \left(1 + x\right)\right) \cdot \left(\left(1 + x\right) \cdot \left(1 + x\right)\right)}{\left(x - 1\right) \cdot \left(\left(1 + x\right) \cdot \left(1 + x\right)\right)}}{\frac{x}{1 + x} + \frac{1 + x}{x - 1}}\\ \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 2019068 +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))