sqrtexp (problem 3.4.4)

Percentage Accurate: 35.2% → 100.0%
Time: 9.0s
Alternatives: 10
Speedup: 309.0×

Specification

?
\[\begin{array}{l} \\ \sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \end{array} \]
(FPCore (x)
 :precision binary64
 (sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0))))
double code(double x) {
	return sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt(((exp((2.0d0 * x)) - 1.0d0) / (exp(x) - 1.0d0)))
end function
public static double code(double x) {
	return Math.sqrt(((Math.exp((2.0 * x)) - 1.0) / (Math.exp(x) - 1.0)));
}
def code(x):
	return math.sqrt(((math.exp((2.0 * x)) - 1.0) / (math.exp(x) - 1.0)))
function code(x)
	return sqrt(Float64(Float64(exp(Float64(2.0 * x)) - 1.0) / Float64(exp(x) - 1.0)))
end
function tmp = code(x)
	tmp = sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
end
code[x_] := N[Sqrt[N[(N[(N[Exp[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 35.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \end{array} \]
(FPCore (x)
 :precision binary64
 (sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0))))
double code(double x) {
	return sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt(((exp((2.0d0 * x)) - 1.0d0) / (exp(x) - 1.0d0)))
end function
public static double code(double x) {
	return Math.sqrt(((Math.exp((2.0 * x)) - 1.0) / (Math.exp(x) - 1.0)));
}
def code(x):
	return math.sqrt(((math.exp((2.0 * x)) - 1.0) / (math.exp(x) - 1.0)))
function code(x)
	return sqrt(Float64(Float64(exp(Float64(2.0 * x)) - 1.0) / Float64(exp(x) - 1.0)))
end
function tmp = code(x)
	tmp = sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
end
code[x_] := N[Sqrt[N[(N[(N[Exp[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\end{array}

Alternative 1: 100.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \mathsf{hypot}\left(1, e^{x \cdot 0.5}\right) \end{array} \]
(FPCore (x) :precision binary64 (hypot 1.0 (exp (* x 0.5))))
double code(double x) {
	return hypot(1.0, exp((x * 0.5)));
}
public static double code(double x) {
	return Math.hypot(1.0, Math.exp((x * 0.5)));
}
def code(x):
	return math.hypot(1.0, math.exp((x * 0.5)))
function code(x)
	return hypot(1.0, exp(Float64(x * 0.5)))
end
function tmp = code(x)
	tmp = hypot(1.0, exp((x * 0.5)));
end
code[x_] := N[Sqrt[1.0 ^ 2 + N[Exp[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]
\begin{array}{l}

\\
\mathsf{hypot}\left(1, e^{x \cdot 0.5}\right)
\end{array}
Derivation
  1. Initial program 35.2%

    \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
  2. Step-by-step derivation
    1. *-commutative35.2%

      \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
    2. exp-lft-sqr35.4%

      \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
    3. difference-of-sqr-136.3%

      \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
    4. associate-*r/36.3%

      \[\leadsto \sqrt{\color{blue}{\left(e^{x} + 1\right) \cdot \frac{e^{x} - 1}{e^{x} - 1}}} \]
    5. *-inverses99.6%

      \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
    6. *-rgt-identity99.6%

      \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
    7. +-commutative99.6%

      \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
  3. Simplified99.6%

    \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. +-commutative99.6%

      \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
    2. flip-+35.4%

      \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
    3. metadata-eval35.4%

      \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
    4. exp-lft-sqr35.2%

      \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
    5. *-commutative35.2%

      \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
    6. expm1-undefine35.5%

      \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
    7. expm1-undefine99.6%

      \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
    8. add-log-exp99.6%

      \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
    9. *-un-lft-identity99.6%

      \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
    10. log-prod99.6%

      \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
    11. metadata-eval99.6%

      \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
    12. add-log-exp99.6%

      \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
    13. expm1-undefine36.6%

      \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
    14. *-commutative36.6%

      \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
    15. exp-lft-sqr36.5%

      \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
    16. metadata-eval36.5%

      \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
    17. expm1-undefine35.4%

      \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
  6. Applied egg-rr99.6%

    \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
  7. Step-by-step derivation
    1. +-lft-identity99.6%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    2. metadata-eval99.6%

      \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
    3. rem-square-sqrt99.6%

      \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
    4. hypot-undefine99.6%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
  8. Simplified99.6%

    \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
  9. Step-by-step derivation
    1. pow1/299.6%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{{\left(e^{x}\right)}^{0.5}}\right) \]
    2. pow-exp100.0%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{e^{x \cdot 0.5}}\right) \]
  10. Applied egg-rr100.0%

    \[\leadsto \mathsf{hypot}\left(1, \color{blue}{e^{x \cdot 0.5}}\right) \]
  11. Add Preprocessing

Alternative 2: 100.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \sqrt{1 + e^{x}} \end{array} \]
(FPCore (x) :precision binary64 (sqrt (+ 1.0 (exp x))))
double code(double x) {
	return sqrt((1.0 + exp(x)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt((1.0d0 + exp(x)))
end function
public static double code(double x) {
	return Math.sqrt((1.0 + Math.exp(x)));
}
def code(x):
	return math.sqrt((1.0 + math.exp(x)))
function code(x)
	return sqrt(Float64(1.0 + exp(x)))
end
function tmp = code(x)
	tmp = sqrt((1.0 + exp(x)));
end
code[x_] := N[Sqrt[N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{1 + e^{x}}
\end{array}
Derivation
  1. Initial program 35.2%

    \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
  2. Step-by-step derivation
    1. *-commutative35.2%

      \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
    2. exp-lft-sqr35.4%

      \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
    3. difference-of-sqr-136.3%

      \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
    4. associate-*r/36.3%

      \[\leadsto \sqrt{\color{blue}{\left(e^{x} + 1\right) \cdot \frac{e^{x} - 1}{e^{x} - 1}}} \]
    5. *-inverses99.6%

      \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
    6. *-rgt-identity99.6%

      \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
    7. +-commutative99.6%

      \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
  3. Simplified99.6%

    \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 3: 98.8% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.7:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{hypot}\left(1, 1 + x \cdot \left(0.5 + x \cdot \left(0.125 + x \cdot 0.020833333333333332\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -3.7)
   1.0
   (hypot
    1.0
    (+ 1.0 (* x (+ 0.5 (* x (+ 0.125 (* x 0.020833333333333332)))))))))
double code(double x) {
	double tmp;
	if (x <= -3.7) {
		tmp = 1.0;
	} else {
		tmp = hypot(1.0, (1.0 + (x * (0.5 + (x * (0.125 + (x * 0.020833333333333332)))))));
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= -3.7) {
		tmp = 1.0;
	} else {
		tmp = Math.hypot(1.0, (1.0 + (x * (0.5 + (x * (0.125 + (x * 0.020833333333333332)))))));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -3.7:
		tmp = 1.0
	else:
		tmp = math.hypot(1.0, (1.0 + (x * (0.5 + (x * (0.125 + (x * 0.020833333333333332)))))))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -3.7)
		tmp = 1.0;
	else
		tmp = hypot(1.0, Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * Float64(0.125 + Float64(x * 0.020833333333333332)))))));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -3.7)
		tmp = 1.0;
	else
		tmp = hypot(1.0, (1.0 + (x * (0.5 + (x * (0.125 + (x * 0.020833333333333332)))))));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -3.7], 1.0, N[Sqrt[1.0 ^ 2 + N[(1.0 + N[(x * N[(0.5 + N[(x * N[(0.125 + N[(x * 0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.7:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(1, 1 + x \cdot \left(0.5 + x \cdot \left(0.125 + x \cdot 0.020833333333333332\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.7000000000000002

    1. Initial program 100.0%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-1100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/100.0%

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

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      2. flip-+100.0%

        \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
      4. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
      5. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
      6. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
      7. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
      8. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      9. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      10. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
      12. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
      13. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
      14. *-commutative100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      15. exp-lft-sqr100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      16. metadata-eval100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
      17. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
    7. Step-by-step derivation
      1. +-lft-identity100.0%

        \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
      3. rem-square-sqrt100.0%

        \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
      4. hypot-undefine100.0%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    8. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    9. Taylor expanded in x around 0 5.2%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + 0.5 \cdot x}\right) \]
    10. Taylor expanded in x around inf 1.1%

      \[\leadsto \color{blue}{x \cdot \left(0.5 + \frac{1}{x}\right)} \]
    11. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{1} \]

    if -3.7000000000000002 < x

    1. Initial program 6.2%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative6.2%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr6.6%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-17.9%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/7.9%

        \[\leadsto \sqrt{\color{blue}{\left(e^{x} + 1\right) \cdot \frac{e^{x} - 1}{e^{x} - 1}}} \]
      5. *-inverses99.4%

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity99.4%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative99.4%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. +-commutative99.4%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      2. flip-+6.6%

        \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
      3. metadata-eval6.6%

        \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
      4. exp-lft-sqr6.2%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
      5. *-commutative6.2%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
      6. expm1-undefine6.7%

        \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
      7. expm1-undefine99.4%

        \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
      8. add-log-exp99.4%

        \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      9. *-un-lft-identity99.4%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      10. log-prod99.4%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      11. metadata-eval99.4%

        \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
      12. add-log-exp99.4%

        \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
      13. expm1-undefine8.2%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
      14. *-commutative8.2%

        \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      15. exp-lft-sqr8.2%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      16. metadata-eval8.2%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
      17. expm1-undefine6.6%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
    6. Applied egg-rr99.4%

      \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
    7. Step-by-step derivation
      1. +-lft-identity99.4%

        \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
      2. metadata-eval99.4%

        \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
      3. rem-square-sqrt99.5%

        \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
      4. hypot-undefine99.5%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    8. Simplified99.5%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    9. Taylor expanded in x around 0 98.7%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + x \cdot \left(0.5 + x \cdot \left(0.125 + 0.020833333333333332 \cdot x\right)\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutative98.7%

        \[\leadsto \mathsf{hypot}\left(1, 1 + x \cdot \left(0.5 + x \cdot \left(0.125 + \color{blue}{x \cdot 0.020833333333333332}\right)\right)\right) \]
    11. Simplified98.7%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + x \cdot \left(0.5 + x \cdot \left(0.125 + x \cdot 0.020833333333333332\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 98.7% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.6:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2 + x \cdot \left(1 + x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -1.6)
   1.0
   (sqrt (+ 2.0 (* x (+ 1.0 (* x (+ 0.5 (* x 0.16666666666666666)))))))))
double code(double x) {
	double tmp;
	if (x <= -1.6) {
		tmp = 1.0;
	} else {
		tmp = sqrt((2.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))))));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-1.6d0)) then
        tmp = 1.0d0
    else
        tmp = sqrt((2.0d0 + (x * (1.0d0 + (x * (0.5d0 + (x * 0.16666666666666666d0)))))))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -1.6) {
		tmp = 1.0;
	} else {
		tmp = Math.sqrt((2.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))))));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -1.6:
		tmp = 1.0
	else:
		tmp = math.sqrt((2.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))))))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -1.6)
		tmp = 1.0;
	else
		tmp = sqrt(Float64(2.0 + Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * 0.16666666666666666)))))));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -1.6)
		tmp = 1.0;
	else
		tmp = sqrt((2.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))))));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -1.6], 1.0, N[Sqrt[N[(2.0 + N[(x * N[(1.0 + N[(x * N[(0.5 + N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.6000000000000001

    1. Initial program 100.0%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-1100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/100.0%

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

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      2. flip-+100.0%

        \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
      4. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
      5. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
      6. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
      7. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
      8. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      9. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      10. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
      12. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
      13. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
      14. *-commutative100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      15. exp-lft-sqr100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      16. metadata-eval100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
      17. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
    7. Step-by-step derivation
      1. +-lft-identity100.0%

        \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
      3. rem-square-sqrt100.0%

        \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
      4. hypot-undefine100.0%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    8. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    9. Taylor expanded in x around 0 5.2%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + 0.5 \cdot x}\right) \]
    10. Taylor expanded in x around inf 1.1%

      \[\leadsto \color{blue}{x \cdot \left(0.5 + \frac{1}{x}\right)} \]
    11. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{1} \]

    if -1.6000000000000001 < x

    1. Initial program 6.2%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative6.2%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr6.6%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-17.9%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/7.9%

        \[\leadsto \sqrt{\color{blue}{\left(e^{x} + 1\right) \cdot \frac{e^{x} - 1}{e^{x} - 1}}} \]
      5. *-inverses99.4%

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity99.4%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative99.4%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 98.5%

      \[\leadsto \sqrt{\color{blue}{2 + x \cdot \left(1 + x \cdot \left(0.5 + 0.16666666666666666 \cdot x\right)\right)}} \]
    6. Step-by-step derivation
      1. *-commutative98.5%

        \[\leadsto \sqrt{2 + x \cdot \left(1 + x \cdot \left(0.5 + \color{blue}{x \cdot 0.16666666666666666}\right)\right)} \]
    7. Simplified98.5%

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

Alternative 5: 98.6% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.1:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{hypot}\left(1, 1 + x \cdot \left(0.5 + x \cdot 0.125\right)\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2.1) 1.0 (hypot 1.0 (+ 1.0 (* x (+ 0.5 (* x 0.125)))))))
double code(double x) {
	double tmp;
	if (x <= -2.1) {
		tmp = 1.0;
	} else {
		tmp = hypot(1.0, (1.0 + (x * (0.5 + (x * 0.125)))));
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= -2.1) {
		tmp = 1.0;
	} else {
		tmp = Math.hypot(1.0, (1.0 + (x * (0.5 + (x * 0.125)))));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2.1:
		tmp = 1.0
	else:
		tmp = math.hypot(1.0, (1.0 + (x * (0.5 + (x * 0.125)))))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2.1)
		tmp = 1.0;
	else
		tmp = hypot(1.0, Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * 0.125)))));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2.1)
		tmp = 1.0;
	else
		tmp = hypot(1.0, (1.0 + (x * (0.5 + (x * 0.125)))));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2.1], 1.0, N[Sqrt[1.0 ^ 2 + N[(1.0 + N[(x * N[(0.5 + N[(x * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(1, 1 + x \cdot \left(0.5 + x \cdot 0.125\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.10000000000000009

    1. Initial program 100.0%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-1100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/100.0%

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

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      2. flip-+100.0%

        \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
      4. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
      5. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
      6. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
      7. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
      8. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      9. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      10. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
      12. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
      13. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
      14. *-commutative100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      15. exp-lft-sqr100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      16. metadata-eval100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
      17. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
    7. Step-by-step derivation
      1. +-lft-identity100.0%

        \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
      3. rem-square-sqrt100.0%

        \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
      4. hypot-undefine100.0%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    8. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    9. Taylor expanded in x around 0 5.2%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + 0.5 \cdot x}\right) \]
    10. Taylor expanded in x around inf 1.1%

      \[\leadsto \color{blue}{x \cdot \left(0.5 + \frac{1}{x}\right)} \]
    11. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{1} \]

    if -2.10000000000000009 < x

    1. Initial program 6.2%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative6.2%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr6.6%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-17.9%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/7.9%

        \[\leadsto \sqrt{\color{blue}{\left(e^{x} + 1\right) \cdot \frac{e^{x} - 1}{e^{x} - 1}}} \]
      5. *-inverses99.4%

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity99.4%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative99.4%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. +-commutative99.4%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      2. flip-+6.6%

        \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
      3. metadata-eval6.6%

        \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
      4. exp-lft-sqr6.2%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
      5. *-commutative6.2%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
      6. expm1-undefine6.7%

        \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
      7. expm1-undefine99.4%

        \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
      8. add-log-exp99.4%

        \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      9. *-un-lft-identity99.4%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      10. log-prod99.4%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      11. metadata-eval99.4%

        \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
      12. add-log-exp99.4%

        \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
      13. expm1-undefine8.2%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
      14. *-commutative8.2%

        \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      15. exp-lft-sqr8.2%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      16. metadata-eval8.2%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
      17. expm1-undefine6.6%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
    6. Applied egg-rr99.4%

      \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
    7. Step-by-step derivation
      1. +-lft-identity99.4%

        \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
      2. metadata-eval99.4%

        \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
      3. rem-square-sqrt99.5%

        \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
      4. hypot-undefine99.5%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    8. Simplified99.5%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    9. Taylor expanded in x around 0 98.3%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + x \cdot \left(0.5 + 0.125 \cdot x\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutative98.3%

        \[\leadsto \mathsf{hypot}\left(1, 1 + x \cdot \left(0.5 + \color{blue}{x \cdot 0.125}\right)\right) \]
    11. Simplified98.3%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + x \cdot \left(0.5 + x \cdot 0.125\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 98.6% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.3:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2 + x \cdot \left(1 + x \cdot 0.5\right)}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -1.3) 1.0 (sqrt (+ 2.0 (* x (+ 1.0 (* x 0.5)))))))
double code(double x) {
	double tmp;
	if (x <= -1.3) {
		tmp = 1.0;
	} else {
		tmp = sqrt((2.0 + (x * (1.0 + (x * 0.5)))));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-1.3d0)) then
        tmp = 1.0d0
    else
        tmp = sqrt((2.0d0 + (x * (1.0d0 + (x * 0.5d0)))))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -1.3) {
		tmp = 1.0;
	} else {
		tmp = Math.sqrt((2.0 + (x * (1.0 + (x * 0.5)))));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -1.3:
		tmp = 1.0
	else:
		tmp = math.sqrt((2.0 + (x * (1.0 + (x * 0.5)))))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -1.3)
		tmp = 1.0;
	else
		tmp = sqrt(Float64(2.0 + Float64(x * Float64(1.0 + Float64(x * 0.5)))));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -1.3)
		tmp = 1.0;
	else
		tmp = sqrt((2.0 + (x * (1.0 + (x * 0.5)))));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -1.3], 1.0, N[Sqrt[N[(2.0 + N[(x * N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.30000000000000004

    1. Initial program 100.0%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-1100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/100.0%

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

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      2. flip-+100.0%

        \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
      4. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
      5. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
      6. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
      7. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
      8. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      9. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      10. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
      12. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
      13. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
      14. *-commutative100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      15. exp-lft-sqr100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      16. metadata-eval100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
      17. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
    7. Step-by-step derivation
      1. +-lft-identity100.0%

        \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
      3. rem-square-sqrt100.0%

        \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
      4. hypot-undefine100.0%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    8. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    9. Taylor expanded in x around 0 5.2%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + 0.5 \cdot x}\right) \]
    10. Taylor expanded in x around inf 1.1%

      \[\leadsto \color{blue}{x \cdot \left(0.5 + \frac{1}{x}\right)} \]
    11. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{1} \]

    if -1.30000000000000004 < x

    1. Initial program 6.2%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative6.2%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr6.6%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-17.9%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/7.9%

        \[\leadsto \sqrt{\color{blue}{\left(e^{x} + 1\right) \cdot \frac{e^{x} - 1}{e^{x} - 1}}} \]
      5. *-inverses99.4%

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity99.4%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative99.4%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 98.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.3:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2 + x \cdot \left(1 + x \cdot 0.5\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 98.3% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.7:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{hypot}\left(1, 1 + x \cdot 0.5\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2.7) 1.0 (hypot 1.0 (+ 1.0 (* x 0.5)))))
double code(double x) {
	double tmp;
	if (x <= -2.7) {
		tmp = 1.0;
	} else {
		tmp = hypot(1.0, (1.0 + (x * 0.5)));
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= -2.7) {
		tmp = 1.0;
	} else {
		tmp = Math.hypot(1.0, (1.0 + (x * 0.5)));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2.7:
		tmp = 1.0
	else:
		tmp = math.hypot(1.0, (1.0 + (x * 0.5)))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2.7)
		tmp = 1.0;
	else
		tmp = hypot(1.0, Float64(1.0 + Float64(x * 0.5)));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2.7)
		tmp = 1.0;
	else
		tmp = hypot(1.0, (1.0 + (x * 0.5)));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2.7], 1.0, N[Sqrt[1.0 ^ 2 + N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(1, 1 + x \cdot 0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.7000000000000002

    1. Initial program 100.0%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-1100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/100.0%

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

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      2. flip-+100.0%

        \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
      4. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
      5. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
      6. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
      7. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
      8. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      9. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      10. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
      12. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
      13. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
      14. *-commutative100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      15. exp-lft-sqr100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      16. metadata-eval100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
      17. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
    7. Step-by-step derivation
      1. +-lft-identity100.0%

        \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
      3. rem-square-sqrt100.0%

        \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
      4. hypot-undefine100.0%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    8. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    9. Taylor expanded in x around 0 5.2%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + 0.5 \cdot x}\right) \]
    10. Taylor expanded in x around inf 1.1%

      \[\leadsto \color{blue}{x \cdot \left(0.5 + \frac{1}{x}\right)} \]
    11. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{1} \]

    if -2.7000000000000002 < x

    1. Initial program 6.2%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative6.2%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr6.6%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-17.9%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/7.9%

        \[\leadsto \sqrt{\color{blue}{\left(e^{x} + 1\right) \cdot \frac{e^{x} - 1}{e^{x} - 1}}} \]
      5. *-inverses99.4%

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity99.4%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative99.4%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. +-commutative99.4%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      2. flip-+6.6%

        \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
      3. metadata-eval6.6%

        \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
      4. exp-lft-sqr6.2%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
      5. *-commutative6.2%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
      6. expm1-undefine6.7%

        \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
      7. expm1-undefine99.4%

        \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
      8. add-log-exp99.4%

        \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      9. *-un-lft-identity99.4%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      10. log-prod99.4%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      11. metadata-eval99.4%

        \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
      12. add-log-exp99.4%

        \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
      13. expm1-undefine8.2%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
      14. *-commutative8.2%

        \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      15. exp-lft-sqr8.2%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      16. metadata-eval8.2%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
      17. expm1-undefine6.6%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
    6. Applied egg-rr99.4%

      \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
    7. Step-by-step derivation
      1. +-lft-identity99.4%

        \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
      2. metadata-eval99.4%

        \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
      3. rem-square-sqrt99.5%

        \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
      4. hypot-undefine99.5%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    8. Simplified99.5%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    9. Taylor expanded in x around 0 97.8%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + 0.5 \cdot x}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.7:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{hypot}\left(1, 1 + x \cdot 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 98.3% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x + 2}\\ \end{array} \end{array} \]
(FPCore (x) :precision binary64 (if (<= x -1.0) 1.0 (sqrt (+ x 2.0))))
double code(double x) {
	double tmp;
	if (x <= -1.0) {
		tmp = 1.0;
	} else {
		tmp = sqrt((x + 2.0));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-1.0d0)) then
        tmp = 1.0d0
    else
        tmp = sqrt((x + 2.0d0))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -1.0) {
		tmp = 1.0;
	} else {
		tmp = Math.sqrt((x + 2.0));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -1.0:
		tmp = 1.0
	else:
		tmp = math.sqrt((x + 2.0))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -1.0)
		tmp = 1.0;
	else
		tmp = sqrt(Float64(x + 2.0));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -1.0)
		tmp = 1.0;
	else
		tmp = sqrt((x + 2.0));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -1.0], 1.0, N[Sqrt[N[(x + 2.0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;\sqrt{x + 2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1

    1. Initial program 100.0%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-1100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/100.0%

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

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      2. flip-+100.0%

        \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
      4. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
      5. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
      6. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
      7. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
      8. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      9. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      10. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
      12. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
      13. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
      14. *-commutative100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      15. exp-lft-sqr100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      16. metadata-eval100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
      17. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
    7. Step-by-step derivation
      1. +-lft-identity100.0%

        \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
      3. rem-square-sqrt100.0%

        \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
      4. hypot-undefine100.0%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    8. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    9. Taylor expanded in x around 0 5.2%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + 0.5 \cdot x}\right) \]
    10. Taylor expanded in x around inf 1.1%

      \[\leadsto \color{blue}{x \cdot \left(0.5 + \frac{1}{x}\right)} \]
    11. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{1} \]

    if -1 < x

    1. Initial program 6.2%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative6.2%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr6.6%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-17.9%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/7.9%

        \[\leadsto \sqrt{\color{blue}{\left(e^{x} + 1\right) \cdot \frac{e^{x} - 1}{e^{x} - 1}}} \]
      5. *-inverses99.4%

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity99.4%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative99.4%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 97.7%

      \[\leadsto \sqrt{\color{blue}{2 + x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x + 2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 97.6% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.78:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2}\\ \end{array} \end{array} \]
(FPCore (x) :precision binary64 (if (<= x -0.78) 1.0 (sqrt 2.0)))
double code(double x) {
	double tmp;
	if (x <= -0.78) {
		tmp = 1.0;
	} else {
		tmp = sqrt(2.0);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-0.78d0)) then
        tmp = 1.0d0
    else
        tmp = sqrt(2.0d0)
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -0.78) {
		tmp = 1.0;
	} else {
		tmp = Math.sqrt(2.0);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -0.78:
		tmp = 1.0
	else:
		tmp = math.sqrt(2.0)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -0.78)
		tmp = 1.0;
	else
		tmp = sqrt(2.0);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -0.78)
		tmp = 1.0;
	else
		tmp = sqrt(2.0);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -0.78], 1.0, N[Sqrt[2.0], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.78:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;\sqrt{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -0.78000000000000003

    1. Initial program 100.0%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-1100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/100.0%

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

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      2. flip-+100.0%

        \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
      3. metadata-eval100.0%

        \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
      4. exp-lft-sqr100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
      5. *-commutative100.0%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
      6. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
      7. expm1-undefine100.0%

        \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
      8. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      9. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      10. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
      11. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
      12. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
      13. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
      14. *-commutative100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      15. exp-lft-sqr100.0%

        \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
      16. metadata-eval100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
      17. expm1-undefine100.0%

        \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
    7. Step-by-step derivation
      1. +-lft-identity100.0%

        \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
      2. metadata-eval100.0%

        \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
      3. rem-square-sqrt100.0%

        \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
      4. hypot-undefine100.0%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    8. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
    9. Taylor expanded in x around 0 5.2%

      \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + 0.5 \cdot x}\right) \]
    10. Taylor expanded in x around inf 1.1%

      \[\leadsto \color{blue}{x \cdot \left(0.5 + \frac{1}{x}\right)} \]
    11. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{1} \]

    if -0.78000000000000003 < x

    1. Initial program 6.2%

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Step-by-step derivation
      1. *-commutative6.2%

        \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
      2. exp-lft-sqr6.6%

        \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
      3. difference-of-sqr-17.9%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
      4. associate-*r/7.9%

        \[\leadsto \sqrt{\color{blue}{\left(e^{x} + 1\right) \cdot \frac{e^{x} - 1}{e^{x} - 1}}} \]
      5. *-inverses99.4%

        \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
      6. *-rgt-identity99.4%

        \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
      7. +-commutative99.4%

        \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 96.2%

      \[\leadsto \color{blue}{\sqrt{2}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 46.0% accurate, 309.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (x) :precision binary64 1.0)
double code(double x) {
	return 1.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0
end function
public static double code(double x) {
	return 1.0;
}
def code(x):
	return 1.0
function code(x)
	return 1.0
end
function tmp = code(x)
	tmp = 1.0;
end
code[x_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 35.2%

    \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
  2. Step-by-step derivation
    1. *-commutative35.2%

      \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
    2. exp-lft-sqr35.4%

      \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
    3. difference-of-sqr-136.3%

      \[\leadsto \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}} \]
    4. associate-*r/36.3%

      \[\leadsto \sqrt{\color{blue}{\left(e^{x} + 1\right) \cdot \frac{e^{x} - 1}{e^{x} - 1}}} \]
    5. *-inverses99.6%

      \[\leadsto \sqrt{\left(e^{x} + 1\right) \cdot \color{blue}{1}} \]
    6. *-rgt-identity99.6%

      \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
    7. +-commutative99.6%

      \[\leadsto \sqrt{\color{blue}{1 + e^{x}}} \]
  3. Simplified99.6%

    \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. +-commutative99.6%

      \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
    2. flip-+35.4%

      \[\leadsto \sqrt{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}}} \]
    3. metadata-eval35.4%

      \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}} \]
    4. exp-lft-sqr35.2%

      \[\leadsto \sqrt{\frac{\color{blue}{e^{x \cdot 2}} - 1}{e^{x} - 1}} \]
    5. *-commutative35.2%

      \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
    6. expm1-undefine35.5%

      \[\leadsto \sqrt{\frac{\color{blue}{\mathsf{expm1}\left(2 \cdot x\right)}}{e^{x} - 1}} \]
    7. expm1-undefine99.6%

      \[\leadsto \sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}} \]
    8. add-log-exp99.6%

      \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
    9. *-un-lft-identity99.6%

      \[\leadsto \log \color{blue}{\left(1 \cdot e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
    10. log-prod99.6%

      \[\leadsto \color{blue}{\log 1 + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right)} \]
    11. metadata-eval99.6%

      \[\leadsto \color{blue}{0} + \log \left(e^{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}}\right) \]
    12. add-log-exp99.6%

      \[\leadsto 0 + \color{blue}{\sqrt{\frac{\mathsf{expm1}\left(2 \cdot x\right)}{\mathsf{expm1}\left(x\right)}}} \]
    13. expm1-undefine36.6%

      \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{\mathsf{expm1}\left(x\right)}} \]
    14. *-commutative36.6%

      \[\leadsto 0 + \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{\mathsf{expm1}\left(x\right)}} \]
    15. exp-lft-sqr36.5%

      \[\leadsto 0 + \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}} \]
    16. metadata-eval36.5%

      \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}} \]
    17. expm1-undefine35.4%

      \[\leadsto 0 + \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
  6. Applied egg-rr99.6%

    \[\leadsto \color{blue}{0 + \sqrt{1 + e^{x}}} \]
  7. Step-by-step derivation
    1. +-lft-identity99.6%

      \[\leadsto \color{blue}{\sqrt{1 + e^{x}}} \]
    2. metadata-eval99.6%

      \[\leadsto \sqrt{\color{blue}{1 \cdot 1} + e^{x}} \]
    3. rem-square-sqrt99.6%

      \[\leadsto \sqrt{1 \cdot 1 + \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}} \]
    4. hypot-undefine99.6%

      \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
  8. Simplified99.6%

    \[\leadsto \color{blue}{\mathsf{hypot}\left(1, \sqrt{e^{x}}\right)} \]
  9. Taylor expanded in x around 0 69.2%

    \[\leadsto \mathsf{hypot}\left(1, \color{blue}{1 + 0.5 \cdot x}\right) \]
  10. Taylor expanded in x around inf 14.6%

    \[\leadsto \color{blue}{x \cdot \left(0.5 + \frac{1}{x}\right)} \]
  11. Taylor expanded in x around 0 45.1%

    \[\leadsto \color{blue}{1} \]
  12. Add Preprocessing

Reproduce

?
herbie shell --seed 2024087 
(FPCore (x)
  :name "sqrtexp (problem 3.4.4)"
  :precision binary64
  (sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0))))