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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{{x}^{1}}{\frac{\sqrt{2}}{x}}, 0.25 - \frac{0.125}{2}, \mathsf{fma}\left(0.5, \frac{x}{\sqrt{2}}, \sqrt{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 VAR;
	if ((x <= -1.1188714909134117e-13)) {
		VAR = sqrt(((exp((2.0 * x)) - 1.0) / (fma(-1.0, 1.0, exp((x + x))) / (exp(x) + 1.0))));
	} else {
		VAR = fma((pow(x, 1.0) / (sqrt(2.0) / x)), (0.25 - (0.125 / 2.0)), fma(0.5, (x / sqrt(2.0)), sqrt(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 < -1.1188714909134117e-13

    1. Initial program 0.7

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

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

    if -1.1188714909134117e-13 < x

    1. Initial program 36.6

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{x}^{2}}{\sqrt{2}}, 0.25 - \frac{0.125}{2}, \mathsf{fma}\left(0.5, \frac{x}{\sqrt{2}}, \sqrt{2}\right)\right)}\]
    4. Using strategy rm
    5. Applied sqr-pow8.2

      \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{{x}^{\left(\frac{2}{2}\right)} \cdot {x}^{\left(\frac{2}{2}\right)}}}{\sqrt{2}}, 0.25 - \frac{0.125}{2}, \mathsf{fma}\left(0.5, \frac{x}{\sqrt{2}}, \sqrt{2}\right)\right)\]
    6. Applied associate-/l*8.2

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

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

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

Reproduce

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