Average Error: 29.2 → 0.1
Time: 7.4m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -12407.883343899579 \lor \neg \left(x \le 12710.296123715665\right):\\ \;\;\;\;(\left(\frac{-1}{x \cdot x}\right) \cdot \left(\frac{3}{x}\right) + \left(\frac{-1}{x \cdot x} - \frac{3}{x}\right))_*\\ \mathbf{else}:\\ \;\;\;\;(\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 - x}{-1 + x}\right))_*\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -12407.883343899579 or 12710.296123715665 < x

    1. Initial program 59.4

      \[\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.0

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

    if -12407.883343899579 < x < 12710.296123715665

    1. Initial program 0.1

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.1

      \[\leadsto \frac{x}{x + 1} - \frac{x + 1}{\color{blue}{1 \cdot \left(x - 1\right)}}\]
    4. Applied add-sqr-sqrt0.5

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

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\frac{\sqrt{x + 1}}{1} \cdot \frac{\sqrt{x + 1}}{x - 1}}\]
    6. Applied flip3-+0.5

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

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

      \[\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{\sqrt{x + 1}}{x - 1} \cdot \frac{\sqrt{x + 1}}{1}\right))_* + (\left(-\frac{\sqrt{x + 1}}{x - 1}\right) \cdot \left(\frac{\sqrt{x + 1}}{1}\right) + \left(\frac{\sqrt{x + 1}}{x - 1} \cdot \frac{\sqrt{x + 1}}{1}\right))_*}\]
    9. Simplified0.5

      \[\leadsto \color{blue}{(\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 - x}{x + -1}\right))_*} + (\left(-\frac{\sqrt{x + 1}}{x - 1}\right) \cdot \left(\frac{\sqrt{x + 1}}{1}\right) + \left(\frac{\sqrt{x + 1}}{x - 1} \cdot \frac{\sqrt{x + 1}}{1}\right))_*\]
    10. Simplified0.1

      \[\leadsto (\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 - x}{x + -1}\right))_* + \color{blue}{0}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -12407.883343899579 \lor \neg \left(x \le 12710.296123715665\right):\\ \;\;\;\;(\left(\frac{-1}{x \cdot x}\right) \cdot \left(\frac{3}{x}\right) + \left(\frac{-1}{x \cdot x} - \frac{3}{x}\right))_*\\ \mathbf{else}:\\ \;\;\;\;(\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 - x}{-1 + x}\right))_*\\ \end{array}\]

Runtime

Time bar (total: 7.4m)Debug logProfile

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