Average Error: 4.6 → 0.9
Time: 20.0s
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{\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}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{x}{\sqrt{2}} \cdot \frac{x}{2}, \mathsf{fma}\left(0.25, \frac{x \cdot x}{\sqrt{2}}, \mathsf{fma}\left(\frac{x}{\sqrt{2}}, 0.5, \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{\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}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{x}{\sqrt{2}} \cdot \frac{x}{2}, \mathsf{fma}\left(0.25, \frac{x \cdot x}{\sqrt{2}}, \mathsf{fma}\left(\frac{x}{\sqrt{2}}, 0.5, \sqrt{2}\right)\right)\right)\\

\end{array}
double f(double x) {
        double r28704 = 2.0;
        double r28705 = x;
        double r28706 = r28704 * r28705;
        double r28707 = exp(r28706);
        double r28708 = 1.0;
        double r28709 = r28707 - r28708;
        double r28710 = exp(r28705);
        double r28711 = r28710 - r28708;
        double r28712 = r28709 / r28711;
        double r28713 = sqrt(r28712);
        return r28713;
}

double f(double x) {
        double r28714 = x;
        double r28715 = -1.0586348953815684e-10;
        bool r28716 = r28714 <= r28715;
        double r28717 = 2.0;
        double r28718 = exp(r28717);
        double r28719 = 2.0;
        double r28720 = r28714 / r28719;
        double r28721 = pow(r28718, r28720);
        double r28722 = 1.0;
        double r28723 = -r28722;
        double r28724 = fma(r28721, r28721, r28723);
        double r28725 = exp(r28714);
        double r28726 = r28725 - r28722;
        double r28727 = r28724 / r28726;
        double r28728 = sqrt(r28727);
        double r28729 = 0.125;
        double r28730 = -r28729;
        double r28731 = sqrt(r28717);
        double r28732 = r28714 / r28731;
        double r28733 = r28714 / r28717;
        double r28734 = r28732 * r28733;
        double r28735 = 0.25;
        double r28736 = r28714 * r28714;
        double r28737 = r28736 / r28731;
        double r28738 = 0.5;
        double r28739 = fma(r28732, r28738, r28731);
        double r28740 = fma(r28735, r28737, r28739);
        double r28741 = fma(r28730, r28734, r28740);
        double r28742 = r28716 ? r28728 : r28741;
        return r28742;
}

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 sqr-pow0.3

      \[\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 -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. Taylor expanded around 0 7.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{x}{\sqrt{2}} \cdot \frac{x}{2}, \mathsf{fma}\left(0.25, \frac{x \cdot x}{\sqrt{2}}, \mathsf{fma}\left(\frac{x}{\sqrt{2}}, 0.5, \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{\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}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{x}{\sqrt{2}} \cdot \frac{x}{2}, \mathsf{fma}\left(0.25, \frac{x \cdot x}{\sqrt{2}}, \mathsf{fma}\left(\frac{x}{\sqrt{2}}, 0.5, \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))))