Migdal et al, Equation (51)

Percentage Accurate: 99.5% → 99.2%
Time: 12.9s
Alternatives: 11
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 11 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.5% 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.2% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 3.7e-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 67.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{n} \cdot \sqrt{2 \cdot \color{blue}{\frac{1}{\frac{k}{\pi}}}} \]
      3. un-div-inv99.5%

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

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

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

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

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

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

    if 3.7e-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. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(2 \cdot \left(0.5 + k \cdot -0.5\right)\right)}}{k}}} \]
    4. Step-by-step derivation
      1. distribute-rgt-in99.8%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 58.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;k \leq 1.35 \cdot 10^{+25}:\\ \;\;\;\;\sqrt{n} \cdot \sqrt{2 \cdot \frac{\pi}{k}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + \mathsf{fma}\left(\pi, n \cdot \frac{2}{k}, -1\right)}\\ \end{array} \end{array} \]
(FPCore (k n)
 :precision binary64
 (if (<= k 1.35e+25)
   (* (sqrt n) (sqrt (* 2.0 (/ PI k))))
   (sqrt (+ 1.0 (fma PI (* n (/ 2.0 k)) -1.0)))))
double code(double k, double n) {
	double tmp;
	if (k <= 1.35e+25) {
		tmp = sqrt(n) * sqrt((2.0 * (((double) M_PI) / k)));
	} else {
		tmp = sqrt((1.0 + fma(((double) M_PI), (n * (2.0 / k)), -1.0)));
	}
	return tmp;
}
function code(k, n)
	tmp = 0.0
	if (k <= 1.35e+25)
		tmp = Float64(sqrt(n) * sqrt(Float64(2.0 * Float64(pi / k))));
	else
		tmp = sqrt(Float64(1.0 + fma(pi, Float64(n * Float64(2.0 / k)), -1.0)));
	end
	return tmp
end
code[k_, n_] := If[LessEqual[k, 1.35e+25], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(1.0 + N[(Pi * N[(n * N[(2.0 / k), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 99.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 64.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35e25 < 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 1.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{e^{\color{blue}{\log \left(1 + \frac{n}{k} \cdot \left(\pi \cdot 2\right)\right)}} - 1} \]
      2. rem-exp-log41.0%

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

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

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

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

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

        \[\leadsto \sqrt{1 + \color{blue}{\mathsf{fma}\left(\pi, \frac{2 \cdot n}{k}, -1\right)}} \]
      8. *-commutative41.0%

        \[\leadsto \sqrt{1 + \mathsf{fma}\left(\pi, \frac{\color{blue}{n \cdot 2}}{k}, -1\right)} \]
      9. associate-/l*41.0%

        \[\leadsto \sqrt{1 + \mathsf{fma}\left(\pi, \color{blue}{n \cdot \frac{2}{k}}, -1\right)} \]
      10. metadata-eval41.0%

        \[\leadsto \sqrt{1 + \mathsf{fma}\left(\pi, n \cdot \frac{2}{k}, \color{blue}{-1}\right)} \]
    16. Simplified41.0%

      \[\leadsto \sqrt{\color{blue}{1 + \mathsf{fma}\left(\pi, n \cdot \frac{2}{k}, -1\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 99.5% accurate, 1.0× speedup?

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

\\
{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(0.5 + k \cdot -0.5\right)} \cdot {k}^{-0.5}
\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. Step-by-step derivation
    1. metadata-eval99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(0.5 + k \cdot -0.5\right)} \cdot {k}^{-0.5}} \]
  7. Add Preprocessing

Alternative 4: 99.5% accurate, 1.0× speedup?

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

Alternative 5: 40.1% 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 28.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{n} \cdot \sqrt{2 \cdot \color{blue}{\frac{1}{\frac{k}{\pi}}}} \]
    3. un-div-inv39.5%

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

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

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

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

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

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

Alternative 6: 30.7% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sqrt{\color{blue}{2 \cdot \left(\pi \cdot \frac{n}{k}\right)}} \]
  13. Step-by-step derivation
    1. pow129.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\left|\color{blue}{n \cdot \frac{\pi \cdot 2}{k}}\right|} \]
    12. associate-/l*29.6%

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

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

Alternative 7: 30.6% accurate, 2.0× speedup?

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

\\
\frac{1}{\sqrt{\frac{k}{\pi \cdot \left(2 \cdot n\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. Applied egg-rr89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 30.6% accurate, 2.0× speedup?

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

\\
\frac{1}{\sqrt{k \cdot \frac{\frac{0.5}{n}}{\pi}}}
\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. Applied egg-rr89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{\color{blue}{\frac{0.5 \cdot k}{n \cdot \pi}}}} \]
    2. *-commutative29.6%

      \[\leadsto \frac{1}{\sqrt{\frac{\color{blue}{k \cdot 0.5}}{n \cdot \pi}}} \]
    3. associate-*r/29.5%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{k \cdot \frac{0.5}{n \cdot \pi}}}} \]
    4. associate-/r*29.6%

      \[\leadsto \frac{1}{\sqrt{k \cdot \color{blue}{\frac{\frac{0.5}{n}}{\pi}}}} \]
  10. Simplified29.6%

    \[\leadsto \frac{1}{\sqrt{\color{blue}{k \cdot \frac{\frac{0.5}{n}}{\pi}}}} \]
  11. Add Preprocessing

Alternative 9: 30.1% accurate, 2.0× speedup?

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

\\
\sqrt{\frac{2 \cdot n}{\frac{k}{\pi}}}
\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 28.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 30.1% 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 28.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 30.1% accurate, 2.0× speedup?

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

\\
\sqrt{2 \cdot \left(\pi \cdot \frac{n}{k}\right)}
\end{array}
Derivation
  1. Initial program 99.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 28.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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