Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.4%
Time: 13.2s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \end{array} \]
(FPCore (k n)
 :precision binary64
 (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
	return (1.0 / sqrt(k)) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
	return (1.0 / Math.sqrt(k)) * Math.pow(((2.0 * Math.PI) * n), ((1.0 - k) / 2.0));
}
def code(k, n):
	return (1.0 / math.sqrt(k)) * math.pow(((2.0 * math.pi) * n), ((1.0 - k) / 2.0))
function code(k, n)
	return Float64(Float64(1.0 / sqrt(k)) * (Float64(Float64(2.0 * pi) * n) ^ Float64(Float64(1.0 - k) / 2.0)))
end
function tmp = code(k, n)
	tmp = (1.0 / sqrt(k)) * (((2.0 * pi) * n) ^ ((1.0 - k) / 2.0));
end
code[k_, n_] := N[(N[(1.0 / N[Sqrt[k], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\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 8 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: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \end{array} \]
(FPCore (k n)
 :precision binary64
 (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
	return (1.0 / sqrt(k)) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
	return (1.0 / Math.sqrt(k)) * Math.pow(((2.0 * Math.PI) * n), ((1.0 - k) / 2.0));
}
def code(k, n):
	return (1.0 / math.sqrt(k)) * math.pow(((2.0 * math.pi) * n), ((1.0 - k) / 2.0))
function code(k, n)
	return Float64(Float64(1.0 / sqrt(k)) * (Float64(Float64(2.0 * pi) * n) ^ Float64(Float64(1.0 - k) / 2.0)))
end
function tmp = code(k, n)
	tmp = (1.0 / sqrt(k)) * (((2.0 * pi) * n) ^ ((1.0 - k) / 2.0));
end
code[k_, n_] := N[(N[(1.0 / N[Sqrt[k], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}

Alternative 1: 99.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := n \cdot \left(2 \cdot \pi\right)\\ \frac{\sqrt{t_0}}{\sqrt{k \cdot {t_0}^{k}}} \end{array} \end{array} \]
(FPCore (k n)
 :precision binary64
 (let* ((t_0 (* n (* 2.0 PI)))) (/ (sqrt t_0) (sqrt (* k (pow t_0 k))))))
double code(double k, double n) {
	double t_0 = n * (2.0 * ((double) M_PI));
	return sqrt(t_0) / sqrt((k * pow(t_0, k)));
}
public static double code(double k, double n) {
	double t_0 = n * (2.0 * Math.PI);
	return Math.sqrt(t_0) / Math.sqrt((k * Math.pow(t_0, k)));
}
def code(k, n):
	t_0 = n * (2.0 * math.pi)
	return math.sqrt(t_0) / math.sqrt((k * math.pow(t_0, k)))
function code(k, n)
	t_0 = Float64(n * Float64(2.0 * pi))
	return Float64(sqrt(t_0) / sqrt(Float64(k * (t_0 ^ k))))
end
function tmp = code(k, n)
	t_0 = n * (2.0 * pi);
	tmp = sqrt(t_0) / sqrt((k * (t_0 ^ k)));
end
code[k_, n_] := Block[{t$95$0 = N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(k * N[Power[t$95$0, k], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := n \cdot \left(2 \cdot \pi\right)\\
\frac{\sqrt{t_0}}{\sqrt{k \cdot {t_0}^{k}}}
\end{array}
\end{array}
Derivation
  1. Initial program 99.6%

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. Step-by-step derivation
    1. div-sub99.6%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\color{blue}{\left(\frac{1}{2} - \frac{k}{2}\right)}} \]
    2. metadata-eval99.6%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\color{blue}{0.5} - \frac{k}{2}\right)} \]
    3. pow-sub99.7%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot \color{blue}{\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{0.5}}{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}}} \]
    4. pow1/299.7%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot \frac{\color{blue}{\sqrt{\left(2 \cdot \pi\right) \cdot n}}}{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}} \]
    5. associate-*l*99.7%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot \frac{\sqrt{\color{blue}{2 \cdot \left(\pi \cdot n\right)}}}{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}} \]
    6. associate-*l*99.7%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot \frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{{\color{blue}{\left(2 \cdot \left(\pi \cdot n\right)\right)}}^{\left(\frac{k}{2}\right)}} \]
    7. div-inv99.7%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot \frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\color{blue}{\left(k \cdot \frac{1}{2}\right)}}} \]
    8. metadata-eval99.7%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot \frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(k \cdot \color{blue}{0.5}\right)}} \]
  3. Applied egg-rr99.7%

    \[\leadsto \frac{1}{\sqrt{k}} \cdot \color{blue}{\frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(k \cdot 0.5\right)}}} \]
  4. Step-by-step derivation
    1. associate-*r*99.7%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot \frac{\sqrt{\color{blue}{\left(2 \cdot \pi\right) \cdot n}}}{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(k \cdot 0.5\right)}} \]
    2. associate-*r*99.7%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot \frac{\sqrt{\left(2 \cdot \pi\right) \cdot n}}{{\color{blue}{\left(\left(2 \cdot \pi\right) \cdot n\right)}}^{\left(k \cdot 0.5\right)}} \]
  5. Simplified99.7%

    \[\leadsto \frac{1}{\sqrt{k}} \cdot \color{blue}{\frac{\sqrt{\left(2 \cdot \pi\right) \cdot n}}{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(k \cdot 0.5\right)}}} \]
  6. Step-by-step derivation
    1. frac-times99.8%

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{\left(2 \cdot \pi\right) \cdot n}}{\sqrt{k} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(k \cdot 0.5\right)}}} \]
    2. *-un-lft-identity99.8%

      \[\leadsto \frac{\color{blue}{\sqrt{\left(2 \cdot \pi\right) \cdot n}}}{\sqrt{k} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(k \cdot 0.5\right)}} \]
    3. associate-*r*99.8%

      \[\leadsto \frac{\sqrt{\color{blue}{2 \cdot \left(\pi \cdot n\right)}}}{\sqrt{k} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(k \cdot 0.5\right)}} \]
    4. pow1/299.8%

      \[\leadsto \frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{\color{blue}{{k}^{0.5}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(k \cdot 0.5\right)}} \]
    5. pow-unpow99.8%

      \[\leadsto \frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{{k}^{0.5} \cdot \color{blue}{{\left({\left(\left(2 \cdot \pi\right) \cdot n\right)}^{k}\right)}^{0.5}}} \]
    6. pow-prod-down99.8%

      \[\leadsto \frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{\color{blue}{{\left(k \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{k}\right)}^{0.5}}} \]
    7. associate-*r*99.8%

      \[\leadsto \frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{{\left(k \cdot {\color{blue}{\left(2 \cdot \left(\pi \cdot n\right)\right)}}^{k}\right)}^{0.5}} \]
  7. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{{\left(k \cdot {\left(2 \cdot \left(\pi \cdot n\right)\right)}^{k}\right)}^{0.5}}} \]
  8. Step-by-step derivation
    1. *-commutative99.8%

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\pi \cdot n\right) \cdot 2}}}{{\left(k \cdot {\left(2 \cdot \left(\pi \cdot n\right)\right)}^{k}\right)}^{0.5}} \]
    2. *-commutative99.8%

      \[\leadsto \frac{\sqrt{\color{blue}{\left(n \cdot \pi\right)} \cdot 2}}{{\left(k \cdot {\left(2 \cdot \left(\pi \cdot n\right)\right)}^{k}\right)}^{0.5}} \]
    3. associate-*l*99.8%

      \[\leadsto \frac{\sqrt{\color{blue}{n \cdot \left(\pi \cdot 2\right)}}}{{\left(k \cdot {\left(2 \cdot \left(\pi \cdot n\right)\right)}^{k}\right)}^{0.5}} \]
    4. *-commutative99.8%

      \[\leadsto \frac{\sqrt{n \cdot \color{blue}{\left(2 \cdot \pi\right)}}}{{\left(k \cdot {\left(2 \cdot \left(\pi \cdot n\right)\right)}^{k}\right)}^{0.5}} \]
    5. unpow1/299.8%

      \[\leadsto \frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\color{blue}{\sqrt{k \cdot {\left(2 \cdot \left(\pi \cdot n\right)\right)}^{k}}}} \]
    6. *-commutative99.8%

      \[\leadsto \frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k \cdot {\color{blue}{\left(\left(\pi \cdot n\right) \cdot 2\right)}}^{k}}} \]
    7. *-commutative99.8%

      \[\leadsto \frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k \cdot {\left(\color{blue}{\left(n \cdot \pi\right)} \cdot 2\right)}^{k}}} \]
    8. associate-*l*99.8%

      \[\leadsto \frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k \cdot {\color{blue}{\left(n \cdot \left(\pi \cdot 2\right)\right)}}^{k}}} \]
    9. *-commutative99.8%

      \[\leadsto \frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k \cdot {\left(n \cdot \color{blue}{\left(2 \cdot \pi\right)}\right)}^{k}}} \]
  9. Simplified99.8%

    \[\leadsto \color{blue}{\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k \cdot {\left(n \cdot \left(2 \cdot \pi\right)\right)}^{k}}}} \]
  10. Final simplification99.8%

    \[\leadsto \frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k \cdot {\left(n \cdot \left(2 \cdot \pi\right)\right)}^{k}}} \]

