Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.3%
Time: 20.9s
Alternatives: 9
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 9 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.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.8 \cdot 10^{-22}:\\
\;\;\;\;\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}\\

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


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

    1. Initial program 99.1%

      \[\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.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{2 \cdot \color{blue}{\frac{n}{\frac{k}{\pi}}}} \]
    6. Simplified69.2%

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

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

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

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

    if 3.80000000000000023e-22 < k

    1. Initial program 99.9%

      \[\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.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\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 3.8 \cdot 10^{-22}:\\ \;\;\;\;\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\\ \end{array} \]

Alternative 2: 99.4% accurate, 0.6× speedup?

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

\\
{k}^{-0.5} \cdot {\left(\left(2 \cdot \sqrt[3]{{\pi}^{3}}\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\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. expm1-log1p-u96.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.5% accurate, 1.0× speedup?

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

\\
{k}^{-0.5} \cdot {\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(\frac{1 - k}{2}\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. expm1-log1p-u96.5%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.5% accurate, 1.0× speedup?

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

\\
\frac{{\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(0.5 - \frac{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.6%

      \[\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.6%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 49.2% accurate, 1.0× speedup?

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

\\
\frac{\sqrt{2 \cdot n}}{\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. div-sub99.6%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}} \]
  8. Applied egg-rr45.3%

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

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

Alternative 6: 38.7% accurate, 1.5× speedup?

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

\\
\frac{1}{\sqrt{\frac{k}{n \cdot \left(2 \cdot \pi\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. Taylor expanded in k around 0 45.1%

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

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

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

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

    \[\leadsto \frac{1}{\sqrt{k}} \cdot \color{blue}{\sqrt{2 \cdot \left(\pi \cdot n\right)}} \]
  5. Step-by-step derivation
    1. add-sqr-sqrt44.9%

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

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

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

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

      \[\leadsto \sqrt{\frac{1}{\color{blue}{k}}} \cdot \sqrt{2 \cdot \left(\pi \cdot n\right)} \]
  6. Applied egg-rr44.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 38.7% accurate, 1.5× speedup?

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

\\
\frac{1}{\sqrt{\frac{\frac{\frac{k}{n}}{\pi}}{2}}}
\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 45.1%

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

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

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

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

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

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

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

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

    \[\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-def42.3%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sqrt{n \cdot \left(\pi \cdot 2\right)}}{\sqrt{k}}} \]
  7. Step-by-step derivation
    1. clear-num45.2%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{\color{blue}{\frac{\frac{\frac{k}{n}}{\pi}}{2}}}} \]
  10. Simplified33.4%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\frac{\frac{\frac{k}{n}}{\pi}}{2}}}} \]
  11. Final simplification33.4%

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

Alternative 8: 38.1% 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. div-sub99.6%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 38.1% 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. div-sub99.6%

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

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

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

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

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

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

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

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

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

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

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

Reproduce

?
herbie shell --seed 2023287 
(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))))