Average Error: 0.5 → 0.5
Time: 16.8s
Precision: binary64
Cost: 20036
\[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
\[\begin{array}{l} \mathbf{if}\;k \leq 2.628360817064176 \cdot 10^{-22}:\\ \;\;\;\;\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{\frac{k}{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(1 - k\right)}}}}\\ \end{array} \]
(FPCore (k n)
 :precision binary64
 (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))))
(FPCore (k n)
 :precision binary64
 (if (<= k 2.628360817064176e-22)
   (* (sqrt (* 2.0 (/ PI k))) (sqrt n))
   (/ 1.0 (sqrt (/ k (pow (* PI (* n 2.0)) (- 1.0 k)))))))
double code(double k, double n) {
	return (1.0 / sqrt(k)) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0));
}
double code(double k, double n) {
	double tmp;
	if (k <= 2.628360817064176e-22) {
		tmp = sqrt((2.0 * (((double) M_PI) / k))) * sqrt(n);
	} else {
		tmp = 1.0 / sqrt((k / pow((((double) M_PI) * (n * 2.0)), (1.0 - k))));
	}
	return tmp;
}
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));
}
public static double code(double k, double n) {
	double tmp;
	if (k <= 2.628360817064176e-22) {
		tmp = Math.sqrt((2.0 * (Math.PI / k))) * Math.sqrt(n);
	} else {
		tmp = 1.0 / Math.sqrt((k / Math.pow((Math.PI * (n * 2.0)), (1.0 - k))));
	}
	return tmp;
}
def code(k, n):
	return (1.0 / math.sqrt(k)) * math.pow(((2.0 * math.pi) * n), ((1.0 - k) / 2.0))
def code(k, n):
	tmp = 0
	if k <= 2.628360817064176e-22:
		tmp = math.sqrt((2.0 * (math.pi / k))) * math.sqrt(n)
	else:
		tmp = 1.0 / math.sqrt((k / math.pow((math.pi * (n * 2.0)), (1.0 - k))))
	return tmp
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 code(k, n)
	tmp = 0.0
	if (k <= 2.628360817064176e-22)
		tmp = Float64(sqrt(Float64(2.0 * Float64(pi / k))) * sqrt(n));
	else
		tmp = Float64(1.0 / sqrt(Float64(k / (Float64(pi * Float64(n * 2.0)) ^ Float64(1.0 - k)))));
	end
	return tmp
end
function tmp = code(k, n)
	tmp = (1.0 / sqrt(k)) * (((2.0 * pi) * n) ^ ((1.0 - k) / 2.0));
end
function tmp_2 = code(k, n)
	tmp = 0.0;
	if (k <= 2.628360817064176e-22)
		tmp = sqrt((2.0 * (pi / k))) * sqrt(n);
	else
		tmp = 1.0 / sqrt((k / ((pi * (n * 2.0)) ^ (1.0 - k))));
	end
	tmp_2 = tmp;
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]
code[k_, n_] := If[LessEqual[k, 2.628360817064176e-22], N[(N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sqrt[N[(k / N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\begin{array}{l}
\mathbf{if}\;k \leq 2.628360817064176 \cdot 10^{-22}:\\
\;\;\;\;\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if k < 2.6283608170641761e-22

    1. Initial program 0.5

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{2}{\frac{\frac{k}{\pi}}{n}}}} \]
    5. Applied egg-rr0.4

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

    if 2.6283608170641761e-22 < k

    1. Initial program 0.4

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. Applied egg-rr0.6

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

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

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

Alternatives

Alternative 1
Error0.4
Cost32896
\[\begin{array}{l} t_0 := n \cdot \left(2 \cdot \pi\right)\\ \frac{{t_0}^{\left(k \cdot -0.5\right)} \cdot \sqrt{t_0}}{\sqrt{k}} \end{array} \]
Alternative 2
Error0.6
Cost26624
\[\begin{array}{l} t_0 := 0.5 + k \cdot -0.5\\ \frac{{\left(2 \cdot \pi\right)}^{t_0}}{\frac{\sqrt{k}}{{n}^{t_0}}} \end{array} \]
Alternative 3
Error0.5
Cost26176
\[\frac{{\left(\sqrt{2 \cdot \left(n \cdot \pi\right)}\right)}^{\left(1 - k\right)}}{\sqrt{k}} \]
Alternative 4
Error0.5
Cost20036
\[\begin{array}{l} \mathbf{if}\;k \leq 2.628360817064176 \cdot 10^{-22}:\\ \;\;\;\;\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{{\left(\frac{\pi \cdot -2}{\frac{-1}{n}}\right)}^{\left(1 - k\right)}}{k}}\\ \end{array} \]
Alternative 5
Error0.5
Cost20032
\[\sqrt{\frac{1}{k}} \cdot {\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(\frac{1 - k}{2}\right)} \]
Alternative 6
Error0.4
Cost19972
\[\begin{array}{l} \mathbf{if}\;k \leq 2.628360817064176 \cdot 10^{-22}:\\ \;\;\;\;\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{k}{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\left(1 - k\right)}}\right)}^{-0.5}\\ \end{array} \]
Alternative 7
Error0.5
Cost19968
\[{\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(\frac{1 - k}{2}\right)} \cdot {k}^{-0.5} \]
Alternative 8
Error0.5
Cost19908
\[\begin{array}{l} \mathbf{if}\;k \leq 2.628360817064176 \cdot 10^{-22}:\\ \;\;\;\;\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\left(1 - k\right)}}{k}}\\ \end{array} \]
Alternative 9
Error18.4
Cost19844
\[\begin{array}{l} \mathbf{if}\;k \leq 2.5 \cdot 10^{+149}:\\ \;\;\;\;\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n}\\ \mathbf{else}:\\ \;\;\;\;{\left({\left(2 \cdot \left(n \cdot \frac{\pi}{k}\right)\right)}^{3}\right)}^{0.16666666666666666}\\ \end{array} \]
Alternative 10
Error22.2
Cost19584
\[\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n} \]
Alternative 11
Error31.9
Cost13248
\[{\left(0.5 \cdot \frac{k}{n \cdot \pi}\right)}^{-0.5} \]
Alternative 12
Error31.9
Cost13248
\[{\left(k \cdot \frac{\frac{0.5}{n}}{\pi}\right)}^{-0.5} \]
Alternative 13
Error32.6
Cost13184
\[\sqrt{2 \cdot \left(n \cdot \frac{\pi}{k}\right)} \]
Alternative 14
Error32.6
Cost13184
\[\sqrt{\left(n \cdot \pi\right) \cdot \frac{2}{k}} \]
Alternative 15
Error32.6
Cost13184
\[\sqrt{\frac{n}{\frac{k}{2 \cdot \pi}}} \]

Error

Reproduce

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