Average Error: 29.7 → 0.1
Time: 1.9m
Precision: 64
Internal Precision: 1344
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -9507.107678167975 \lor \neg \left(x \le 12066.169323686487\right):\\ \;\;\;\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_*\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{x}{1 - x \cdot x}\right) \cdot \left(1 - x\right) + \left(\frac{-(\left(x \cdot x\right) \cdot x + 1)_*}{\left(x - 1\right) \cdot \left(1 + \left(x \cdot x - x\right)\right)}\right))_*\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -9507.107678167975 or 12066.169323686487 < x

    1. Initial program 59.2

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Initial simplification59.2

      \[\leadsto \frac{x}{1 + x} - \frac{1 + x}{x - 1}\]
    3. Taylor expanded around -inf 0.4

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

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

    if -9507.107678167975 < x < 12066.169323686487

    1. Initial program 0.1

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Initial simplification0.1

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

      \[\leadsto \frac{x}{\color{blue}{\frac{1 \cdot 1 - x \cdot x}{1 - x}}} - \frac{1 + x}{x - 1}\]
    5. Applied associate-/r/0.1

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

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

      \[\leadsto (\color{blue}{\left(\frac{x}{1 - x \cdot x}\right)} \cdot \left(1 - x\right) + \left(-\frac{1 + x}{x - 1}\right))_*\]
    8. Using strategy rm
    9. Applied flip3-+0.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -9507.107678167975 \lor \neg \left(x \le 12066.169323686487\right):\\ \;\;\;\;(\left(1 + \frac{3}{x}\right) \cdot \left(\frac{-1}{x \cdot x}\right) + \left(\frac{-3}{x}\right))_*\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{x}{1 - x \cdot x}\right) \cdot \left(1 - x\right) + \left(\frac{-(\left(x \cdot x\right) \cdot x + 1)_*}{\left(x - 1\right) \cdot \left(1 + \left(x \cdot x - x\right)\right)}\right))_*\\ \end{array}\]

Runtime

Time bar (total: 1.9m)Debug logProfile

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