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

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))) < 6.613776447506048e-06

    1. Initial program 58.9

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

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

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

    if 6.613776447506048e-06 < (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))

    1. Initial program 0.1

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Taylor expanded around 0 1.0

      \[\leadsto \color{blue}{{x}^{2} + \left(1 + 3 \cdot x\right)}\]
    3. Applied simplify1.0

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

Runtime

Time bar (total: 1.9m)Debug logProfile

herbie shell --seed '#(1072107073 2127697367 3936270018 2300570620 2134894798 4023771849)' +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))