Migdal et al, Equation (51)

Percentage Accurate: 98.4% → 99.6%
Time: 14.7s
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: 98.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 2 (PI.f64)) n) < 9.99999999999999938e-279

    1. Initial program 94.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-sqrt93.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-unprod94.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. *-commutative94.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*94.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-sub94.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-eval94.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-inv94.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. *-commutative94.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-rr94.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. Simplified94.0%

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999938e-279 < (*.f64 (*.f64 2 (PI.f64)) n)

    1. Initial program 99.3%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. 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
  3. Recombined 2 regimes into one program.
  4. Final simplification99.6%

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

Alternative 2: 99.6% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.2% accurate, 1.0× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3500000000000001e-62 < k

    1. Initial program 97.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. Step-by-step derivation
      1. associate-*r*97.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.3% accurate, 1.0× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35000000000000004e-36 < k

    1. Initial program 97.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. Step-by-step derivation
      1. add-sqr-sqrt97.2%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 57.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 95.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 65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.79999999999999971e29 < k

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 98.5% accurate, 1.0× speedup?

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

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

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. Step-by-step derivation
    1. associate-*l/98.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-identity98.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*98.0%

      \[\leadsto \frac{{\color{blue}{\left(2 \cdot \left(\pi \cdot n\right)\right)}}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}} \]
    4. div-sub98.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-eval98.0%

      \[\leadsto \frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(\color{blue}{0.5} - \frac{k}{2}\right)}}{\sqrt{k}} \]
  3. Simplified98.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. Final simplification98.0%

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

Alternative 7: 30.8% accurate, 1.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 (fabs (* PI (/ n k))))))
double code(double k, double n) {
	return sqrt((2.0 * fabs((((double) M_PI) * (n / k)))));
}
public static double code(double k, double n) {
	return Math.sqrt((2.0 * Math.abs((Math.PI * (n / k)))));
}
def code(k, n):
	return math.sqrt((2.0 * math.fabs((math.pi * (n / k)))))
function code(k, n)
	return sqrt(Float64(2.0 * abs(Float64(pi * Float64(n / k)))))
end
function tmp = code(k, n)
	tmp = sqrt((2.0 * abs((pi * (n / k)))));
end
code[k_, n_] := N[Sqrt[N[(2.0 * N[Abs[N[(Pi * N[(n / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{2 \cdot \color{blue}{\left|\pi \cdot \frac{n}{k}\right|}} \]
  15. Simplified31.4%

    \[\leadsto \sqrt{2 \cdot \color{blue}{\left|\pi \cdot \frac{n}{k}\right|}} \]
  16. Final simplification31.4%

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

Alternative 8: 39.6% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{n \cdot 2} \cdot \sqrt{\frac{\pi}{k}}} \]
  14. Final simplification39.4%

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

Alternative 9: 30.1% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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