Average Error: 28.7 → 0.3
Time: 2.0m
Precision: 64
Internal Precision: 1408
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{-3}{x} + \left(1 + \frac{3}{x}\right) \cdot \frac{-1}{x \cdot x} \le -4.242258952429771 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{x + 1} - \frac{{x}^{3} + {1}^{3}}{\left(\left(1 - x\right) + x \cdot x\right) \cdot \left(x - 1\right)}\\ \mathbf{if}\;\frac{-3}{x} + \left(1 + \frac{3}{x}\right) \cdot \frac{-1}{x \cdot x} \le 2.98938586655047 \cdot 10^{-11}:\\ \;\;\;\;\frac{-3}{x} + \left(1 + \frac{3}{x}\right) \cdot \frac{-1}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x - 1} \cdot \left(x - 1\right) - \frac{x + 1}{x - 1}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if (+ (/ (- 3) x) (* (+ 1 (/ 3 x)) (/ (- 1) (* x x)))) < -4.242258952429771e-13

    1. Initial program 0.6

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

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

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\frac{{x}^{3} + {1}^{3}}{\left(x - 1\right) \cdot \left(x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)\right)}}\]
    5. Applied simplify0.6

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

    if -4.242258952429771e-13 < (+ (/ (- 3) x) (* (+ 1 (/ 3 x)) (/ (- 1) (* x x)))) < 2.98938586655047e-11

    1. Initial program 60.2

      \[\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}{\frac{-3}{x} + \left(1 + \frac{3}{x}\right) \cdot \frac{-1}{x \cdot x}}\]

    if 2.98938586655047e-11 < (+ (/ (- 3) x) (* (+ 1 (/ 3 x)) (/ (- 1) (* x x))))

    1. Initial program 0.5

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

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

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

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

Runtime

Time bar (total: 2.0m)Debug logProfile

herbie shell --seed '#(1070355188 2193211668 3977393919 3454156579 3755371326 1656365382)' 
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))