Average Error: 5.3 → 0.7
Time: 5.2s
Precision: 64
\[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.47296027893171819 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{\frac{\sqrt{e^{2 \cdot x}} + \sqrt{1}}{\frac{e^{x} - 1}{{\left(e^{2}\right)}^{\left(\frac{1}{2} \cdot x\right)} - \sqrt{1}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x \cdot \left(1 + 0.5 \cdot x\right) + 2}\\ \end{array}\]
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\begin{array}{l}
\mathbf{if}\;x \le -1.47296027893171819 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{\frac{\sqrt{e^{2 \cdot x}} + \sqrt{1}}{\frac{e^{x} - 1}{{\left(e^{2}\right)}^{\left(\frac{1}{2} \cdot x\right)} - \sqrt{1}}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{x \cdot \left(1 + 0.5 \cdot x\right) + 2}\\

\end{array}
double code(double x) {
	return sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
}
double code(double x) {
	double temp;
	if ((x <= -1.4729602789317182e-05)) {
		temp = sqrt(((sqrt(exp((2.0 * x))) + sqrt(1.0)) / ((exp(x) - 1.0) / (pow(exp(2.0), (0.5 * x)) - sqrt(1.0)))));
	} else {
		temp = sqrt(((x * (1.0 + (0.5 * x))) + 2.0));
	}
	return temp;
}

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 < -1.4729602789317182e-05

    1. Initial program 0.1

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

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

      \[\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. Applied associate-/l*0.0

      \[\leadsto \sqrt{\color{blue}{\frac{\sqrt{e^{2 \cdot x}} + \sqrt{1}}{\frac{e^{x} - 1}{\sqrt{e^{2 \cdot x}} - \sqrt{1}}}}}\]
    7. Using strategy rm
    8. Applied add-log-exp0.0

      \[\leadsto \sqrt{\frac{\sqrt{e^{2 \cdot x}} + \sqrt{1}}{\frac{e^{x} - 1}{\sqrt{e^{\color{blue}{\log \left(e^{2}\right)} \cdot x}} - \sqrt{1}}}}\]
    9. Applied exp-to-pow0.0

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

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

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

    if -1.4729602789317182e-05 < x

    1. Initial program 36.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.47296027893171819 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{\frac{\sqrt{e^{2 \cdot x}} + \sqrt{1}}{\frac{e^{x} - 1}{{\left(e^{2}\right)}^{\left(\frac{1}{2} \cdot x\right)} - \sqrt{1}}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x \cdot \left(1 + 0.5 \cdot x\right) + 2}\\ \end{array}\]

Reproduce

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