Average Error: 29.1 → 0.2
Time: 1.4m
Precision: 64
Internal Precision: 1344
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x} \le -2.7356856428146153 \cdot 10^{-10}:\\ \;\;\;\;\frac{\left(\left(x - 1\right) - \left(x + 1\right)\right) - \frac{x + 1}{x}}{\frac{x + 1}{x} \cdot \left(x - 1\right)}\\ \mathbf{if}\;\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x} \le 2.2699762401516993 \cdot 10^{-12}:\\ \;\;\;\;\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{x + 1}{x}} - \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)) (* x x))) < -2.7356856428146153e-10

    1. Initial program 0.4

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

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

      \[\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. Applied simplify0.0

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

    if -2.7356856428146153e-10 < (- (/ (- 3) x) (/ (+ 1 (/ 3 x)) (* x x))) < 2.2699762401516993e-12

    1. Initial program 60.1

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

    if 2.2699762401516993e-12 < (- (/ (- 3) x) (/ (+ 1 (/ 3 x)) (* x x)))

    1. Initial program 0.8

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

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

Runtime

Time bar (total: 1.4m)Debug logProfile

herbie shell --seed '#(1071246582 2318319007 2683472949 3810440501 3233274817 2724848749)' 
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))