Average Error: 29.5 → 0.0
Time: 4.7m
Precision: 64
Internal Precision: 1344
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_* \le -6.094615793701393 \cdot 10^{-12}:\\ \;\;\;\;\frac{\left(\left(-x\right) + \left(-x\right)\right) - \left(1 + x\right)}{\left(x - 1\right) \cdot \left(1 + x\right)}\\ \mathbf{if}\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_* \le 6.8582771154339995 \cdot 10^{-06}:\\ \;\;\;\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_*\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - 1\right) \cdot x - \left(1 + x\right) \cdot \left(1 + x\right)}{\left(x - 1\right) \cdot \left(1 + x\right)}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if (fma (+ 1 (/ 3 x)) (/ (- 1) (* x x)) (- (/ 3 x))) < -6.094615793701393e-12

    1. Initial program 0.5

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\left(x + 1\right) \cdot \left(x - 1\right)}}\]
    4. Using strategy rm
    5. Applied distribute-lft-in0.5

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

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

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

    if -6.094615793701393e-12 < (fma (+ 1 (/ 3 x)) (/ (- 1) (* x x)) (- (/ 3 x))) < 6.8582771154339995e-06

    1. Initial program 59.9

      \[\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(3 \cdot \frac{1}{x} + \frac{1}{{x}^{2}}\right)\right)}\]
    3. Applied simplify0.0

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

    if 6.8582771154339995e-06 < (fma (+ 1 (/ 3 x)) (/ (- 1) (* x x)) (- (/ 3 x)))

    1. Initial program 0.1

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_* \le -6.094615793701393 \cdot 10^{-12}:\\ \;\;\;\;\frac{\left(\left(-x\right) + \left(-x\right)\right) - \left(1 + x\right)}{\left(x - 1\right) \cdot \left(1 + x\right)}\\ \mathbf{if}\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_* \le 6.8582771154339995 \cdot 10^{-06}:\\ \;\;\;\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_*\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - 1\right) \cdot x - \left(1 + x\right) \cdot \left(1 + x\right)}{\left(x - 1\right) \cdot \left(1 + x\right)}\\ \end{array}}\]

Runtime

Time bar (total: 4.7m)Debug logProfile

herbie shell --seed '#(1072330854 3074818769 591214268 3603999196 3863745332 3332387116)' +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))