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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x}{\sqrt{2}} + \left(\sqrt{2} + \frac{{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)}^{2}}{\sqrt{\sqrt{2}}} \cdot \left(\frac{{\left(\sqrt[3]{x}\right)}^{2}}{\sqrt{\sqrt{2}}} \cdot \left(0.25 - \frac{0.125}{2}\right)\right)\right)\\

\end{array}
double code(double x) {
	return sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
}
double code(double x) {
	double VAR;
	if ((x <= -4.0542415267134493e-17)) {
		VAR = sqrt((cbrt(pow((exp((2.0 * x)) - 1.0), 3.0)) / (fma(-1.0, 1.0, exp((x + x))) / (exp(x) + 1.0))));
	} else {
		VAR = ((0.5 * (x / sqrt(2.0))) + (sqrt(2.0) + ((pow((cbrt(x) * cbrt(x)), 2.0) / sqrt(sqrt(2.0))) * ((pow(cbrt(x), 2.0) / sqrt(sqrt(2.0))) * (0.25 - (0.125 / 2.0))))));
	}
	return VAR;
}

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 < -4.0542415267134493e-17

    1. Initial program 0.9

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

      \[\leadsto \sqrt{\frac{e^{2 \cdot x} - 1}{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}}\]
    4. Simplified0.0

      \[\leadsto \sqrt{\frac{e^{2 \cdot x} - 1}{\frac{\color{blue}{\mathsf{fma}\left(-1, 1, e^{x + x}\right)}}{e^{x} + 1}}}\]
    5. Using strategy rm
    6. Applied add-cbrt-cube0.0

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

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

    if -4.0542415267134493e-17 < x

    1. Initial program 37.0

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x}{\sqrt{2}} + \left(\sqrt{2} + \frac{{x}^{2}}{\sqrt{2}} \cdot \left(0.25 - \frac{0.125}{2}\right)\right)}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt8.7

      \[\leadsto 0.5 \cdot \frac{x}{\sqrt{2}} + \left(\sqrt{2} + \frac{{x}^{2}}{\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}} \cdot \left(0.25 - \frac{0.125}{2}\right)\right)\]
    6. Applied sqrt-prod8.7

      \[\leadsto 0.5 \cdot \frac{x}{\sqrt{2}} + \left(\sqrt{2} + \frac{{x}^{2}}{\color{blue}{\sqrt{\sqrt{2}} \cdot \sqrt{\sqrt{2}}}} \cdot \left(0.25 - \frac{0.125}{2}\right)\right)\]
    7. Applied add-cube-cbrt8.7

      \[\leadsto 0.5 \cdot \frac{x}{\sqrt{2}} + \left(\sqrt{2} + \frac{{\color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)}}^{2}}{\sqrt{\sqrt{2}} \cdot \sqrt{\sqrt{2}}} \cdot \left(0.25 - \frac{0.125}{2}\right)\right)\]
    8. Applied unpow-prod-down8.7

      \[\leadsto 0.5 \cdot \frac{x}{\sqrt{2}} + \left(\sqrt{2} + \frac{\color{blue}{{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)}^{2} \cdot {\left(\sqrt[3]{x}\right)}^{2}}}{\sqrt{\sqrt{2}} \cdot \sqrt{\sqrt{2}}} \cdot \left(0.25 - \frac{0.125}{2}\right)\right)\]
    9. Applied times-frac8.7

      \[\leadsto 0.5 \cdot \frac{x}{\sqrt{2}} + \left(\sqrt{2} + \color{blue}{\left(\frac{{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)}^{2}}{\sqrt{\sqrt{2}}} \cdot \frac{{\left(\sqrt[3]{x}\right)}^{2}}{\sqrt{\sqrt{2}}}\right)} \cdot \left(0.25 - \frac{0.125}{2}\right)\right)\]
    10. Applied associate-*l*8.7

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

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

Reproduce

herbie shell --seed 2020092 +o rules:numerics
(FPCore (x)
  :name "sqrtexp (problem 3.4.4)"
  :precision binary64
  (sqrt (/ (- (exp (* 2 x)) 1) (- (exp x) 1))))