Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.4%
Time: 12.4s
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, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \left(2 \cdot n\right) \cdot \pi\\
\frac{1}{\sqrt{k}} \cdot \frac{\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. 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)}} \]
    2. 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)} \]
    3. 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)}}} \]
    4. 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)}} \]
    5. associate-*l*99.6%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.4% accurate, 0.8× speedup?

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

\\
\frac{{k}^{-0.5}}{{\left({\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\left(1 - k\right)}\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 \frac{1}{\sqrt{k}} \cdot {\left(\color{blue}{\left(\pi \cdot 2\right)} \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. associate-*r*99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.5% accurate, 1.0× speedup?

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

\\
\sqrt{\frac{1}{k}} \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. add-sqr-sqrt99.3%

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

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

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

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

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

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

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

Alternative 4: 99.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ {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.2%

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

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

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

      \[\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: 99.2% accurate, 1.0× speedup?

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

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

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


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

    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. Taylor expanded in k around 0 99.0%

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

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

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

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

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

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

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

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

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

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

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

    if 2.3000000000000001e-48 < 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. *-commutative99.6%

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

        \[\leadsto {\color{blue}{\left(\pi \cdot \left(2 \cdot n\right)\right)}}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \]
      4. div-inv99.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-u99.3%

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

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

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

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

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

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

Alternative 6: 98.5% accurate, 1.0× speedup?

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

\\
\sqrt{\frac{\pi}{k}} \cdot {\left(2 \cdot n\right)}^{\left(0.5 - k \cdot 0.5\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. 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. *-un-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. *-commutative99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 99.5% accurate, 1.0× speedup?

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

\\
\frac{{\left(\left(2 \cdot n\right) \cdot \pi\right)}^{\left(\frac{1 - 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. *-commutative99.5%

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

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

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

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

Alternative 8: 50.6% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 39.4% accurate, 1.5× speedup?

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

\\
{\left(k \cdot \frac{\frac{0.5}{n}}{\pi}\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. 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)}} \]
    2. 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)} \]
    3. 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)}}} \]
    4. 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)}} \]
    5. associate-*l*99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(e^{\log k - \log \left(2 \cdot \color{blue}{\left(n \cdot \pi\right)}\right)}\right)}^{-0.5} \]
    6. sub-neg33.7%

      \[\leadsto {\left(e^{\color{blue}{\log k + \left(-\log \left(2 \cdot \left(n \cdot \pi\right)\right)\right)}}\right)}^{-0.5} \]
    7. exp-sum33.8%

      \[\leadsto {\color{blue}{\left(e^{\log k} \cdot e^{-\log \left(2 \cdot \left(n \cdot \pi\right)\right)}\right)}}^{-0.5} \]
    8. rem-exp-log34.2%

      \[\leadsto {\left(\color{blue}{k} \cdot e^{-\log \left(2 \cdot \left(n \cdot \pi\right)\right)}\right)}^{-0.5} \]
    9. rec-exp34.2%

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

      \[\leadsto {\left(k \cdot \frac{1}{e^{\log \left(2 \cdot \color{blue}{\left(\pi \cdot n\right)}\right)}}\right)}^{-0.5} \]
    11. rem-exp-log36.5%

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

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

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

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

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

    \[\leadsto \color{blue}{{\left(k \cdot \frac{\frac{0.5}{n}}{\pi}\right)}^{-0.5}} \]
  15. Final simplification36.5%

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

Reproduce

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