Average Error: 4.6 → 0.7
Time: 5.0s
Precision: 64
\[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.41561703945165 \cdot 10^{-8}:\\ \;\;\;\;\sqrt{\frac{\frac{{\left(e^{2 \cdot x}\right)}^{3} - {1}^{3}}{\mathsf{fma}\left(e^{2 \cdot x} + 1, 1, {\left(e^{2}\right)}^{\left(2 \cdot x\right)}\right)}}{\frac{1}{\frac{e^{x} + 1}{{\left(e^{2 \cdot x}\right)}^{3} - {\left(1 \cdot 1\right)}^{3}} \cdot \left(e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right) + e^{2 \cdot x} \cdot \left(1 \cdot 1\right)\right)\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(0.5, {x}^{2}, \mathsf{fma}\left(1, x, 2\right)\right)}\\ \end{array}\]
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\begin{array}{l}
\mathbf{if}\;x \le -1.41561703945165 \cdot 10^{-8}:\\
\;\;\;\;\sqrt{\frac{\frac{{\left(e^{2 \cdot x}\right)}^{3} - {1}^{3}}{\mathsf{fma}\left(e^{2 \cdot x} + 1, 1, {\left(e^{2}\right)}^{\left(2 \cdot x\right)}\right)}}{\frac{1}{\frac{e^{x} + 1}{{\left(e^{2 \cdot x}\right)}^{3} - {\left(1 \cdot 1\right)}^{3}} \cdot \left(e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right) + e^{2 \cdot x} \cdot \left(1 \cdot 1\right)\right)\right)}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(0.5, {x}^{2}, \mathsf{fma}\left(1, x, 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.41561703945165e-08)) {
		VAR = sqrt((((pow(exp((2.0 * x)), 3.0) - pow(1.0, 3.0)) / fma((exp((2.0 * x)) + 1.0), 1.0, pow(exp(2.0), (2.0 * x)))) / (1.0 / (((exp(x) + 1.0) / (pow(exp((2.0 * x)), 3.0) - pow((1.0 * 1.0), 3.0))) * ((exp((2.0 * x)) * exp((2.0 * x))) + (((1.0 * 1.0) * (1.0 * 1.0)) + (exp((2.0 * x)) * (1.0 * 1.0))))))));
	} else {
		VAR = sqrt(fma(0.5, pow(x, 2.0), fma(1.0, x, 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.41561703945165e-08

    1. Initial program 0.3

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

      \[\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}}}\]
    5. Using strategy rm
    6. Applied clear-num0.0

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

      \[\leadsto \sqrt{\frac{e^{2 \cdot x} - 1}{\frac{1}{\color{blue}{\frac{e^{x} + 1}{e^{2 \cdot x} - 1 \cdot 1}}}}}\]
    8. Using strategy rm
    9. Applied flip3--0.2

      \[\leadsto \sqrt{\frac{e^{2 \cdot x} - 1}{\frac{1}{\frac{e^{x} + 1}{\color{blue}{\frac{{\left(e^{2 \cdot x}\right)}^{3} - {\left(1 \cdot 1\right)}^{3}}{e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right) + e^{2 \cdot x} \cdot \left(1 \cdot 1\right)\right)}}}}}}\]
    10. Applied associate-/r/0.2

      \[\leadsto \sqrt{\frac{e^{2 \cdot x} - 1}{\frac{1}{\color{blue}{\frac{e^{x} + 1}{{\left(e^{2 \cdot x}\right)}^{3} - {\left(1 \cdot 1\right)}^{3}} \cdot \left(e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right) + e^{2 \cdot x} \cdot \left(1 \cdot 1\right)\right)\right)}}}}\]
    11. Using strategy rm
    12. Applied flip3--0.0

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

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

    if -1.41561703945165e-08 < x

    1. Initial program 36.7

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

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

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

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

Reproduce

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