Migdal et al, Equation (51)

Percentage Accurate: 98.4% → 99.5%
Time: 15.2s
Alternatives: 13
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 13 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: 98.4% accurate, 1.0× speedup?

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

\\
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}

Alternative 1: 99.5% accurate, 0.7× speedup?

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

\\
{k}^{-0.5} \cdot {\left(\left|\pi \cdot \left(n \cdot 2\right)\right|\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Derivation
  1. Initial program 98.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. Step-by-step derivation
    1. associate-*r*98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \pi \cdot \left(n \cdot 2\right)\\
\mathbf{if}\;k \leq 2.4 \cdot 10^{-68}:\\
\;\;\;\;{k}^{-0.5} \cdot \sqrt{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{t\_0}^{\left(1 - k\right)}}{k}}\\


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

    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 64.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.39999999999999991e-68 < k

    1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 56.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;k \leq 9.6 \cdot 10^{+94}:\\
\;\;\;\;{k}^{-0.5} \cdot \sqrt{\pi \cdot \left(n \cdot 2\right)}\\

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


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

    1. Initial program 96.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 49.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.5999999999999993e94 < 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. Step-by-step derivation
      1. associate-*r*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{k}} \cdot {\color{blue}{\left(\left|\pi \cdot \left(n \cdot 2\right)\right|\right)}}^{\left(\frac{1 - k}{2}\right)} \]
    7. Step-by-step derivation
      1. *-un-lft-identity100.0%

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

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

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

        \[\leadsto \left(1 \cdot {k}^{\color{blue}{-0.5}}\right) \cdot {\left(\left|\pi \cdot \left(n \cdot 2\right)\right|\right)}^{\left(\frac{1 - k}{2}\right)} \]
    8. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(1 \cdot {k}^{-0.5}\right)} \cdot {\left(\left|\pi \cdot \left(n \cdot 2\right)\right|\right)}^{\left(\frac{1 - k}{2}\right)} \]
    9. Step-by-step derivation
      1. *-lft-identity100.0%

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

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

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

        \[\leadsto \sqrt{\frac{\color{blue}{\left|2\right| \cdot \left|n \cdot \pi\right|}}{k}} \]
      2. metadata-eval2.8%

        \[\leadsto \sqrt{\frac{\color{blue}{2} \cdot \left|n \cdot \pi\right|}{k}} \]
    13. Simplified2.8%

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

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

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

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

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

        \[\leadsto \sqrt{e^{\mathsf{log1p}\left(\color{blue}{2 \cdot \frac{\left|n \cdot \pi\right|}{k}}\right)} - 1} \]
      6. add-sqr-sqrt18.8%

        \[\leadsto \sqrt{e^{\mathsf{log1p}\left(2 \cdot \frac{\left|\color{blue}{\sqrt{n \cdot \pi} \cdot \sqrt{n \cdot \pi}}\right|}{k}\right)} - 1} \]
      7. fabs-sqr18.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 9.6 \cdot 10^{+94}:\\ \;\;\;\;{k}^{-0.5} \cdot \sqrt{\pi \cdot \left(n \cdot 2\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + \mathsf{fma}\left(n, \pi \cdot \frac{2}{k}, -1\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.5% accurate, 1.0× speedup?

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

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

    \[\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/98.3%

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

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

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

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

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

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

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

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

      \[\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}} \]
    4. inv-pow98.3%

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

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

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

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

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

Alternative 5: 98.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 98.3%

    \[\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/98.3%

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

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

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

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

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

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

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

Alternative 6: 39.7% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 39.7% accurate, 1.0× speedup?

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

\\
\sqrt{\pi \cdot n} \cdot \sqrt{\frac{2}{k}}
\end{array}
Derivation
  1. Initial program 98.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 26.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\pi \cdot \frac{2 \cdot n}{k}}} \]
  10. Taylor expanded in n around 0 26.3%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 39.7% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 9: 30.9% accurate, 2.0× speedup?

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

\\
\frac{1}{\sqrt{k \cdot \frac{0.5}{\pi \cdot n}}}
\end{array}
Derivation
  1. Initial program 98.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 26.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\pi \cdot \frac{2 \cdot n}{k}}} \]
  10. Taylor expanded in n around 0 26.3%

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

      \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \pi}{k}}} \]
    2. add-sqr-sqrt26.2%

      \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\sqrt{n \cdot \pi} \cdot \sqrt{n \cdot \pi}}}{k}} \]
    3. fabs-sqr26.2%

      \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\left|\sqrt{n \cdot \pi} \cdot \sqrt{n \cdot \pi}\right|}}{k}} \]
    4. add-sqr-sqrt26.8%

      \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\left|\color{blue}{n \cdot \pi}\right|}{k}} \]
    5. sqrt-prod26.8%

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

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

      \[\leadsto \sqrt{\color{blue}{\frac{1}{\frac{k}{2 \cdot \left|n \cdot \pi\right|}}}} \]
    8. sqrt-div27.3%

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{k}{2 \cdot \left|n \cdot \pi\right|}}}} \]
    9. metadata-eval27.3%

      \[\leadsto \frac{\color{blue}{1}}{\sqrt{\frac{k}{2 \cdot \left|n \cdot \pi\right|}}} \]
    10. *-un-lft-identity27.3%

      \[\leadsto \frac{1}{\sqrt{\frac{\color{blue}{1 \cdot k}}{2 \cdot \left|n \cdot \pi\right|}}} \]
    11. add-sqr-sqrt26.8%

      \[\leadsto \frac{1}{\sqrt{\frac{1 \cdot k}{2 \cdot \left|\color{blue}{\sqrt{n \cdot \pi} \cdot \sqrt{n \cdot \pi}}\right|}}} \]
    12. fabs-sqr26.8%

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

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

      \[\leadsto \frac{1}{\sqrt{\color{blue}{\frac{1}{2} \cdot \frac{k}{n \cdot \pi}}}} \]
    15. metadata-eval26.8%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{0.5} \cdot \frac{k}{n \cdot \pi}}} \]
    16. *-commutative26.8%

      \[\leadsto \frac{1}{\sqrt{0.5 \cdot \frac{k}{\color{blue}{\pi \cdot n}}}} \]
  12. Applied egg-rr26.8%

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

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

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

      \[\leadsto \frac{1}{\sqrt{\color{blue}{k \cdot \frac{0.5}{\pi \cdot n}}}} \]
    4. *-commutative26.8%

      \[\leadsto \frac{1}{\sqrt{k \cdot \frac{0.5}{\color{blue}{n \cdot \pi}}}} \]
  14. Simplified26.8%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{k \cdot \frac{0.5}{n \cdot \pi}}}} \]
  15. Final simplification26.8%

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

Alternative 10: 30.9% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 30.4% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \sqrt{2 \cdot \frac{\pi \cdot n}{k}} \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(Float64(pi * 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[(N[(Pi * n), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{2 \cdot \frac{\pi \cdot n}{k}}
\end{array}
Derivation
  1. Initial program 98.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 26.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\pi \cdot \frac{2 \cdot n}{k}}} \]
  10. Taylor expanded in n around 0 26.3%

    \[\leadsto \sqrt{\color{blue}{2 \cdot \frac{n \cdot \pi}{k}}} \]
  11. Final simplification26.3%

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

Alternative 12: 30.4% 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 98.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 26.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 30.4% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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