Alternative 2: 99.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;k \leq 2.3 \cdot 10^{-40}:\\ \;\;\;\;\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\left(1 - k\right)} \cdot \frac{1}{k}}\\ \end{array} \end{array} \]
(FPCore (k n)
 :precision binary64
 (if (<= k 2.3e-40)
   (/ (sqrt (* n (* 2.0 PI))) (sqrt k))
   (sqrt (* (pow (* 2.0 (* n PI)) (- 1.0 k)) (/ 1.0 k)))))
double code(double k, double n) {
	double tmp;
	if (k <= 2.3e-40) {
		tmp = sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
	} else {
		tmp = sqrt((pow((2.0 * (n * ((double) M_PI))), (1.0 - k)) * (1.0 / k)));
	}
	return tmp;
}
public static double code(double k, double n) {
	double tmp;
	if (k <= 2.3e-40) {
		tmp = Math.sqrt((n * (2.0 * Math.PI))) / Math.sqrt(k);
	} else {
		tmp = Math.sqrt((Math.pow((2.0 * (n * Math.PI)), (1.0 - k)) * (1.0 / k)));
	}
	return tmp;
}
def code(k, n):
	tmp = 0
	if k <= 2.3e-40:
		tmp = math.sqrt((n * (2.0 * math.pi))) / math.sqrt(k)
	else:
		tmp = math.sqrt((math.pow((2.0 * (n * math.pi)), (1.0 - k)) * (1.0 / k)))
	return tmp
