Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.5%
Time: 14.7s
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.5% accurate, 0.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.4% accurate, 0.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 98.6% accurate, 1.0× speedup?

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

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

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


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

    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. div-sub99.2%

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}\right)} - 1} \]
    3. Applied egg-rr55.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-def60.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left({\left(\frac{\pi \cdot \left(n \cdot 2\right)}{k}\right)}^{1} \cdot {\left(\frac{\pi \cdot \left(n \cdot 2\right)}{k}\right)}^{\color{blue}{\left(\sqrt{0.25}\right)}}\right)}^{0.3333333333333333} \]
      7. pow-prod-up42.5%

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

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

        \[\leadsto {\left({\left(\frac{\pi}{\frac{k}{\color{blue}{2 \cdot n}}}\right)}^{\left(1 + \sqrt{0.25}\right)}\right)}^{0.3333333333333333} \]
      10. metadata-eval42.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{\left({\left(\frac{\pi}{k} \cdot \left(n \cdot 2\right)\right)}^{1.5}\right)}^{0.3333333333333333}} \]
      2. pow-pow64.4%

        \[\leadsto \color{blue}{{\left(\frac{\pi}{k} \cdot \left(n \cdot 2\right)\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} \]
      3. metadata-eval64.4%

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

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

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

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

    if 9.99999999999999999e-79 < k

    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. expm1-log1p-u99.2%

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

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

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

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

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

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

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

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

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

Alternative 6: 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.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 49.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}\right)} - 1} \]
  3. Applied egg-rr78.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-def85.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-log1p87.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left({\left(\frac{\pi \cdot \left(n \cdot 2\right)}{k}\right)}^{1} \cdot {\left(\frac{\pi \cdot \left(n \cdot 2\right)}{k}\right)}^{\color{blue}{\left(\sqrt{0.25}\right)}}\right)}^{0.3333333333333333} \]
    7. pow-prod-up23.5%

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

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

      \[\leadsto {\left({\left(\frac{\pi}{\frac{k}{\color{blue}{2 \cdot n}}}\right)}^{\left(1 + \sqrt{0.25}\right)}\right)}^{0.3333333333333333} \]
    10. metadata-eval23.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left({\left(\frac{\pi}{k} \cdot \left(n \cdot 2\right)\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    2. pow-pow33.6%

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\frac{\pi}{k}} \cdot \sqrt{n \cdot 2}} \]
  15. Final simplification46.1%

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

Alternative 8: 39.3% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}\right)} - 1} \]
  3. Applied egg-rr78.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-def85.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-log1p87.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left({\left(\frac{\pi \cdot \left(n \cdot 2\right)}{k}\right)}^{1} \cdot {\left(\frac{\pi \cdot \left(n \cdot 2\right)}{k}\right)}^{\color{blue}{\left(\sqrt{0.25}\right)}}\right)}^{0.3333333333333333} \]
    7. pow-prod-up23.5%

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

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

      \[\leadsto {\left({\left(\frac{\pi}{\frac{k}{\color{blue}{2 \cdot n}}}\right)}^{\left(1 + \sqrt{0.25}\right)}\right)}^{0.3333333333333333} \]
    10. metadata-eval23.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left({\left(\frac{\pi}{k} \cdot \left(n \cdot 2\right)\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    2. pow-pow33.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 38.5% 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.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}\right)} - 1} \]
  3. Applied egg-rr78.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-def85.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-log1p87.1%

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{\frac{\color{blue}{\pi \cdot \left(n \cdot 2\right)}}{k}} \]
  9. Taylor expanded in n around 0 33.6%

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

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

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

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

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

Reproduce

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