Migdal et al, Equation (51)

Percentage Accurate: 99.5% → 99.5%
Time: 15.4s
Alternatives: 9
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.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.5% accurate, 1.0× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {k}^{-0.5} \cdot \sqrt{\color{blue}{\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 1.99999999999999989e-20 < k

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 1.0× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {k}^{-0.5} \cdot \sqrt{\color{blue}{\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 1.45e-20 < k

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt99.5%

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

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

        \[\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*99.5%

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

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

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

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

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

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

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

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

Alternative 3: 59.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;k \leq 1.5 \cdot 10^{+101}:\\ \;\;\;\;{k}^{-0.5} \cdot \sqrt{\pi \cdot \left(2 \cdot n\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 1.5e+101)
   (* (pow k -0.5) (sqrt (* PI (* 2.0 n))))
   (sqrt (+ -1.0 (fma n (* PI (/ 2.0 k)) 1.0)))))
double code(double k, double n) {
	double tmp;
	if (k <= 1.5e+101) {
		tmp = pow(k, -0.5) * sqrt((((double) M_PI) * (2.0 * n)));
	} 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 <= 1.5e+101)
		tmp = Float64((k ^ -0.5) * sqrt(Float64(pi * Float64(2.0 * n))));
	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, 1.5e+101], N[(N[Power[k, -0.5], $MachinePrecision] * N[Sqrt[N[(Pi * N[(2.0 * n), $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 1.5 \cdot 10^{+101}:\\
\;\;\;\;{k}^{-0.5} \cdot \sqrt{\pi \cdot \left(2 \cdot n\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 < 1.49999999999999997e101

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.49999999999999997e101 < 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. Step-by-step derivation
      1. associate-*l/100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 49.7% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 38.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.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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. Applied egg-rr85.3%

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

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

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

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

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

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

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

Alternative 9: 38.0% 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.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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