function code(k, n)
	tmp = 0.0
	if (k <= 2.3e-40)
		tmp = Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k));
	else
		tmp = sqrt(Float64((Float64(2.0 * Float64(n * pi)) ^ Float64(1.0 - k)) * Float64(1.0 / k)));
	end
	return tmp
end
function tmp_2 = code(k, n)
	tmp = 0.0;
	if (k <= 2.3e-40)
		tmp = sqrt((n * (2.0 * pi))) / sqrt(k);
	else
		tmp = sqrt((((2.0 * (n * pi)) ^ (1.0 - k)) * (1.0 / k)));
	end
	tmp_2 = tmp;
end
code[k_, n_] := If[LessEqual[k, 2.3e-40], N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(2.0 * N[(n * Pi), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] * N[(1.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.3 \cdot 10^{-40}:\\
\;\;\;\;\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\left(1 - k\right)} \cdot \frac{1}{k}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 2.3e-40

    1. Initial program 99.3%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. Taylor expanded in k around 0 99.1%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot \color{blue}{\left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)} \]
    3. Step-by-step derivation
      1. expm1-log1p-u93.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{k}} \cdot \left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)\right)\right)} \]
      2. expm1-udef73.2%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{\sqrt{k}} \cdot \left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)\right)} - 1} \]
      3. associate-*l/73.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{1 \cdot \left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)}{\sqrt{k}}}\right)} - 1 \]
      4. *-un-lft-identity73.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{2} \cdot \sqrt{n \cdot \pi}}}{\sqrt{k}}\right)} - 1 \]
      5. sqrt-unprod73.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{2 \cdot \left(n \cdot \pi\right)}}}{\sqrt{k}}\right)} - 1 \]
      6. *-commutative73.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{2 \cdot \color{blue}{\left(\pi \cdot n\right)}}}{\sqrt{k}}\right)} - 1 \]
    4. Applied egg-rr73.2%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{\sqrt{k}}\right)} - 1} \]
    5. Step-by-step derivation
      1. expm1-def93.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{\sqrt{k}}\right)\right)} \]
      2. expm1-log1p99.5%

        \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{\sqrt{k}}} \]
      3. *-commutative99.5%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(\pi \cdot n\right) \cdot 2}}}{\sqrt{k}} \]
      4. *-commutative99.5%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(n \cdot \pi\right)} \cdot 2}}{\sqrt{k}} \]
      5. associate-*l*99.5%

        \[\leadsto \frac{\sqrt{\color{blue}{n \cdot \left(\pi \cdot 2\right)}}}{\sqrt{k}} \]
      6. *-commutative99.5%

        \[\leadsto \frac{\sqrt{n \cdot \color{blue}{\left(2 \cdot \pi\right)}}}{\sqrt{k}} \]
    6. Simplified99.5%

      \[\leadsto \color{blue}{\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}} \]

    if 2.3e-40 < k

    1. Initial program 99.8%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. Step-by-step derivation
      1. *-commutative99.8%

        \[\leadsto \color{blue}{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}}} \]
      2. *-commutative99.8%

        \[\leadsto {\left(\color{blue}{\left(\pi \cdot 2\right)} \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \]
      3. associate-*r*99.8%

        \[\leadsto {\color{blue}{\left(\pi \cdot \left(2 \cdot n\right)\right)}}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \]
      4. div-inv99.9%

        \[\leadsto \color{blue}{\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}} \]
      5. expm1-log1p-u99.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}\right)\right)} \]
      6. expm1-udef95.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}\right)} - 1} \]
    3. Applied egg-rr95.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def99.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\right)\right)} \]
      2. expm1-log1p99.9%

        \[\leadsto \color{blue}{\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}} \]
      3. associate-*r*99.9%

        \[\leadsto \sqrt{\frac{{\color{blue}{\left(\left(2 \cdot \pi\right) \cdot n\right)}}^{\left(1 - k\right)}}{k}} \]
    5. Simplified99.9%

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(1 - k\right)}}{k}}} \]
    6. Step-by-step derivation
      1. associate-*r*99.9%

        \[\leadsto \sqrt{\frac{{\color{blue}{\left(2 \cdot \left(\pi \cdot n\right)\right)}}^{\left(1 - k\right)}}{k}} \]
      2. div-inv99.9%

        \[\leadsto \sqrt{\color{blue}{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)} \cdot \frac{1}{k}}} \]
    7. Applied egg-rr99.9%

      \[\leadsto \sqrt{\color{blue}{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)} \cdot \frac{1}{k}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 2.3 \cdot 10^{-40}:\\ \;\;\;\;\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\left(1 - k\right)} \cdot \frac{1}{k}}\\ \end{array} \]

