Average Error: 29.1 → 0.2
Time: 3.0m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -13059.87478629602 \lor \neg \left(x \le 0.986855910207498\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}:\\ \;\;\;\;\sqrt{\frac{x}{1 + x} - \frac{1 + x}{x - 1}} \cdot \sqrt{(\left(\frac{-1 - x}{(\left(x \cdot x\right) \cdot x + -1)_*}\right) \cdot \left((x \cdot x + 1)_* + x\right) + \left(\frac{(\left(1 - x\right) \cdot x + \left({x}^{3}\right))_*}{(x \cdot \left(x \cdot x\right) + 1)_*}\right))_*}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -13059.87478629602 or 0.986855910207498 < x

    1. Initial program 58.9

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Taylor expanded around inf 0.6

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

      \[\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 -13059.87478629602 < x < 0.986855910207498

    1. Initial program 0.0

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.1

      \[\leadsto \color{blue}{\sqrt{\frac{x}{x + 1} - \frac{x + 1}{x - 1}} \cdot \sqrt{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}}\]
    4. Using strategy rm
    5. Applied flip3--0.1

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

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

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

      \[\leadsto \sqrt{\frac{x}{x + 1} - \frac{x + 1}{x - 1}} \cdot \sqrt{\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}^{3} - {1}^{3}} \cdot \left(x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)\right)}\]
    9. Applied prod-diff0.1

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

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

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

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

Runtime

Time bar (total: 3.0m)Debug logProfile

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