Average Error: 29.2 → 0.8
Time: 3.2m
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 -3.8411611046864326 \cdot 10^{-10}:\\ \;\;\;\;x \cdot \left(3 + x\right) + 1\\ \mathbf{if}\;\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x} \le 8.133924293901448 \cdot 10^{-10}:\\ \;\;\;\;\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{3} \cdot {\left(x - 1\right)}^{3} - {\left(x + 1\right)}^{3} \cdot {\left(x + 1\right)}^{3}}{{\left(x + 1\right)}^{3} \cdot {\left(x - 1\right)}^{3}}}{\frac{1 + x}{x - 1} \cdot \left(\frac{x}{1 + x} + \frac{1 + x}{x - 1}\right) + \frac{x}{1 + x} \cdot \frac{x}{1 + x}}\\ \end{array}\]

Error

Bits error versus x

Derivation

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

    1. Initial program 0.4

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

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

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

    if -3.8411611046864326e-10 < (- (/ (- 3) x) (/ (+ 1 (/ 3 x)) (* x x))) < 8.133924293901448e-10

    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 8.133924293901448e-10 < (- (/ (- 3) x) (/ (+ 1 (/ 3 x)) (* x x)))

    1. Initial program 0.5

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

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

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

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

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

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

Runtime

Time bar (total: 3.2m)Debug logProfile

herbie shell --seed '#(1071948828 1180510430 2986424009 997076509 406109801 420189285)' 
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))