Alternative 3: 99.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := n \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;k \leq 5.1 \cdot 10^{-46}:\\ \;\;\;\;\frac{\sqrt{t_0}}{\sqrt{k}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{{t_0}^{\left(1 - k\right)}}{k}}\\ \end{array} \end{array} \]
(FPCore (k n)
 :precision binary64
 (let* ((t_0 (* n (* 2.0 PI))))
   (if (<= k 5.1e-46)
     (/ (sqrt t_0) (sqrt k))
     (sqrt (/ (pow t_0 (- 1.0 k)) k)))))
double code(double k, double n) {
	double t_0 = n * (2.0 * ((double) M_PI));
	double tmp;
	if (k <= 5.1e-46) {
		tmp = sqrt(t_0) / sqrt(k);
	} else {
		tmp = sqrt((pow(t_0, (1.0 - k)) / k));
	}
	return tmp;
}
public static double code(double k, double n) {
	double t_0 = n * (2.0 * Math.PI);
	double tmp;
	if (k <= 5.1e-46) {
		tmp = Math.sqrt(t_0) / Math.sqrt(k);
	} else {
		tmp = Math.sqrt((Math.pow(t_0, (1.0 - k)) / k));
	}
	return tmp;
}
def code(k, n):
	t_0 = n * (2.0 * math.pi)
	tmp = 0
	if k <= 5.1e-46:
		tmp = math.sqrt(t_0) / math.sqrt(k)
	else:
		tmp = math.sqrt((math.pow(t_0, (1.0 - k)) / k))
	return tmp
function code(k, n)
	t_0 = Float64(n * Float64(2.0 * pi))
	tmp = 0.0
	if (k <= 5.1e-46)
		tmp = Float64(sqrt(t_0) / sqrt(k));
	else
		tmp = sqrt(Float64((t_0 ^ Float64(1.0 - k)) / k));
	end
	return tmp
