Average Error: 29.8 → 0.1
Time: 27.1s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -14872.906038072784:\\ \;\;\;\;\left(\frac{-1}{x \cdot x} - \frac{3}{x}\right) - \frac{3}{\left(x \cdot x\right) \cdot x}\\ \mathbf{elif}\;x \le 9738.110188373239:\\ \;\;\;\;\left(\left(1 + \left(x - x \cdot x\right)\right) \cdot \left(\left(1 + x\right) \cdot \left(1 - x\right)\right)\right) \cdot \frac{\frac{\left(x - 1\right) \cdot \left(x \cdot \left(1 - \left(x - x \cdot x\right)\right)\right) - \left(1 + x\right) \cdot \left(1 + \left(x \cdot x\right) \cdot x\right)}{1 - \left(x - x \cdot x\right) \cdot \left(x - x \cdot x\right)}}{\left(1 - x \cdot x\right) \cdot \left(-1 + x \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-1}{x \cdot x} - \frac{3}{x}\right) - \frac{3}{\left(x \cdot x\right) \cdot x}\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -14872.906038072784:\\
\;\;\;\;\left(\frac{-1}{x \cdot x} - \frac{3}{x}\right) - \frac{3}{\left(x \cdot x\right) \cdot x}\\

\mathbf{elif}\;x \le 9738.110188373239:\\
\;\;\;\;\left(\left(1 + \left(x - x \cdot x\right)\right) \cdot \left(\left(1 + x\right) \cdot \left(1 - x\right)\right)\right) \cdot \frac{\frac{\left(x - 1\right) \cdot \left(x \cdot \left(1 - \left(x - x \cdot x\right)\right)\right) - \left(1 + x\right) \cdot \left(1 + \left(x \cdot x\right) \cdot x\right)}{1 - \left(x - x \cdot x\right) \cdot \left(x - x \cdot x\right)}}{\left(1 - x \cdot x\right) \cdot \left(-1 + x \cdot x\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{-1}{x \cdot x} - \frac{3}{x}\right) - \frac{3}{\left(x \cdot x\right) \cdot x}\\

\end{array}
double f(double x) {
        double r5313654 = x;
        double r5313655 = 1.0;
        double r5313656 = r5313654 + r5313655;
        double r5313657 = r5313654 / r5313656;
        double r5313658 = r5313654 - r5313655;
        double r5313659 = r5313656 / r5313658;
        double r5313660 = r5313657 - r5313659;
        return r5313660;
}

double f(double x) {
        double r5313661 = x;
        double r5313662 = -14872.906038072784;
        bool r5313663 = r5313661 <= r5313662;
        double r5313664 = -1.0;
        double r5313665 = r5313661 * r5313661;
        double r5313666 = r5313664 / r5313665;
        double r5313667 = 3.0;
        double r5313668 = r5313667 / r5313661;
        double r5313669 = r5313666 - r5313668;
        double r5313670 = r5313665 * r5313661;
        double r5313671 = r5313667 / r5313670;
        double r5313672 = r5313669 - r5313671;
        double r5313673 = 9738.110188373239;
        bool r5313674 = r5313661 <= r5313673;
        double r5313675 = 1.0;
        double r5313676 = r5313661 - r5313665;
        double r5313677 = r5313675 + r5313676;
        double r5313678 = r5313675 + r5313661;
        double r5313679 = r5313675 - r5313661;
        double r5313680 = r5313678 * r5313679;
        double r5313681 = r5313677 * r5313680;
        double r5313682 = r5313661 - r5313675;
        double r5313683 = r5313675 - r5313676;
        double r5313684 = r5313661 * r5313683;
        double r5313685 = r5313682 * r5313684;
        double r5313686 = r5313675 + r5313670;
        double r5313687 = r5313678 * r5313686;
        double r5313688 = r5313685 - r5313687;
        double r5313689 = r5313676 * r5313676;
        double r5313690 = r5313675 - r5313689;
        double r5313691 = r5313688 / r5313690;
        double r5313692 = r5313675 - r5313665;
        double r5313693 = r5313664 + r5313665;
        double r5313694 = r5313692 * r5313693;
        double r5313695 = r5313691 / r5313694;
        double r5313696 = r5313681 * r5313695;
        double r5313697 = r5313674 ? r5313696 : r5313672;
        double r5313698 = r5313663 ? r5313672 : r5313697;
        return r5313698;
}

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 < -14872.906038072784 or 9738.110188373239 < x

    1. Initial program 59.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(\frac{1}{{x}^{2}} + 3 \cdot \frac{1}{x}\right)\right)}\]
    3. Simplified0.0

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

    if -14872.906038072784 < x < 9738.110188373239

    1. Initial program 0.1

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

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

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

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

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

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

      \[\leadsto \frac{\left(1 - \left(x - x \cdot x\right)\right) \cdot \left(x \cdot \left(x - 1\right)\right) - \left(\left(1 + x \cdot \left(x \cdot x\right)\right) + x \cdot \left(1 + x \cdot \left(x \cdot x\right)\right)\right)}{\color{blue}{\left(1 - \left(x - x \cdot x\right)\right) \cdot \left(\left(x - 1\right) \cdot \left(1 + x\right)\right)}}\]
    10. Using strategy rm
    11. Applied flip-+0.1

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

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

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

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

      \[\leadsto \frac{\left(1 - \left(x - x \cdot x\right)\right) \cdot \left(x \cdot \left(x - 1\right)\right) - \left(\left(1 + x \cdot \left(x \cdot x\right)\right) + x \cdot \left(1 + x \cdot \left(x \cdot x\right)\right)\right)}{\color{blue}{\frac{\left(1 \cdot 1 - \left(x - x \cdot x\right) \cdot \left(x - x \cdot x\right)\right) \cdot \left(\left(x \cdot x - 1 \cdot 1\right) \cdot \left(1 \cdot 1 - x \cdot x\right)\right)}{\left(1 + \left(x - x \cdot x\right)\right) \cdot \left(\left(x + 1\right) \cdot \left(1 - x\right)\right)}}}\]
    16. Applied associate-/r/0.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -14872.906038072784:\\ \;\;\;\;\left(\frac{-1}{x \cdot x} - \frac{3}{x}\right) - \frac{3}{\left(x \cdot x\right) \cdot x}\\ \mathbf{elif}\;x \le 9738.110188373239:\\ \;\;\;\;\left(\left(1 + \left(x - x \cdot x\right)\right) \cdot \left(\left(1 + x\right) \cdot \left(1 - x\right)\right)\right) \cdot \frac{\frac{\left(x - 1\right) \cdot \left(x \cdot \left(1 - \left(x - x \cdot x\right)\right)\right) - \left(1 + x\right) \cdot \left(1 + \left(x \cdot x\right) \cdot x\right)}{1 - \left(x - x \cdot x\right) \cdot \left(x - x \cdot x\right)}}{\left(1 - x \cdot x\right) \cdot \left(-1 + x \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-1}{x \cdot x} - \frac{3}{x}\right) - \frac{3}{\left(x \cdot x\right) \cdot x}\\ \end{array}\]

Reproduce

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