Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.4%
Time: 13.8s
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.7× speedup?

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

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

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-/r/99.6%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\sqrt{k}}{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(0.5 + \left(-k \cdot \color{blue}{0.5}\right)\right)}}} \]
    10. distribute-rgt-neg-in99.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{\sqrt{k} \cdot {\left(n \cdot \left(\pi \cdot 2\right)\right)}^{\left(-\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}} \]
  7. Add Preprocessing

Alternative 2: 99.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

    if 1.0199999999999999e-45 < k

    1. Initial program 99.7%

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

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

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

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

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

Alternative 3: 53.9% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(8 \cdot {\left(n \cdot \frac{\pi}{k}\right)}^{3}\right)}^{0.16666666666666666}\\


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

    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. Add Preprocessing
    3. Taylor expanded in k around 0 50.9%

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

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

      \[\leadsto \color{blue}{\sqrt{n \cdot \frac{\pi}{k}} \cdot \sqrt{2}} \]
    6. Step-by-step derivation
      1. sqrt-unprod51.0%

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

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

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

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

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

    if 4.49999999999999973e155 < k

    1. Initial program 100.0%

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

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

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

      \[\leadsto \color{blue}{\sqrt{n \cdot \frac{\pi}{k}} \cdot \sqrt{2}} \]
    6. Step-by-step derivation
      1. sqrt-unprod2.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left({\color{blue}{\left(2 \cdot \left(\pi \cdot \frac{n}{k}\right)\right)}}^{3}\right)}^{0.16666666666666666} \]
      7. cube-prod34.4%

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

        \[\leadsto {\left(\color{blue}{8} \cdot {\left(\pi \cdot \frac{n}{k}\right)}^{3}\right)}^{0.16666666666666666} \]
      9. associate-*r/34.4%

        \[\leadsto {\left(8 \cdot {\color{blue}{\left(\frac{\pi \cdot n}{k}\right)}}^{3}\right)}^{0.16666666666666666} \]
      10. associate-*l/34.4%

        \[\leadsto {\left(8 \cdot {\color{blue}{\left(\frac{\pi}{k} \cdot n\right)}}^{3}\right)}^{0.16666666666666666} \]
      11. *-commutative34.4%

        \[\leadsto {\left(8 \cdot {\color{blue}{\left(n \cdot \frac{\pi}{k}\right)}}^{3}\right)}^{0.16666666666666666} \]
    12. Simplified34.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 4.5 \cdot 10^{+155}:\\ \;\;\;\;\sqrt{n} \cdot \sqrt{2 \cdot \frac{\pi}{k}}\\ \mathbf{else}:\\ \;\;\;\;{\left(8 \cdot {\left(n \cdot \frac{\pi}{k}\right)}^{3}\right)}^{0.16666666666666666}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 50.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := 2 \cdot \frac{\pi}{k}\\
\mathbf{if}\;k \leq 6.2 \cdot 10^{+255}:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(n \cdot t\_0\right)}^{1.5}}\\


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

    if 6.2000000000000004e255 < k

    1. Initial program 100.0%

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

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

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

      \[\leadsto \color{blue}{\sqrt{n \cdot \frac{\pi}{k}} \cdot \sqrt{2}} \]
    6. Step-by-step derivation
      1. sqrt-unprod2.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 99.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 6: 49.4% accurate, 1.0× speedup?

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{n \cdot \frac{\pi}{k}} \cdot \sqrt{2}} \]
  6. Step-by-step derivation
    1. sqrt-unprod37.3%

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

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

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

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

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

    \[\leadsto \sqrt{n} \cdot \sqrt{2 \cdot \frac{\pi}{k}} \]
  11. Add Preprocessing

Alternative 7: 38.1% accurate, 2.0× speedup?

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

\\
\sqrt{\left(\pi \cdot 2\right) \cdot \frac{n}{k}}
\end{array}
Derivation
  1. Initial program 99.6%

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

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

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

    \[\leadsto \color{blue}{\sqrt{n \cdot \frac{\pi}{k}} \cdot \sqrt{2}} \]
  6. Step-by-step derivation
    1. sqrt-unprod37.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\left({\left(n \cdot \left(\frac{\pi}{k} \cdot 2\right)\right)}^{1.5}\right)}^{0.3333333333333333}} \]
  10. Step-by-step derivation
    1. pow-pow37.3%

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \pi}{k} \cdot 2}} \]
    6. *-un-lft-identity37.3%

      \[\leadsto \color{blue}{1 \cdot \sqrt{\frac{n \cdot \pi}{k} \cdot 2}} \]
    7. *-commutative37.3%

      \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \pi}{k} \cdot 2} \cdot 1} \]
    8. associate-/l*37.3%

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

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

      \[\leadsto \sqrt{n \cdot \color{blue}{\frac{\pi \cdot 2}{k}}} \cdot 1 \]
    11. associate-/l*37.3%

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\frac{\pi \cdot 2}{k}} \cdot n} \]
    4. associate-*l/37.3%

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

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

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

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

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

Alternative 8: 38.1% accurate, 2.0× speedup?

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{n \cdot \frac{\pi}{k}} \cdot \sqrt{2}} \]
  6. Step-by-step derivation
    1. sqrt-unprod37.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\left({\left(n \cdot \left(\frac{\pi}{k} \cdot 2\right)\right)}^{1.5}\right)}^{0.3333333333333333}} \]
  10. Step-by-step derivation
    1. pow-pow37.3%

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \pi}{k} \cdot 2}} \]
    6. *-un-lft-identity37.3%

      \[\leadsto \color{blue}{1 \cdot \sqrt{\frac{n \cdot \pi}{k} \cdot 2}} \]
    7. *-commutative37.3%

      \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \pi}{k} \cdot 2} \cdot 1} \]
    8. associate-/l*37.3%

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

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

      \[\leadsto \sqrt{n \cdot \color{blue}{\frac{\pi \cdot 2}{k}}} \cdot 1 \]
    11. associate-/l*37.3%

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\frac{\pi \cdot 2}{k}} \cdot n} \]
    4. associate-*l/37.3%

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\pi \cdot \frac{n \cdot 2}{k}}} \]
  14. Add Preprocessing

Alternative 9: 38.0% accurate, 2.0× speedup?

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

\\
\sqrt{n \cdot \left(\pi \cdot \frac{2}{k}\right)}
\end{array}
Derivation
  1. Initial program 99.6%

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

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

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

    \[\leadsto \color{blue}{\sqrt{n \cdot \frac{\pi}{k}} \cdot \sqrt{2}} \]
  6. Step-by-step derivation
    1. sqrt-unprod37.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\left({\left(n \cdot \left(\frac{\pi}{k} \cdot 2\right)\right)}^{1.5}\right)}^{0.3333333333333333}} \]
  10. Step-by-step derivation
    1. pow-pow37.3%

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

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

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

      \[\leadsto \sqrt{n \cdot \color{blue}{\frac{\pi \cdot 2}{k}}} \]
    5. associate-/l*37.3%

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

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

Reproduce

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