Average Error: 29.2 → 0.2
Time: 6.8s
Precision: binary64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.993340841827823673 \lor \neg \left(x \le 13973.283901258525\right):\\ \;\;\;\;\left(\frac{-1}{{x}^{2}} - \frac{3}{x}\right) - \frac{3}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{3} + \left(x \cdot \left(1 \cdot 1 - x \cdot 1\right) - \frac{{x}^{3} + {1}^{3}}{x - 1} \cdot \left(x + 1\right)\right)}{\sqrt{\left(1 \cdot \left(1 - x\right) + {x}^{2}\right) \cdot \left(x + 1\right)} \cdot \sqrt{\left(1 \cdot \left(1 - x\right) + {x}^{2}\right) \cdot \left(x + 1\right)}}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.9933408418278237 or 13973.283901258525 < x

    1. Initial program 58.7

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-exp-log59.4

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

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

      \[\leadsto \color{blue}{\left(\frac{-1}{{x}^{2}} - \frac{3}{x}\right) - \frac{3}{{x}^{3}}}\]

    if -0.9933408418278237 < x < 13973.283901258525

    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. Using strategy rm
    5. Applied flip3-+0.1

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

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

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

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

      \[\leadsto \frac{{x}^{3} + \left(x \cdot \left(1 \cdot 1 - x \cdot 1\right) - \frac{{x}^{3} + {1}^{3}}{x - 1} \cdot \left(x + 1\right)\right)}{\color{blue}{\left(1 \cdot \left(1 - x\right) + {x}^{2}\right) \cdot \left(x + 1\right)}}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.993340841827823673 \lor \neg \left(x \le 13973.283901258525\right):\\ \;\;\;\;\left(\frac{-1}{{x}^{2}} - \frac{3}{x}\right) - \frac{3}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{3} + \left(x \cdot \left(1 \cdot 1 - x \cdot 1\right) - \frac{{x}^{3} + {1}^{3}}{x - 1} \cdot \left(x + 1\right)\right)}{\sqrt{\left(1 \cdot \left(1 - x\right) + {x}^{2}\right) \cdot \left(x + 1\right)} \cdot \sqrt{\left(1 \cdot \left(1 - x\right) + {x}^{2}\right) \cdot \left(x + 1\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020148 
(FPCore (x)
  :name "Asymptote C"
  :precision binary64
  (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))