Average Error: 4.7 → 0.8
Time: 5.4s
Precision: 64
\[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.5501934119102568 \cdot 10^{-17}:\\ \;\;\;\;\sqrt{\frac{\sqrt{\sqrt{e^{2 \cdot x}}} \cdot \sqrt{\sqrt{e^{2 \cdot x}}} + \sqrt{1}}{1}} \cdot \sqrt{\frac{{\left(e^{2}\right)}^{\left(\frac{1}{2} \cdot x\right)} - \sqrt{1}}{e^{x} - 1}}\\ \mathbf{else}:\\ \;\;\;\;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)\\ \end{array}\]
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\begin{array}{l}
\mathbf{if}\;x \le -5.5501934119102568 \cdot 10^{-17}:\\
\;\;\;\;\sqrt{\frac{\sqrt{\sqrt{e^{2 \cdot x}}} \cdot \sqrt{\sqrt{e^{2 \cdot x}}} + \sqrt{1}}{1}} \cdot \sqrt{\frac{{\left(e^{2}\right)}^{\left(\frac{1}{2} \cdot x\right)} - \sqrt{1}}{e^{x} - 1}}\\

\mathbf{else}:\\
\;\;\;\;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)\\

\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 <= -5.550193411910257e-17)) {
		temp = (sqrt((((sqrt(sqrt(exp((2.0 * x)))) * sqrt(sqrt(exp((2.0 * x))))) + sqrt(1.0)) / 1.0)) * sqrt(((pow(exp(2.0), (0.5 * x)) - sqrt(1.0)) / (exp(x) - 1.0))));
	} else {
		temp = ((0.5 * (x / sqrt(2.0))) + (sqrt(2.0) + ((pow(x, 2.0) / sqrt(2.0)) * (0.25 - (0.125 / 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 < -5.550193411910257e-17

    1. Initial program 0.9

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.9

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

      \[\leadsto \sqrt{\frac{e^{2 \cdot x} - \color{blue}{\sqrt{1} \cdot \sqrt{1}}}{1 \cdot \left(e^{x} - 1\right)}}\]
    5. Applied add-sqr-sqrt0.7

      \[\leadsto \sqrt{\frac{\color{blue}{\sqrt{e^{2 \cdot x}} \cdot \sqrt{e^{2 \cdot x}}} - \sqrt{1} \cdot \sqrt{1}}{1 \cdot \left(e^{x} - 1\right)}}\]
    6. Applied difference-of-squares0.3

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

      \[\leadsto \sqrt{\color{blue}{\frac{\sqrt{e^{2 \cdot x}} + \sqrt{1}}{1} \cdot \frac{\sqrt{e^{2 \cdot x}} - \sqrt{1}}{e^{x} - 1}}}\]
    8. Applied sqrt-prod0.3

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

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

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

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

      \[\leadsto \sqrt{\frac{\sqrt{e^{2 \cdot x}} + \sqrt{1}}{1}} \cdot \sqrt{\frac{{\left(e^{2}\right)}^{\color{blue}{\left(\frac{1}{2} \cdot x\right)}} - \sqrt{1}}{e^{x} - 1}}\]
    14. Using strategy rm
    15. Applied add-sqr-sqrt0.0

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

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

    if -5.550193411910257e-17 < x

    1. Initial program 38.3

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

      \[\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.1

      \[\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)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

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

Reproduce

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