Average Error: 29.7 → 0.0
Time: 1.7m
Precision: 64
Internal Precision: 1344
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.9130454702801605 \cdot 10^{+18} \lor \neg \left(x \le 106284.32836736059\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}:\\ \;\;\;\;\frac{1}{(x \cdot x + -1)_*} \cdot (-2 \cdot x + \left(-1 - x\right))_*\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -1.9130454702801605e+18 or 106284.32836736059 < x

    1. Initial program 59.9

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

      \[\leadsto \color{blue}{\frac{1}{\frac{x + 1}{x}}} - \frac{x + 1}{x - 1}\]
    4. Using strategy rm
    5. Applied frac-sub59.6

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

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

      \[\leadsto \frac{\left(\left(-2 - x\right) + x\right) - \frac{x + 1}{x}}{\color{blue}{\frac{(x \cdot x + -1)_*}{x}}}\]
    8. 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)}\]
    9. 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 -1.9130454702801605e+18 < x < 106284.32836736059

    1. Initial program 1.0

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

      \[\leadsto \color{blue}{\frac{1}{\frac{x + 1}{x}}} - \frac{x + 1}{x - 1}\]
    4. Using strategy rm
    5. Applied frac-sub0.6

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

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

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

      \[\leadsto \frac{\left(\left(-2 - x\right) + x\right) - \frac{x + 1}{x}}{\color{blue}{(x \cdot x + -1)_* \cdot \frac{1}{x}}}\]
    10. Applied *-un-lft-identity0.3

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(\left(-2 - x\right) + x\right) - \frac{x + 1}{x}\right)}}{(x \cdot x + -1)_* \cdot \frac{1}{x}}\]
    11. Applied times-frac0.3

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

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

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

Runtime

Time bar (total: 1.7m)Debug logProfile

BaselineHerbieOracleSpan%
Regimes15.50.00.015.5100%
herbie shell --seed 2018286 +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))