Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.5%
Time: 18.9s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 99.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.6% 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^{-86}:\\ \;\;\;\;{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-86)
     (* (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-86) {
		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-86) {
		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-86:
		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-86)
		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-86)
		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-86], 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^{-86}:\\
\;\;\;\;{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.40000000000000013e-86

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.40000000000000013e-86 < k

    1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 2.4 \cdot 10^{-86}:\\ \;\;\;\;{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: 58.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;k \leq 5.2 \cdot 10^{+100}:\\ \;\;\;\;{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 5.2e+100)
   (* (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 <= 5.2e+100) {
		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 <= 5.2e+100)
		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, 5.2e+100], 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 5.2 \cdot 10^{+100}:\\
\;\;\;\;{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 < 5.2000000000000003e100

    1. Initial program 98.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 55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{\pi \cdot n} \cdot \sqrt{2}}{\sqrt{k}}} \]
      7. div-inv74.4%

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

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

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

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

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

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

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

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

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

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

    if 5.2000000000000003e100 < k

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 5.2 \cdot 10^{+100}:\\ \;\;\;\;{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: 99.4% accurate, 1.0× speedup?

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

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

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

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

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

Alternative 5: 99.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 99.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\left(2 \cdot n\right) \cdot \pi\right)}^{\left(0.5 - \color{blue}{0.5 \cdot k}\right)} \cdot {k}^{-0.5} \]
    5. cancel-sign-sub-inv99.2%

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

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

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

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

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

Alternative 7: 99.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 8: 49.4% 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 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{\pi \cdot n} \cdot \sqrt{2}}{\sqrt{k}}} \]
    7. div-inv51.5%

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 49.4% 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 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 49.3% 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.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 49.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 37.6% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 37.6% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 5.1% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \sqrt{\frac{1}{k}} \end{array} \]
(FPCore (k n) :precision binary64 (sqrt (/ 1.0 k)))
double code(double k, double n) {
	return sqrt((1.0 / k));
}
real(8) function code(k, n)
    real(8), intent (in) :: k
    real(8), intent (in) :: n
    code = sqrt((1.0d0 / k))
end function
public static double code(double k, double n) {
	return Math.sqrt((1.0 / k));
}
def code(k, n):
	return math.sqrt((1.0 / k))
function code(k, n)
	return sqrt(Float64(1.0 / k))
end
function tmp = code(k, n)
	tmp = sqrt((1.0 / k));
end
code[k_, n_] := N[Sqrt[N[(1.0 / k), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{\frac{1}{k}}
\end{array}
Derivation
  1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{\color{blue}{1}}{k}} \]
  8. Simplified5.3%

    \[\leadsto \sqrt{\frac{\color{blue}{1}}{k}} \]
  9. Final simplification5.3%

    \[\leadsto \sqrt{\frac{1}{k}} \]
  10. Add Preprocessing

Reproduce

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