Average Error: 4.7 → 0.3
Time: 6.4s
Precision: 64
\[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.2162383544769925 \cdot 10^{-4}:\\ \;\;\;\;\sqrt{\frac{\left(\sqrt{e^{2 \cdot x}} + \sqrt{1}\right) \cdot \left(\sqrt{e^{2 \cdot x}} - \sqrt{1}\right)}{\sqrt[3]{{\left(e^{x} - 1\right)}^{3}}}}\\ \mathbf{elif}\;x \le 6.561572677279099 \cdot 10^{-15}:\\ \;\;\;\;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)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{\left(\sqrt{e^{2 \cdot x}} + \sqrt{1}\right) \cdot \left(\sqrt{e^{2 \cdot x}} - \sqrt{1}\right)}{e^{x} - 1}}\\ \end{array}\]
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\begin{array}{l}
\mathbf{if}\;x \le -2.2162383544769925 \cdot 10^{-4}:\\
\;\;\;\;\sqrt{\frac{\left(\sqrt{e^{2 \cdot x}} + \sqrt{1}\right) \cdot \left(\sqrt{e^{2 \cdot x}} - \sqrt{1}\right)}{\sqrt[3]{{\left(e^{x} - 1\right)}^{3}}}}\\

\mathbf{elif}\;x \le 6.561572677279099 \cdot 10^{-15}:\\
\;\;\;\;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)\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\left(\sqrt{e^{2 \cdot x}} + \sqrt{1}\right) \cdot \left(\sqrt{e^{2 \cdot x}} - \sqrt{1}\right)}{e^{x} - 1}}\\

\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 <= -0.00022162383544769925)) {
		VAR = sqrt((((sqrt(exp((2.0 * x))) + sqrt(1.0)) * (sqrt(exp((2.0 * x))) - sqrt(1.0))) / cbrt(pow((exp(x) - 1.0), 3.0))));
	} else {
		double VAR_1;
		if ((x <= 6.561572677279099e-15)) {
			VAR_1 = ((0.5 * (x / sqrt(2.0))) + (sqrt(2.0) + ((pow(x, 2.0) / sqrt(2.0)) * (0.25 - (0.125 / 2.0)))));
		} else {
			VAR_1 = sqrt((((sqrt(exp((2.0 * x))) + sqrt(1.0)) * (sqrt(exp((2.0 * x))) - sqrt(1.0))) / (exp(x) - 1.0)));
		}
		VAR = VAR_1;
	}
	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 3 regimes
  2. if x < -0.00022162383544769925

    1. Initial program 0.0

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.0

      \[\leadsto \sqrt{\frac{e^{2 \cdot x} - \color{blue}{\sqrt{1} \cdot \sqrt{1}}}{e^{x} - 1}}\]
    4. Applied add-sqr-sqrt0.0

      \[\leadsto \sqrt{\frac{\color{blue}{\sqrt{e^{2 \cdot x}} \cdot \sqrt{e^{2 \cdot x}}} - \sqrt{1} \cdot \sqrt{1}}{e^{x} - 1}}\]
    5. Applied difference-of-squares0.0

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

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

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

    if -0.00022162383544769925 < x < 6.561572677279099e-15

    1. Initial program 45.8

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

      \[\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. Simplified0.4

      \[\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)}\]

    if 6.561572677279099e-15 < x

    1. Initial program 15.0

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt15.0

      \[\leadsto \sqrt{\frac{e^{2 \cdot x} - \color{blue}{\sqrt{1} \cdot \sqrt{1}}}{e^{x} - 1}}\]
    4. Applied add-sqr-sqrt13.4

      \[\leadsto \sqrt{\frac{\color{blue}{\sqrt{e^{2 \cdot x}} \cdot \sqrt{e^{2 \cdot x}}} - \sqrt{1} \cdot \sqrt{1}}{e^{x} - 1}}\]
    5. Applied difference-of-squares5.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.2162383544769925 \cdot 10^{-4}:\\ \;\;\;\;\sqrt{\frac{\left(\sqrt{e^{2 \cdot x}} + \sqrt{1}\right) \cdot \left(\sqrt{e^{2 \cdot x}} - \sqrt{1}\right)}{\sqrt[3]{{\left(e^{x} - 1\right)}^{3}}}}\\ \mathbf{elif}\;x \le 6.561572677279099 \cdot 10^{-15}:\\ \;\;\;\;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)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{\left(\sqrt{e^{2 \cdot x}} + \sqrt{1}\right) \cdot \left(\sqrt{e^{2 \cdot x}} - \sqrt{1}\right)}{e^{x} - 1}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020091 
(FPCore (x)
  :name "sqrtexp (problem 3.4.4)"
  :precision binary64
  (sqrt (/ (- (exp (* 2 x)) 1) (- (exp x) 1))))