Average Error: 4.7 → 0.2
Time: 6.4s
Precision: 64
\[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.49289552284852816 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{\frac{e^{2 \cdot x} - 1}{\mathsf{fma}\left(-1, 1, e^{x + x}\right)} \cdot \left(e^{x} + 1\right)}\\ \mathbf{elif}\;x \le 8.9599648132643091 \cdot 10^{-14}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(0.5, {x}^{2}, \mathsf{fma}\left(1, x, 2\right)\right)}\\ \mathbf{elif}\;x \le 356.58327449642752:\\ \;\;\;\;\sqrt{\frac{e^{2 \cdot x} - 1}{\mathsf{fma}\left(-1, 1, e^{x + x}\right)} \cdot \left(e^{x} + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{{x}^{2}}{{\left(\sqrt{2}\right)}^{3}}, \mathsf{fma}\left(\frac{{x}^{2}}{\sqrt{2}}, 0.25, \mathsf{fma}\left(0.5, \frac{x}{\sqrt{2}}, \sqrt{2}\right)\right)\right)\\ \end{array}\]
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\begin{array}{l}
\mathbf{if}\;x \le -1.49289552284852816 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{\frac{e^{2 \cdot x} - 1}{\mathsf{fma}\left(-1, 1, e^{x + x}\right)} \cdot \left(e^{x} + 1\right)}\\

\mathbf{elif}\;x \le 8.9599648132643091 \cdot 10^{-14}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(0.5, {x}^{2}, \mathsf{fma}\left(1, x, 2\right)\right)}\\

\mathbf{elif}\;x \le 356.58327449642752:\\
\;\;\;\;\sqrt{\frac{e^{2 \cdot x} - 1}{\mathsf{fma}\left(-1, 1, e^{x + x}\right)} \cdot \left(e^{x} + 1\right)}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{{x}^{2}}{{\left(\sqrt{2}\right)}^{3}}, \mathsf{fma}\left(\frac{{x}^{2}}{\sqrt{2}}, 0.25, \mathsf{fma}\left(0.5, \frac{x}{\sqrt{2}}, \sqrt{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 <= -1.4928955228485282e-05)) {
		VAR = sqrt((((exp((2.0 * x)) - 1.0) / fma(-1.0, 1.0, exp((x + x)))) * (exp(x) + 1.0)));
	} else {
		double VAR_1;
		if ((x <= 8.959964813264309e-14)) {
			VAR_1 = sqrt(fma(0.5, pow(x, 2.0), fma(1.0, x, 2.0)));
		} else {
			double VAR_2;
			if ((x <= 356.5832744964275)) {
				VAR_2 = sqrt((((exp((2.0 * x)) - 1.0) / fma(-1.0, 1.0, exp((x + x)))) * (exp(x) + 1.0)));
			} else {
				VAR_2 = fma(-0.125, (pow(x, 2.0) / pow(sqrt(2.0), 3.0)), fma((pow(x, 2.0) / sqrt(2.0)), 0.25, fma(0.5, (x / sqrt(2.0)), sqrt(2.0))));
			}
			VAR_1 = VAR_2;
		}
		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 < -1.4928955228485282e-05 or 8.959964813264309e-14 < x < 356.5832744964275

    1. Initial program 0.7

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

      \[\leadsto \sqrt{\frac{e^{2 \cdot x} - 1}{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}}\]
    4. Applied associate-/r/0.4

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

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

    if -1.4928955228485282e-05 < x < 8.959964813264309e-14

    1. Initial program 44.8

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

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

      \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(0.5, {x}^{2}, \mathsf{fma}\left(1, x, 2\right)\right)}}\]

    if 356.5832744964275 < x

    1. Initial program 64.0

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

      \[\leadsto \sqrt{\frac{e^{2 \cdot x} - 1}{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}}\]
    4. Applied associate-/r/64.0

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

      \[\leadsto \sqrt{\color{blue}{\frac{e^{2 \cdot x} - 1}{\mathsf{fma}\left(-1, 1, e^{x + x}\right)}} \cdot \left(e^{x} + 1\right)}\]
    6. Taylor expanded around 0 60.8

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

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

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

Reproduce

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