end
function tmp_2 = code(k, n)
	t_0 = n * (2.0 * pi);
	tmp = 0.0;
	if (k <= 5.1e-46)
		tmp = sqrt(t_0) / sqrt(k);
	else
		tmp = sqrt(((t_0 ^ (1.0 - k)) / k));
	end
	tmp_2 = tmp;
end
code[k_, n_] := Block[{t$95$0 = N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k, 5.1e-46], N[(N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[t$95$0, N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := n \cdot \left(2 \cdot \pi\right)\\
\mathbf{if}\;k \leq 5.1 \cdot 10^{-46}:\\
\;\;\;\;\frac{\sqrt{t_0}}{\sqrt{k}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{t_0}^{\left(1 - k\right)}}{k}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 5.0999999999999997e-46

    1. Initial program 99.3%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. Taylor expanded in k around 0 99.1%

      \[\leadsto \frac{1}{\sqrt{k}} \cdot \color{blue}{\left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)} \]
    3. Step-by-step derivation
      1. expm1-log1p-u93.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{k}} \cdot \left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)\right)\right)} \]
      2. expm1-udef73.5%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{\sqrt{k}} \cdot \left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)\right)} - 1} \]
      3. associate-*l/73.5%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{1 \cdot \left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)}{\sqrt{k}}}\right)} - 1 \]
      4. *-un-lft-identity73.5%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{2} \cdot \sqrt{n \cdot \pi}}}{\sqrt{k}}\right)} - 1 \]
      5. sqrt-unprod73.5%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{2 \cdot \left(n \cdot \pi\right)}}}{\sqrt{k}}\right)} - 1 \]
      6. *-commutative73.5%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{2 \cdot \color{blue}{\left(\pi \cdot n\right)}}}{\sqrt{k}}\right)} - 1 \]
    4. Applied egg-rr73.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{\sqrt{k}}\right)} - 1} \]
    5. Step-by-step derivation
      1. expm1-def93.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{\sqrt{k}}\right)\right)} \]
      2. expm1-log1p99.5%

        \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{\sqrt{k}}} \]
      3. *-commutative99.5%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(\pi \cdot n\right) \cdot 2}}}{\sqrt{k}} \]
      4. *-commutative99.5%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(n \cdot \pi\right)} \cdot 2}}{\sqrt{k}} \]
      5. associate-*l*99.5%

        \[\leadsto \frac{\sqrt{\color{blue}{n \cdot \left(\pi \cdot 2\right)}}}{\sqrt{k}} \]
      6. *-commutative99.5%

        \[\leadsto \frac{\sqrt{n \cdot \color{blue}{\left(2 \cdot \pi\right)}}}{\sqrt{k}} \]
    6. Simplified99.5%

      \[\leadsto \color{blue}{\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}} \]

    if 5.0999999999999997e-46 < k

    1. Initial program 99.8%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. Step-by-step derivation
      1. *-commutative99.8%

        \[\leadsto \color{blue}{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}}} \]
      2. *-commutative99.8%

        \[\leadsto {\left(\color{blue}{\left(\pi \cdot 2\right)} \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \]
      3. associate-*r*99.8%

        \[\leadsto {\color{blue}{\left(\pi \cdot \left(2 \cdot n\right)\right)}}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \]
      4. div-inv99.9%

        \[\leadsto \color{blue}{\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}} \]
      5. expm1-log1p-u99.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}\right)\right)} \]
      6. expm1-udef95.1%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}\right)} - 1} \]
    3. Applied egg-rr95.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def99.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\right)\right)} \]
      2. expm1-log1p99.8%

        \[\leadsto \color{blue}{\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}} \]
      3. associate-*r*99.8%

        \[\leadsto \sqrt{\frac{{\color{blue}{\left(\left(2 \cdot \pi\right) \cdot n\right)}}^{\left(1 - k\right)}}{k}} \]
    5. Simplified99.8%

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(1 - k\right)}}{k}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 5.1 \cdot 10^{-46}:\\ \;\;\;\;\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{{\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(1 - k\right)}}{k}}\\ \end{array} \]

Alternative 4: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}} \end{array} \]
(FPCore (k n)
 :precision binary64
 (/ (pow (* PI (* n 2.0)) (/ (- 1.0 k) 2.0)) (sqrt k)))
double code(double k, double n) {
	return pow((((double) M_PI) * (n * 2.0)), ((1.0 - k) / 2.0)) / sqrt(k);
}
public static double code(double k, double n) {
	return Math.pow((Math.PI * (n * 2.0)), ((1.0 - k) / 2.0)) / Math.sqrt(k);
}
def code(k, n):
	return math.pow((math.pi * (n * 2.0)), ((1.0 - k) / 2.0)) / math.sqrt(k)
