Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.4%
Time: 16.0s
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.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

      \[\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 74.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}} \]
    11. Step-by-step derivation
      1. *-commutative99.4%

        \[\leadsto \frac{\sqrt{\color{blue}{n \cdot 2}}}{\sqrt{\frac{k}{\pi}}} \]
    12. Simplified99.4%

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

    if 4.7999999999999999e-47 < k

    1. Initial program 99.7%

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

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

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

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

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

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

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

      \[\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.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-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}}} \]
    6. Step-by-step derivation
      1. div-inv99.8%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.2%

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

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

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

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

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

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

        \[\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-rr52.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-def73.0%

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

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

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

      \[\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 76.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}} \]
    11. Step-by-step derivation
      1. *-commutative99.4%

        \[\leadsto \frac{\sqrt{\color{blue}{n \cdot 2}}}{\sqrt{\frac{k}{\pi}}} \]
    12. Simplified99.4%

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

    if 5.4999999999999999e-24 < 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. expm1-log1p-u99.7%

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

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

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

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

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

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

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

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

      \[\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. metadata-eval99.8%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{\left(e^{\log \left(2 \cdot \left(\pi \cdot n\right)\right)}\right)}^{\left(\frac{1 - k}{2}\right)}}}{\sqrt{k}} \]
      8. add-exp-log99.8%

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

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

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

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

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

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

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

Alternative 4: 99.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;k \leq 2 \cdot 10^{-24}:\\ \;\;\;\;\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(1 - k\right)}}{k}}\\ \end{array} \end{array} \]
(FPCore (k n)
 :precision binary64
 (if (<= k 2e-24)
   (/ (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 <= 2e-24) {
		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 <= 2e-24) {
		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 <= 2e-24:
		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 <= 2e-24)
		tmp = Float64(sqrt(Float64(2.0 * n)) / sqrt(Float64(k / pi)));
	else
		tmp = sqrt(Float64((Float64(Float64(2.0 * pi) * n) ^ Float64(1.0 - k)) / k));
	end
	return tmp
end
function tmp_2 = code(k, n)
	tmp = 0.0;
	if (k <= 2e-24)
		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, 2e-24], N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(k / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 99.2%

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

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

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

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

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

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

        \[\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-rr52.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-def73.0%

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

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

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

      \[\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 76.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}} \]
    11. Step-by-step derivation
      1. *-commutative99.4%

        \[\leadsto \frac{\sqrt{\color{blue}{n \cdot 2}}}{\sqrt{\frac{k}{\pi}}} \]
    12. Simplified99.4%

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

    if 1.99999999999999985e-24 < 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.8%

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

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

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

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

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

Alternative 5: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}} \end{array} \]
(FPCore (k n)
 :precision binary64
 (/ (pow (* PI (* 2.0 n)) (/ (- 1.0 k) 2.0)) (sqrt k)))
double code(double k, double n) {
	return pow((((double) M_PI) * (2.0 * n)), ((1.0 - k) / 2.0)) / sqrt(k);
}
public static double code(double k, double n) {
	return Math.pow((Math.PI * (2.0 * n)), ((1.0 - k) / 2.0)) / Math.sqrt(k);
}
def code(k, n):
	return math.pow((math.pi * (2.0 * n)), ((1.0 - k) / 2.0)) / math.sqrt(k)
function code(k, n)
	return Float64((Float64(pi * Float64(2.0 * n)) ^ Float64(Float64(1.0 - k) / 2.0)) / sqrt(k))
end
function tmp = code(k, n)
	tmp = ((pi * (2.0 * n)) ^ ((1.0 - k) / 2.0)) / sqrt(k);
end
code[k_, n_] := N[(N[Power[N[(Pi * N[(2.0 * n), $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(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}
\end{array}
Derivation
  1. Initial program 99.5%

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

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

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

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

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

Alternative 6: 51.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.1 \cdot 10^{+232}:\\
\;\;\;\;\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(2 \cdot \frac{\pi}{\frac{k}{n}}\right)}^{1.5}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 2.09999999999999991e232

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\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 44.7%

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{n \cdot 2}}}{\sqrt{\frac{k}{\pi}}} \]
    12. Simplified56.7%

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

    if 2.09999999999999991e232 < k

    1. Initial program 100.0%

      \[\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. *-commutative100.0%

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

        \[\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*100.0%

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

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

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

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

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

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

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

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

      \[\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 3.1%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt[3]{\left(\sqrt{2 \cdot \left(\frac{n}{k} \cdot \pi\right)} \cdot \sqrt{2 \cdot \left(\frac{n}{k} \cdot \pi\right)}\right) \cdot \sqrt{2 \cdot \left(\frac{n}{k} \cdot \pi\right)}}} \]
      2. pow1/327.8%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{2 \cdot \left(\frac{n}{k} \cdot \pi\right)} \cdot \sqrt{2 \cdot \left(\frac{n}{k} \cdot \pi\right)}\right) \cdot \sqrt{2 \cdot \left(\frac{n}{k} \cdot \pi\right)}\right)}^{0.3333333333333333}} \]
      3. add-sqr-sqrt27.8%

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

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

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

        \[\leadsto {\color{blue}{\left({\left(2 \cdot \left(\frac{n}{k} \cdot \pi\right)\right)}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333} \]
      7. *-commutative27.8%

        \[\leadsto {\left({\left(2 \cdot \color{blue}{\left(\pi \cdot \frac{n}{k}\right)}\right)}^{\left(1 + 0.5\right)}\right)}^{0.3333333333333333} \]
      8. metadata-eval27.8%

        \[\leadsto {\left({\left(2 \cdot \left(\pi \cdot \frac{n}{k}\right)\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333} \]
    10. Applied egg-rr27.8%

      \[\leadsto \color{blue}{{\left({\left(2 \cdot \left(\pi \cdot \frac{n}{k}\right)\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    11. Step-by-step derivation
      1. unpow1/327.8%

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

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

        \[\leadsto \sqrt[3]{{\left(2 \cdot \color{blue}{\frac{\pi}{\frac{k}{n}}}\right)}^{1.5}} \]
    12. Simplified27.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 2.1 \cdot 10^{+232}:\\ \;\;\;\;\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{\left(2 \cdot \frac{\pi}{\frac{k}{n}}\right)}^{1.5}}\\ \end{array} \]

Alternative 7: 50.4% 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.5%

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

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

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

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

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

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

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

      \[\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 39.7%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}} \]
  11. Step-by-step derivation
    1. *-commutative50.2%

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

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

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

Alternative 8: 38.3% 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.5%

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

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

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

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

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

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

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

      \[\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 39.7%

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

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

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

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

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

Alternative 9: 38.3% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \sqrt{2 \cdot \frac{\pi \cdot n}{k}} \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(Float64(pi * 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[(N[(Pi * n), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

      \[\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 39.7%

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

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

Reproduce

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