Average Error: 59.1 → 0.2
Time: 10.1s
Precision: 64
\[\sqrt{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le 1.59252664246739995129731326528599311132 \cdot 10^{-4}:\\ \;\;\;\;\sqrt{{x}^{2} \cdot \left(\frac{1}{2} + x \cdot \frac{1}{6}\right) + x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{e^{x + x} - 1 \cdot 1}}{\sqrt{e^{x} + 1}}\\ \end{array}\]
\sqrt{e^{x} - 1}
\begin{array}{l}
\mathbf{if}\;x \le 1.59252664246739995129731326528599311132 \cdot 10^{-4}:\\
\;\;\;\;\sqrt{{x}^{2} \cdot \left(\frac{1}{2} + x \cdot \frac{1}{6}\right) + x}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{e^{x + x} - 1 \cdot 1}}{\sqrt{e^{x} + 1}}\\

\end{array}
double f(double x) {
        double r1064816 = x;
        double r1064817 = exp(r1064816);
        double r1064818 = 1.0;
        double r1064819 = r1064817 - r1064818;
        double r1064820 = sqrt(r1064819);
        return r1064820;
}

double f(double x) {
        double r1064821 = x;
        double r1064822 = 0.00015925266424674;
        bool r1064823 = r1064821 <= r1064822;
        double r1064824 = 2.0;
        double r1064825 = pow(r1064821, r1064824);
        double r1064826 = 0.5;
        double r1064827 = 0.16666666666666666;
        double r1064828 = r1064821 * r1064827;
        double r1064829 = r1064826 + r1064828;
        double r1064830 = r1064825 * r1064829;
        double r1064831 = r1064830 + r1064821;
        double r1064832 = sqrt(r1064831);
        double r1064833 = r1064821 + r1064821;
        double r1064834 = exp(r1064833);
        double r1064835 = 1.0;
        double r1064836 = r1064835 * r1064835;
        double r1064837 = r1064834 - r1064836;
        double r1064838 = sqrt(r1064837);
        double r1064839 = exp(r1064821);
        double r1064840 = r1064839 + r1064835;
        double r1064841 = sqrt(r1064840);
        double r1064842 = r1064838 / r1064841;
        double r1064843 = r1064823 ? r1064832 : r1064842;
        return r1064843;
}

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 < 0.00015925266424674

    1. Initial program 60.3

      \[\sqrt{e^{x} - 1}\]
    2. Taylor expanded around 0 0.0

      \[\leadsto \sqrt{\color{blue}{\frac{1}{2} \cdot {x}^{2} + \left(x + \frac{1}{6} \cdot {x}^{3}\right)}}\]
    3. Simplified0.0

      \[\leadsto \sqrt{\color{blue}{{x}^{2} \cdot \left(\frac{1}{2} + x \cdot \frac{1}{6}\right) + x}}\]

    if 0.00015925266424674 < x

    1. Initial program 6.9

      \[\sqrt{e^{x} - 1}\]
    2. Using strategy rm
    3. Applied flip--9.6

      \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}\]
    4. Applied sqrt-div9.7

      \[\leadsto \color{blue}{\frac{\sqrt{e^{x} \cdot e^{x} - 1 \cdot 1}}{\sqrt{e^{x} + 1}}}\]
    5. Simplified9.3

      \[\leadsto \frac{\color{blue}{\sqrt{e^{x + x} - 1 \cdot 1}}}{\sqrt{e^{x} + 1}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 1.59252664246739995129731326528599311132 \cdot 10^{-4}:\\ \;\;\;\;\sqrt{{x}^{2} \cdot \left(\frac{1}{2} + x \cdot \frac{1}{6}\right) + x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{e^{x + x} - 1 \cdot 1}}{\sqrt{e^{x} + 1}}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (x)
  :name "sqrt(exp(x) - 1)"
  :precision binary64
  (sqrt (- (exp x) 1)))