function code(k, n)
	return Float64((Float64(pi * Float64(n * 2.0)) ^ Float64(Float64(1.0 - k) / 2.0)) / sqrt(k))
end
function tmp = code(k, n)
	tmp = ((pi * (n * 2.0)) ^ ((1.0 - k) / 2.0)) / sqrt(k);
end
code[k_, n_] := N[(N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}
\end{array}
Derivation
  1. Initial program 99.6%

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. Step-by-step derivation
    1. associate-*l/99.7%

      \[\leadsto \color{blue}{\frac{1 \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}} \]
    2. *-lft-identity99.7%

      \[\leadsto \frac{\color{blue}{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}}}{\sqrt{k}} \]
    3. *-commutative99.7%

      \[\leadsto \frac{{\left(\color{blue}{\left(\pi \cdot 2\right)} \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}} \]
    4. associate-*l*99.7%

      \[\leadsto \frac{{\color{blue}{\left(\pi \cdot \left(2 \cdot n\right)\right)}}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}} \]
  3. Simplified99.7%

    \[\leadsto \color{blue}{\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}} \]
  4. Final simplification99.7%

    \[\leadsto \frac{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}} \]

Alternative 5: 49.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\sqrt{n \cdot 2}}{\sqrt{\frac{k}{\pi}}} \end{array} \]
(FPCore (k n) :precision binary64 (/ (sqrt (* n 2.0)) (sqrt (/ k PI))))
double code(double k, double n) {
	return sqrt((n * 2.0)) / sqrt((k / ((double) M_PI)));
}
public static double code(double k, double n) {
	return Math.sqrt((n * 2.0)) / Math.sqrt((k / Math.PI));
}
def code(k, n):
	return math.sqrt((n * 2.0)) / math.sqrt((k / math.pi))
function code(k, n)
	return Float64(sqrt(Float64(n * 2.0)) / sqrt(Float64(k / pi)))
end
function tmp = code(k, n)
	tmp = sqrt((n * 2.0)) / sqrt((k / pi));
end
code[k_, n_] := N[(N[Sqrt[N[(n * 2.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(k / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\sqrt{n \cdot 2}}{\sqrt{\frac{k}{\pi}}}
\end{array}
Derivation
  1. Initial program 99.6%

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. Step-by-step derivation
    1. *-commutative99.6%

      \[\leadsto \color{blue}{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}}} \]
    2. *-commutative99.6%

      \[\leadsto {\left(\color{blue}{\left(\pi \cdot 2\right)} \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \]
    3. associate-*r*99.6%

      \[\leadsto {\color{blue}{\left(\pi \cdot \left(2 \cdot n\right)\right)}}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \]
    4. div-inv99.7%

      \[\leadsto \color{blue}{\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}} \]
    5. expm1-log1p-u97.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}\right)\right)} \]
    6. expm1-udef85.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}\right)} - 1} \]
  3. Applied egg-rr76.2%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\right)} - 1} \]
  4. Step-by-step derivation
    1. expm1-def87.5%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\right)\right)} \]
    2. expm1-log1p89.1%

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}} \]
    3. associate-*r*89.1%

      \[\leadsto \sqrt{\frac{{\color{blue}{\left(\left(2 \cdot \pi\right) \cdot n\right)}}^{\left(1 - k\right)}}{k}} \]
  5. Simplified89.1%

    \[\leadsto \color{blue}{\sqrt{\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(1 - k\right)}}{k}}} \]
  6. Taylor expanded in k around 0 37.9%

    \[\leadsto \sqrt{\color{blue}{2 \cdot \frac{n \cdot \pi}{k}}} \]
  7. Step-by-step derivation
    1. associate-/l*37.9%

      \[\leadsto \sqrt{2 \cdot \color{blue}{\frac{n}{\frac{k}{\pi}}}} \]
  8. Simplified37.9%

    \[\leadsto \sqrt{\color{blue}{2 \cdot \frac{n}{\frac{k}{\pi}}}} \]
  9. Step-by-step derivation
    1. associate-*r/37.9%

      \[\leadsto \sqrt{\color{blue}{\frac{2 \cdot n}{\frac{k}{\pi}}}} \]
    2. sqrt-div48.5%

      \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}} \]
  10. Applied egg-rr48.5%

    \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}} \]
  11. Final simplification48.5%

    \[\leadsto \frac{\sqrt{n \cdot 2}}{\sqrt{\frac{k}{\pi}}} \]

