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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{x}{2} \cdot \frac{x}{\sqrt{2}}, \mathsf{fma}\left(\frac{{x}^{2}}{\sqrt{2}}, 0.2500000000000008881784197001252323389053, \mathsf{fma}\left(0.5, \frac{x}{\sqrt{2}}, \sqrt{2}\right)\right)\right)\\

\end{array}
double f(double x) {
        double r39172 = 2.0;
        double r39173 = x;
        double r39174 = r39172 * r39173;
        double r39175 = exp(r39174);
        double r39176 = 1.0;
        double r39177 = r39175 - r39176;
        double r39178 = exp(r39173);
        double r39179 = r39178 - r39176;
        double r39180 = r39177 / r39179;
        double r39181 = sqrt(r39180);
        return r39181;
}

double f(double x) {
        double r39182 = x;
        double r39183 = -1.0586348953815684e-10;
        bool r39184 = r39182 <= r39183;
        double r39185 = 1.0;
        double r39186 = 3.0;
        double r39187 = pow(r39185, r39186);
        double r39188 = exp(r39182);
        double r39189 = pow(r39188, r39186);
        double r39190 = r39187 + r39189;
        double r39191 = 2.0;
        double r39192 = r39191 * r39182;
        double r39193 = exp(r39192);
        double r39194 = r39193 - r39185;
        double r39195 = r39190 * r39194;
        double r39196 = -r39185;
        double r39197 = 2.0;
        double r39198 = exp(r39197);
        double r39199 = pow(r39198, r39182);
        double r39200 = fma(r39185, r39196, r39199);
        double r39201 = r39195 / r39200;
        double r39202 = r39188 * r39188;
        double r39203 = r39185 * r39185;
        double r39204 = r39185 * r39188;
        double r39205 = r39203 - r39204;
        double r39206 = r39202 + r39205;
        double r39207 = r39201 / r39206;
        double r39208 = sqrt(r39207);
        double r39209 = 0.125;
        double r39210 = -r39209;
        double r39211 = r39182 / r39191;
        double r39212 = sqrt(r39191);
        double r39213 = r39182 / r39212;
        double r39214 = r39211 * r39213;
        double r39215 = pow(r39182, r39197);
        double r39216 = r39215 / r39212;
        double r39217 = 0.2500000000000009;
        double r39218 = 0.5;
        double r39219 = fma(r39218, r39213, r39212);
        double r39220 = fma(r39216, r39217, r39219);
        double r39221 = fma(r39210, r39214, r39220);
        double r39222 = r39184 ? r39208 : r39221;
        return r39222;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -1.0586348953815684e-10

    1. Initial program 0.4

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

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

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

      \[\leadsto \sqrt{\frac{{\left(e^{2}\right)}^{x} - 1}{\frac{\color{blue}{\mathsf{fma}\left(1, -1, e^{x + x}\right)}}{e^{x} + 1}}}\]
    6. Using strategy rm
    7. Applied flip3-+0.0

      \[\leadsto \sqrt{\frac{{\left(e^{2}\right)}^{x} - 1}{\frac{\mathsf{fma}\left(1, -1, e^{x + x}\right)}{\color{blue}{\frac{{\left(e^{x}\right)}^{3} + {1}^{3}}{e^{x} \cdot e^{x} + \left(1 \cdot 1 - e^{x} \cdot 1\right)}}}}}\]
    8. Applied associate-/r/0.0

      \[\leadsto \sqrt{\frac{{\left(e^{2}\right)}^{x} - 1}{\color{blue}{\frac{\mathsf{fma}\left(1, -1, e^{x + x}\right)}{{\left(e^{x}\right)}^{3} + {1}^{3}} \cdot \left(e^{x} \cdot e^{x} + \left(1 \cdot 1 - e^{x} \cdot 1\right)\right)}}}\]
    9. Applied associate-/r*0.0

      \[\leadsto \sqrt{\color{blue}{\frac{\frac{{\left(e^{2}\right)}^{x} - 1}{\frac{\mathsf{fma}\left(1, -1, e^{x + x}\right)}{{\left(e^{x}\right)}^{3} + {1}^{3}}}}{e^{x} \cdot e^{x} + \left(1 \cdot 1 - e^{x} \cdot 1\right)}}}\]
    10. Simplified0.0

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

    if -1.0586348953815684e-10 < x

    1. Initial program 35.7

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

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

      \[\leadsto \sqrt{\frac{{\left(e^{2}\right)}^{x} - 1}{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}}\]
    5. Simplified24.4

      \[\leadsto \sqrt{\frac{{\left(e^{2}\right)}^{x} - 1}{\frac{\color{blue}{\mathsf{fma}\left(1, -1, e^{x + x}\right)}}{e^{x} + 1}}}\]
    6. Using strategy rm
    7. Applied flip3-+24.6

      \[\leadsto \sqrt{\frac{{\left(e^{2}\right)}^{x} - 1}{\frac{\mathsf{fma}\left(1, -1, e^{x + x}\right)}{\color{blue}{\frac{{\left(e^{x}\right)}^{3} + {1}^{3}}{e^{x} \cdot e^{x} + \left(1 \cdot 1 - e^{x} \cdot 1\right)}}}}}\]
    8. Applied associate-/r/24.6

      \[\leadsto \sqrt{\frac{{\left(e^{2}\right)}^{x} - 1}{\color{blue}{\frac{\mathsf{fma}\left(1, -1, e^{x + x}\right)}{{\left(e^{x}\right)}^{3} + {1}^{3}} \cdot \left(e^{x} \cdot e^{x} + \left(1 \cdot 1 - e^{x} \cdot 1\right)\right)}}}\]
    9. Applied associate-/r*24.6

      \[\leadsto \sqrt{\color{blue}{\frac{\frac{{\left(e^{2}\right)}^{x} - 1}{\frac{\mathsf{fma}\left(1, -1, e^{x + x}\right)}{{\left(e^{x}\right)}^{3} + {1}^{3}}}}{e^{x} \cdot e^{x} + \left(1 \cdot 1 - e^{x} \cdot 1\right)}}}\]
    10. Simplified24.8

      \[\leadsto \sqrt{\frac{\color{blue}{\frac{\left(e^{x \cdot 2} - 1\right) \cdot \left({\left(e^{x}\right)}^{3} + {1}^{3}\right)}{\mathsf{fma}\left(1, -1, {\left(e^{2}\right)}^{x}\right)}}}{e^{x} \cdot e^{x} + \left(1 \cdot 1 - e^{x} \cdot 1\right)}}\]
    11. Taylor expanded around 0 7.3

      \[\leadsto \color{blue}{\left(\sqrt{2} + \left(0.5 \cdot \frac{x}{\sqrt{2}} + 0.2500000000000008881784197001252323389053 \cdot \frac{{x}^{2}}{\sqrt{2}}\right)\right) - 0.125 \cdot \frac{{x}^{2}}{{\left(\sqrt{2}\right)}^{3}}}\]
    12. Simplified7.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{x}{2} \cdot \frac{x}{\sqrt{2}}, \mathsf{fma}\left(\frac{{x}^{2}}{\sqrt{2}}, 0.2500000000000008881784197001252323389053, \mathsf{fma}\left(0.5, \frac{x}{\sqrt{2}}, \sqrt{2}\right)\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

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

Reproduce

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