Average Error: 28.9 → 0.2
Time: 2.4m
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.034520012231562 \cdot 10^{-06}:\\ \;\;\;\;\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\sqrt[3]{{\left(x - 1\right)}^{3} \cdot {\left(1 + x\right)}^{3}}}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))) < 6.034520012231562e-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}{\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x}}\]

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

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\left(x + 1\right) \cdot \left(x - 1\right)}}\]
    4. Using strategy rm
    5. Applied add-cbrt-cube0.1

      \[\leadsto \frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\left(x + 1\right) \cdot \color{blue}{\sqrt[3]{\left(\left(x - 1\right) \cdot \left(x - 1\right)\right) \cdot \left(x - 1\right)}}}\]
    6. Applied add-cbrt-cube0.1

      \[\leadsto \frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\color{blue}{\sqrt[3]{\left(\left(x + 1\right) \cdot \left(x + 1\right)\right) \cdot \left(x + 1\right)}} \cdot \sqrt[3]{\left(\left(x - 1\right) \cdot \left(x - 1\right)\right) \cdot \left(x - 1\right)}}\]
    7. Applied cbrt-unprod0.1

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

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

Runtime

Time bar (total: 2.4m)Debug logProfile

herbie shell --seed 2018206 
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))