Average Error: 29.2 → 0.5
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 -1.0289384793425094 \cdot 10^{-13}:\\ \;\;\;\;\log \left(e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}\right)\\ \mathbf{if}\;\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x} \le 1.0998023011309302 \cdot 10^{-14}:\\ \;\;\;\;\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(\left(1 + x\right) - x \cdot x\right) \cdot \left(1 + x\right) + \left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(\left(-x\right) + \left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) - \left({\left(1 + x\right)}^{3} + {\left(x \cdot x\right)}^{3}\right) \cdot \left(\left(1 + x\right) \cdot \left(1 + x\right)\right)}{\left(\left(1 + x\right) \cdot \left({x}^{3} - 1\right)\right) \cdot \left(\left(\left(1 + x\right) - x \cdot x\right) \cdot \left(1 + x\right) + \left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}\\ \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 3 regimes
  2. if (- (/ (- 3) x) (/ (+ 1 (/ 3 x)) (* x x))) < -1.0289384793425094e-13

    1. Initial program 0.8

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-log-exp0.8

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\log \left(e^{\frac{x + 1}{x - 1}}\right)}\]
    4. Applied add-log-exp0.8

      \[\leadsto \color{blue}{\log \left(e^{\frac{x}{x + 1}}\right)} - \log \left(e^{\frac{x + 1}{x - 1}}\right)\]
    5. Applied diff-log0.8

      \[\leadsto \color{blue}{\log \left(\frac{e^{\frac{x}{x + 1}}}{e^{\frac{x + 1}{x - 1}}}\right)}\]
    6. Applied simplify0.8

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

    if -1.0289384793425094e-13 < (- (/ (- 3) x) (/ (+ 1 (/ 3 x)) (* x x))) < 1.0998023011309302e-14

    1. Initial program 60.3

      \[\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(\frac{1}{{x}^{2}} + 3 \cdot \frac{1}{x}\right)\right)}\]
    3. Applied simplify0.0

      \[\leadsto \color{blue}{\frac{-3}{x} - \frac{1 + \frac{3}{x}}{x \cdot x}}\]

    if 1.0998023011309302e-14 < (- (/ (- 3) x) (/ (+ 1 (/ 3 x)) (* x x)))

    1. Initial program 1.0

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

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

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

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

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

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

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

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

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

Runtime

Time bar (total: 1.4m)Debug logProfile

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