Average Error: 4.6 → 0.8
Time: 19.8s
Precision: 64
\[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -9.627556263318037368709352563644898737039 \cdot 10^{-6}:\\ \;\;\;\;\sqrt{\frac{\mathsf{fma}\left({\left(e^{2}\right)}^{\left(\frac{x}{2}\right)}, {\left(e^{2}\right)}^{\left(\frac{x}{2}\right)}, -1\right)}{e^{x} - 1}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\sqrt[3]{{\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.5, 1\right), 2\right)\right)}^{3}}}\\ \end{array}\]
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\begin{array}{l}
\mathbf{if}\;x \le -9.627556263318037368709352563644898737039 \cdot 10^{-6}:\\
\;\;\;\;\sqrt{\frac{\mathsf{fma}\left({\left(e^{2}\right)}^{\left(\frac{x}{2}\right)}, {\left(e^{2}\right)}^{\left(\frac{x}{2}\right)}, -1\right)}{e^{x} - 1}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\sqrt[3]{{\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.5, 1\right), 2\right)\right)}^{3}}}\\

\end{array}
double f(double x) {
        double r24161 = 2.0;
        double r24162 = x;
        double r24163 = r24161 * r24162;
        double r24164 = exp(r24163);
        double r24165 = 1.0;
        double r24166 = r24164 - r24165;
        double r24167 = exp(r24162);
        double r24168 = r24167 - r24165;
        double r24169 = r24166 / r24168;
        double r24170 = sqrt(r24169);
        return r24170;
}

double f(double x) {
        double r24171 = x;
        double r24172 = -9.627556263318037e-06;
        bool r24173 = r24171 <= r24172;
        double r24174 = 2.0;
        double r24175 = exp(r24174);
        double r24176 = 2.0;
        double r24177 = r24171 / r24176;
        double r24178 = pow(r24175, r24177);
        double r24179 = 1.0;
        double r24180 = -r24179;
        double r24181 = fma(r24178, r24178, r24180);
        double r24182 = exp(r24171);
        double r24183 = r24182 - r24179;
        double r24184 = r24181 / r24183;
        double r24185 = sqrt(r24184);
        double r24186 = 0.5;
        double r24187 = fma(r24171, r24186, r24179);
        double r24188 = fma(r24171, r24187, r24174);
        double r24189 = 3.0;
        double r24190 = pow(r24188, r24189);
        double r24191 = cbrt(r24190);
        double r24192 = sqrt(r24191);
        double r24193 = r24173 ? r24185 : r24192;
        return r24193;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -9.627556263318037e-06

    1. Initial program 0.1

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\]
    2. Simplified0.1

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(e^{2}\right)}^{x} - 1}{e^{x} - 1}}}\]
    3. Using strategy rm
    4. Applied sqr-pow0.1

      \[\leadsto \sqrt{\frac{\color{blue}{{\left(e^{2}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{2}\right)}^{\left(\frac{x}{2}\right)}} - 1}{e^{x} - 1}}\]
    5. Applied fma-neg0.0

      \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{fma}\left({\left(e^{2}\right)}^{\left(\frac{x}{2}\right)}, {\left(e^{2}\right)}^{\left(\frac{x}{2}\right)}, -1\right)}}{e^{x} - 1}}\]

    if -9.627556263318037e-06 < x

    1. Initial program 34.4

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\]
    2. Simplified34.5

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(e^{2}\right)}^{x} - 1}{e^{x} - 1}}}\]
    3. Taylor expanded around 0 6.2

      \[\leadsto \sqrt{\color{blue}{1 \cdot x + \left(0.5 \cdot {x}^{2} + 2\right)}}\]
    4. Simplified6.2

      \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(1, x, \mathsf{fma}\left(x \cdot x, 0.5, 2\right)\right)}}\]
    5. Using strategy rm
    6. Applied add-cbrt-cube6.3

      \[\leadsto \sqrt{\color{blue}{\sqrt[3]{\left(\mathsf{fma}\left(1, x, \mathsf{fma}\left(x \cdot x, 0.5, 2\right)\right) \cdot \mathsf{fma}\left(1, x, \mathsf{fma}\left(x \cdot x, 0.5, 2\right)\right)\right) \cdot \mathsf{fma}\left(1, x, \mathsf{fma}\left(x \cdot x, 0.5, 2\right)\right)}}}\]
    7. Simplified6.3

      \[\leadsto \sqrt{\sqrt[3]{\color{blue}{{\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.5, 1\right), 2\right)\right)}^{3}}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -9.627556263318037368709352563644898737039 \cdot 10^{-6}:\\ \;\;\;\;\sqrt{\frac{\mathsf{fma}\left({\left(e^{2}\right)}^{\left(\frac{x}{2}\right)}, {\left(e^{2}\right)}^{\left(\frac{x}{2}\right)}, -1\right)}{e^{x} - 1}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\sqrt[3]{{\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.5, 1\right), 2\right)\right)}^{3}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019196 +o rules:numerics
(FPCore (x)
  :name "sqrtexp (problem 3.4.4)"
  (sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0))))