Alternative 6: 49.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}} \end{array} \]
(FPCore (k n) :precision binary64 (/ (sqrt (* n (* 2.0 PI))) (sqrt k)))
double code(double k, double n) {
	return sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
}
public static double code(double k, double n) {
	return Math.sqrt((n * (2.0 * Math.PI))) / Math.sqrt(k);
}
def code(k, n):
	return math.sqrt((n * (2.0 * math.pi))) / math.sqrt(k)
function code(k, n)
	return Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k))
end
function tmp = code(k, n)
	tmp = sqrt((n * (2.0 * pi))) / sqrt(k);
end
code[k_, n_] := N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}
\end{array}
Derivation
  1. Initial program 99.6%

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. Taylor expanded in k around 0 48.3%

    \[\leadsto \frac{1}{\sqrt{k}} \cdot \color{blue}{\left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)} \]
  3. Step-by-step derivation
    1. expm1-log1p-u45.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{k}} \cdot \left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)\right)\right)} \]
    2. expm1-udef45.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{\sqrt{k}} \cdot \left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)\right)} - 1} \]
    3. associate-*l/45.7%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{1 \cdot \left(\sqrt{2} \cdot \sqrt{n \cdot \pi}\right)}{\sqrt{k}}}\right)} - 1 \]
    4. *-un-lft-identity45.7%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{2} \cdot \sqrt{n \cdot \pi}}}{\sqrt{k}}\right)} - 1 \]
    5. sqrt-unprod45.7%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{2 \cdot \left(n \cdot \pi\right)}}}{\sqrt{k}}\right)} - 1 \]
    6. *-commutative45.7%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{2 \cdot \color{blue}{\left(\pi \cdot n\right)}}}{\sqrt{k}}\right)} - 1 \]
  4. Applied egg-rr45.7%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{\sqrt{k}}\right)} - 1} \]
  5. Step-by-step derivation
    1. expm1-def45.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{\sqrt{k}}\right)\right)} \]
    2. expm1-log1p48.5%

      \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot \left(\pi \cdot n\right)}}{\sqrt{k}}} \]
    3. *-commutative48.5%

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\pi \cdot n\right) \cdot 2}}}{\sqrt{k}} \]
    4. *-commutative48.5%

      \[\leadsto \frac{\sqrt{\color{blue}{\left(n \cdot \pi\right)} \cdot 2}}{\sqrt{k}} \]
    5. associate-*l*48.5%

      \[\leadsto \frac{\sqrt{\color{blue}{n \cdot \left(\pi \cdot 2\right)}}}{\sqrt{k}} \]
    6. *-commutative48.5%

      \[\leadsto \frac{\sqrt{n \cdot \color{blue}{\left(2 \cdot \pi\right)}}}{\sqrt{k}} \]
  6. Simplified48.5%

    \[\leadsto \color{blue}{\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}} \]
  7. Final simplification48.5%

    \[\leadsto \frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}} \]

Alternative 7: 38.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \sqrt{2 \cdot \left(\pi \cdot \frac{n}{k}\right)} \end{array} \]
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (* PI (/ n k)))))
double code(double k, double n) {
	return sqrt((2.0 * (((double) M_PI) * (n / k))));
}
public static double code(double k, double n) {
	return Math.sqrt((2.0 * (Math.PI * (n / k))));
}
def code(k, n):
	return math.sqrt((2.0 * (math.pi * (n / k))))
function code(k, n)
	return sqrt(Float64(2.0 * Float64(pi * Float64(n / k))))
end
function tmp = code(k, n)
	tmp = sqrt((2.0 * (pi * (n / k))));
end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(Pi * N[(n / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{2 \cdot \left(\pi \cdot \frac{n}{k}\right)}
\end{array}
Derivation
  1. Initial program 99.6%

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. Step-by-step derivation
    1. *-commutative99.6%

      \[\leadsto \color{blue}{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}}} \]
    2. *-commutative99.6%

      \[\leadsto {\left(\color{blue}{\left(\pi \cdot 2\right)} \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \]
    3. associate-*r*99.6%

      \[\leadsto {\color{blue}{\left(\pi \cdot \left(2 \cdot n\right)\right)}}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \]
    4. div-inv99.7%

      \[\leadsto \color{blue}{\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}} \]
    5. expm1-log1p-u97.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}\right)\right)} \]
    6. expm1-udef85.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}\right)} - 1} \]
  3. Applied egg-rr76.2%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\right)} - 1} \]
  4. Step-by-step derivation
    1. expm1-def87.5%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\right)\right)} \]
    2. expm1-log1p89.1%

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}} \]
    3. associate-*r*89.1%

      \[\leadsto \sqrt{\frac{{\color{blue}{\left(\left(2 \cdot \pi\right) \cdot n\right)}}^{\left(1 - k\right)}}{k}} \]
  5. Simplified89.1%

    \[\leadsto \color{blue}{\sqrt{\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(1 - k\right)}}{k}}} \]
  6. Taylor expanded in k around 0 37.9%

    \[\leadsto \sqrt{\color{blue}{2 \cdot \frac{n \cdot \pi}{k}}} \]
  7. Step-by-step derivation
    1. associate-/l*37.9%

      \[\leadsto \sqrt{2 \cdot \color{blue}{\frac{n}{\frac{k}{\pi}}}} \]
    2. associate-/r/37.9%

      \[\leadsto \sqrt{2 \cdot \color{blue}{\left(\frac{n}{k} \cdot \pi\right)}} \]
  8. Simplified37.9%

    \[\leadsto \sqrt{\color{blue}{2 \cdot \left(\frac{n}{k} \cdot \pi\right)}} \]
  9. Final simplification37.9%

    \[\leadsto \sqrt{2 \cdot \left(\pi \cdot \frac{n}{k}\right)} \]

Alternative 8: 38.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \sqrt{2 \cdot \frac{n}{\frac{k}{\pi}}} \end{array} \]
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (/ n (/ k PI)))))
double code(double k, double n) {
	return sqrt((2.0 * (n / (k / ((double) M_PI)))));
}
public static double code(double k, double n) {
	return Math.sqrt((2.0 * (n / (k / Math.PI))));
}
def code(k, n):
	return math.sqrt((2.0 * (n / (k / math.pi))))
function code(k, n)
	return sqrt(Float64(2.0 * Float64(n / Float64(k / pi))))
end
function tmp = code(k, n)
	tmp = sqrt((2.0 * (n / (k / pi))));
end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(n / N[(k / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{2 \cdot \frac{n}{\frac{k}{\pi}}}
\end{array}
Derivation
  1. Initial program 99.6%

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. Step-by-step derivation
    1. *-commutative99.6%

      \[\leadsto \color{blue}{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}}} \]
    2. *-commutative99.6%

      \[\leadsto {\left(\color{blue}{\left(\pi \cdot 2\right)} \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \]
    3. associate-*r*99.6%

      \[\leadsto {\color{blue}{\left(\pi \cdot \left(2 \cdot n\right)\right)}}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \]
    4. div-inv99.7%

      \[\leadsto \color{blue}{\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}} \]
    5. expm1-log1p-u97.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}\right)\right)} \]
    6. expm1-udef85.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}\right)} - 1} \]
  3. Applied egg-rr76.2%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\right)} - 1} \]
  4. Step-by-step derivation
    1. expm1-def87.5%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\right)\right)} \]
    2. expm1-log1p89.1%

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}} \]
    3. associate-*r*89.1%

      \[\leadsto \sqrt{\frac{{\color{blue}{\left(\left(2 \cdot \pi\right) \cdot n\right)}}^{\left(1 - k\right)}}{k}} \]
  5. Simplified89.1%

    \[\leadsto \color{blue}{\sqrt{\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(1 - k\right)}}{k}}} \]
  6. Taylor expanded in k around 0 37.9%

    \[\leadsto \sqrt{\color{blue}{2 \cdot \frac{n \cdot \pi}{k}}} \]
  7. Step-by-step derivation
    1. associate-/l*37.9%

      \[\leadsto \sqrt{2 \cdot \color{blue}{\frac{n}{\frac{k}{\pi}}}} \]
  8. Simplified37.9%

    \[\leadsto \sqrt{\color{blue}{2 \cdot \frac{n}{\frac{k}{\pi}}}} \]
  9. Final simplification37.9%

    \[\leadsto \sqrt{2 \cdot \frac{n}{\frac{k}{\pi}}} \]

Reproduce

?
herbie shell --seed 2023178 
(FPCore (k n)
  :name "Migdal et al, Equation (51)"
  :precision binary64
  (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))))