Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.5%
Time: 13.6s
Alternatives: 15
Speedup: 1.1×

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}

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 15 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, 1.1× speedup?

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

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

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


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

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{0.5}}{\sqrt{k}}} \]
    4. Taylor expanded in n around inf

      \[\leadsto \frac{n \cdot \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{n}}}{\sqrt{\color{blue}{k}}} \]
    5. Applied rewrites50.2%

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

    if 2.99999999999999989e-41 < k

    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. Applied rewrites99.4%

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

      \[\leadsto \frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k} \cdot \color{blue}{\left(\sqrt{\left(\pi + \pi\right) \cdot n} \cdot e^{\log \left(\sqrt{\left(\pi + \pi\right) \cdot n}\right) \cdot \left(-k\right)}\right)} \]
    4. Applied rewrites87.5%

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

Alternative 2: 99.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\left(\pi + \pi\right) \cdot n}\\ \frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k} \cdot \left(t\_0 \cdot e^{\log t\_0 \cdot \left(-k\right)}\right) \end{array} \end{array} \]
(FPCore (k n)
 :precision binary64
 (let* ((t_0 (sqrt (* (+ PI PI) n))))
   (*
    (/ (fma 1.0 (sqrt k) (* (sqrt k) 0.0)) k)
    (* t_0 (exp (* (log t_0) (- k)))))))
double code(double k, double n) {
	double t_0 = sqrt(((((double) M_PI) + ((double) M_PI)) * n));
	return (fma(1.0, sqrt(k), (sqrt(k) * 0.0)) / k) * (t_0 * exp((log(t_0) * -k)));
}
function code(k, n)
	t_0 = sqrt(Float64(Float64(pi + pi) * n))
	return Float64(Float64(fma(1.0, sqrt(k), Float64(sqrt(k) * 0.0)) / k) * Float64(t_0 * exp(Float64(log(t_0) * Float64(-k)))))
end
code[k_, n_] := Block[{t$95$0 = N[Sqrt[N[(N[(Pi + Pi), $MachinePrecision] * n), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(1.0 * N[Sqrt[k], $MachinePrecision] + N[(N[Sqrt[k], $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision] * N[(t$95$0 * N[Exp[N[(N[Log[t$95$0], $MachinePrecision] * (-k)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\left(\pi + \pi\right) \cdot n}\\
\frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k} \cdot \left(t\_0 \cdot e^{\log t\_0 \cdot \left(-k\right)}\right)
\end{array}
\end{array}
Derivation
  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. Applied rewrites99.4%

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

    \[\leadsto \frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k} \cdot \color{blue}{\left(\sqrt{\left(\pi + \pi\right) \cdot n} \cdot e^{\log \left(\sqrt{\left(\pi + \pi\right) \cdot n}\right) \cdot \left(-k\right)}\right)} \]
  4. Add Preprocessing

Alternative 3: 99.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \end{array} \]
(FPCore (k n)
 :precision binary64
 (*
  (/ (fma 1.0 (sqrt k) (* (sqrt k) 0.0)) k)
  (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
	return (fma(1.0, sqrt(k), (sqrt(k) * 0.0)) / k) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0));
}
function code(k, n)
	return Float64(Float64(fma(1.0, sqrt(k), Float64(sqrt(k) * 0.0)) / k) * (Float64(Float64(2.0 * pi) * n) ^ Float64(Float64(1.0 - k) / 2.0)))
end
code[k_, n_] := N[(N[(N[(1.0 * N[Sqrt[k], $MachinePrecision] + N[(N[Sqrt[k], $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision] / k), $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{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Derivation
  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. Applied rewrites99.4%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  3. Add Preprocessing

Alternative 4: 99.3% accurate, 1.0× speedup?

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

\\
\frac{\sqrt{{\left(\sqrt{\left(\pi + \pi\right) \cdot n}\right)}^{\left(\mathsf{fma}\left(k, -2, 2\right)\right)}}}{\sqrt{k}}
\end{array}
Derivation
  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. Applied rewrites99.4%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  3. Applied rewrites99.4%

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

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

    \[\leadsto \frac{\sqrt{\color{blue}{{\left(\sqrt{\left(\pi + \pi\right) \cdot n}\right)}^{\left(\mathsf{fma}\left(k, -2, 2\right)\right)}}}}{\sqrt{k}} \]
  6. Add Preprocessing

Alternative 5: 99.3% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \frac{{\left(\left(\pi + \pi\right) \cdot n\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}} \end{array} \]
(FPCore (k n)
 :precision binary64
 (/ (pow (* (+ PI PI) n) (fma k -0.5 0.5)) (sqrt k)))
double code(double k, double n) {
	return pow(((((double) M_PI) + ((double) M_PI)) * n), fma(k, -0.5, 0.5)) / sqrt(k);
}
function code(k, n)
	return Float64((Float64(Float64(pi + pi) * n) ^ fma(k, -0.5, 0.5)) / sqrt(k))
end
code[k_, n_] := N[(N[Power[N[(N[(Pi + Pi), $MachinePrecision] * n), $MachinePrecision], N[(k * -0.5 + 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{{\left(\left(\pi + \pi\right) \cdot n\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}
\end{array}
Derivation
  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. Applied rewrites99.5%

    \[\leadsto \color{blue}{\frac{{\left(\left(\pi + \pi\right) \cdot n\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}} \]
  3. Add Preprocessing

Alternative 6: 99.2% accurate, 1.1× speedup?

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

\\
\frac{\sqrt{{\left(\left(\pi + \pi\right) \cdot n\right)}^{\left(1 - k\right)}}}{\sqrt{k}}
\end{array}
Derivation
  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. Applied rewrites99.4%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  3. Applied rewrites99.4%

    \[\leadsto \color{blue}{\frac{\sqrt{{\left(\left(\pi + \pi\right) \cdot n\right)}^{\left(1 - k\right)}}}{\sqrt{k}}} \]
  4. Add Preprocessing

Alternative 7: 79.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;\sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{\sqrt{\left(k \cdot k\right) \cdot \left(k \cdot k\right)}}}}\\ \mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+296}:\\ \;\;\;\;\frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k} \cdot \sqrt{2 \cdot \left(n \cdot \pi\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(\pi + \pi\right) \cdot n}}{k \cdot \sqrt{\sqrt{\frac{1}{k} \cdot \frac{1}{k}}}}\\ \end{array} \end{array} \]
(FPCore (k n)
 :precision binary64
 (let* ((t_0 (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0)))))
   (if (<= t_0 0.0)
     (sqrt (* (+ PI PI) (/ n (sqrt (sqrt (* (* k k) (* k k)))))))
     (if (<= t_0 4e+296)
       (* (/ (fma 1.0 (sqrt k) (* (sqrt k) 0.0)) k) (sqrt (* 2.0 (* n PI))))
       (/
        (sqrt (* (+ PI PI) n))
        (* k (sqrt (sqrt (* (/ 1.0 k) (/ 1.0 k))))))))))
double code(double k, double n) {
	double t_0 = (1.0 / sqrt(k)) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0));
	double tmp;
	if (t_0 <= 0.0) {
		tmp = sqrt(((((double) M_PI) + ((double) M_PI)) * (n / sqrt(sqrt(((k * k) * (k * k)))))));
	} else if (t_0 <= 4e+296) {
		tmp = (fma(1.0, sqrt(k), (sqrt(k) * 0.0)) / k) * sqrt((2.0 * (n * ((double) M_PI))));
	} else {
		tmp = sqrt(((((double) M_PI) + ((double) M_PI)) * n)) / (k * sqrt(sqrt(((1.0 / k) * (1.0 / k)))));
	}
	return tmp;
}
function code(k, n)
	t_0 = Float64(Float64(1.0 / sqrt(k)) * (Float64(Float64(2.0 * pi) * n) ^ Float64(Float64(1.0 - k) / 2.0)))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = sqrt(Float64(Float64(pi + pi) * Float64(n / sqrt(sqrt(Float64(Float64(k * k) * Float64(k * k)))))));
	elseif (t_0 <= 4e+296)
		tmp = Float64(Float64(fma(1.0, sqrt(k), Float64(sqrt(k) * 0.0)) / k) * sqrt(Float64(2.0 * Float64(n * pi))));
	else
		tmp = Float64(sqrt(Float64(Float64(pi + pi) * n)) / Float64(k * sqrt(sqrt(Float64(Float64(1.0 / k) * Float64(1.0 / k))))));
	end
	return tmp
end
code[k_, n_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, 0.0], N[Sqrt[N[(N[(Pi + Pi), $MachinePrecision] * N[(n / N[Sqrt[N[Sqrt[N[(N[(k * k), $MachinePrecision] * N[(k * k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 4e+296], N[(N[(N[(1.0 * N[Sqrt[k], $MachinePrecision] + N[(N[Sqrt[k], $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(n * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(Pi + Pi), $MachinePrecision] * n), $MachinePrecision]], $MachinePrecision] / N[(k * N[Sqrt[N[Sqrt[N[(N[(1.0 / k), $MachinePrecision] * N[(1.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{\sqrt{\left(k \cdot k\right) \cdot \left(k \cdot k\right)}}}}\\

\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+296}:\\
\;\;\;\;\frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k} \cdot \sqrt{2 \cdot \left(n \cdot \pi\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) < 0.0

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

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

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

      \[\leadsto \sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{k \cdot k}}} \]
    6. Applied rewrites31.8%

      \[\leadsto \sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{\sqrt{\left(k \cdot k\right) \cdot \left(k \cdot k\right)}}}} \]

    if 0.0 < (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) < 3.99999999999999993e296

    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. Applied rewrites99.4%

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

      \[\leadsto \frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k} \cdot \color{blue}{\left(\sqrt{\left(\pi + \pi\right) \cdot n} \cdot e^{\log \left(\sqrt{\left(\pi + \pi\right) \cdot n}\right) \cdot \left(-k\right)}\right)} \]
    4. Taylor expanded in k around 0

      \[\leadsto \frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k} \cdot \color{blue}{\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}} \]
    5. Applied rewrites50.1%

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

    if 3.99999999999999993e296 < (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64))))

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{0.5}}{\sqrt{k}}} \]
    4. Taylor expanded in k around inf

      \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}}{\color{blue}{k \cdot \sqrt{\frac{1}{k}}}} \]
    5. Applied rewrites50.1%

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

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

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

Alternative 8: 68.3% accurate, 0.6× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{n \cdot \sqrt{2 \cdot \frac{\pi}{n}}}{\sqrt{k}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) < 5.0000000000000003e-124

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

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

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

      \[\leadsto \sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{k \cdot k}}} \]
    6. Applied rewrites31.8%

      \[\leadsto \sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{\sqrt{\left(k \cdot k\right) \cdot \left(k \cdot k\right)}}}} \]

    if 5.0000000000000003e-124 < (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64))))

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{0.5}}{\sqrt{k}}} \]
    4. Taylor expanded in n around inf

      \[\leadsto \frac{n \cdot \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{n}}}{\sqrt{\color{blue}{k}}} \]
    5. Applied rewrites50.2%

      \[\leadsto \frac{n \cdot \sqrt{2 \cdot \frac{\pi}{n}}}{\sqrt{\color{blue}{k}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 64.6% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;k \leq 1.9 \cdot 10^{+164}:\\
\;\;\;\;n \cdot \sqrt{2 \cdot \frac{\pi}{k \cdot n}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{k \cdot k}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if k < 2.7999999999999999e-31

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{0.5}}{\sqrt{k}}} \]
    4. Taylor expanded in n around inf

      \[\leadsto \frac{n \cdot \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{n}}}{\sqrt{\color{blue}{k}}} \]
    5. Applied rewrites50.2%

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

    if 2.7999999999999999e-31 < k < 1.90000000000000011e164

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

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

      \[\leadsto \color{blue}{\sqrt{\left(\pi + \pi\right) \cdot \frac{n}{k}}} \]
    5. Taylor expanded in n around inf

      \[\leadsto n \cdot \color{blue}{\sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}}} \]
    6. Applied rewrites50.4%

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

    if 1.90000000000000011e164 < k

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

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

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

      \[\leadsto \sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{k \cdot k}}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 64.6% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;k \leq 1.9 \cdot 10^{+164}:\\
\;\;\;\;n \cdot \sqrt{2 \cdot \frac{\pi}{k \cdot n}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{k \cdot k}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if k < 2.7999999999999999e-31

    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. Applied rewrites99.4%

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

      \[\leadsto \frac{\mathsf{fma}\left(1, \sqrt{k}, \sqrt{k} \cdot 0\right)}{k} \cdot \color{blue}{\left(\sqrt{\left(\pi + \pi\right) \cdot n} \cdot e^{\log \left(\sqrt{\left(\pi + \pi\right) \cdot n}\right) \cdot \left(-k\right)}\right)} \]
    4. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{\sqrt{k} \cdot \sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}}{k}} \]
    5. Applied rewrites50.1%

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

    if 2.7999999999999999e-31 < k < 1.90000000000000011e164

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

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

      \[\leadsto \color{blue}{\sqrt{\left(\pi + \pi\right) \cdot \frac{n}{k}}} \]
    5. Taylor expanded in n around inf

      \[\leadsto n \cdot \color{blue}{\sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}}} \]
    6. Applied rewrites50.4%

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

    if 1.90000000000000011e164 < k

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

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

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

      \[\leadsto \sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{k \cdot k}}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 11: 64.6% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\sqrt{\left(\pi + \pi\right) \cdot n}}{\sqrt{k}}\\

\mathbf{elif}\;k \leq 1.9 \cdot 10^{+164}:\\
\;\;\;\;n \cdot \sqrt{2 \cdot \frac{\pi}{k \cdot n}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{k \cdot k}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if k < 2.7999999999999999e-31

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

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

      \[\leadsto \frac{\sqrt{\left(\pi + \pi\right) \cdot n}}{\color{blue}{\sqrt{k}}} \]

    if 2.7999999999999999e-31 < k < 1.90000000000000011e164

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

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

      \[\leadsto \color{blue}{\sqrt{\left(\pi + \pi\right) \cdot \frac{n}{k}}} \]
    5. Taylor expanded in n around inf

      \[\leadsto n \cdot \color{blue}{\sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}}} \]
    6. Applied rewrites50.4%

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

    if 1.90000000000000011e164 < k

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

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

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

      \[\leadsto \sqrt{\left(\pi + \pi\right) \cdot \frac{n}{\sqrt{k \cdot k}}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 12: 61.8% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq 3.2 \cdot 10^{-57}:\\
\;\;\;\;\sqrt{\frac{n + n}{k} \cdot \pi}\\

\mathbf{else}:\\
\;\;\;\;n \cdot \sqrt{2 \cdot \frac{\pi}{k \cdot n}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < 3.2000000000000001e-57

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

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

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

      \[\leadsto \sqrt{\frac{n + n}{k} \cdot \pi} \]

    if 3.2000000000000001e-57 < n

    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. Taylor expanded in k around 0

      \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
    3. Applied rewrites50.2%

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

      \[\leadsto \color{blue}{\sqrt{\left(\pi + \pi\right) \cdot \frac{n}{k}}} \]
    5. Taylor expanded in n around inf

      \[\leadsto n \cdot \color{blue}{\sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}}} \]
    6. Applied rewrites50.4%

      \[\leadsto n \cdot \color{blue}{\sqrt{2 \cdot \frac{\pi}{k \cdot n}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 50.2% accurate, 2.7× speedup?

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

\\
\frac{\sqrt{\left(\pi + \pi\right) \cdot n}}{\sqrt{k}}
\end{array}
Derivation
  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. Taylor expanded in k around 0

    \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
  3. Applied rewrites50.2%

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

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

Alternative 14: 38.2% accurate, 3.1× speedup?

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

\\
\sqrt{\frac{n + n}{k} \cdot \pi}
\end{array}
Derivation
  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. Taylor expanded in k around 0

    \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
  3. Applied rewrites50.2%

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

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

    \[\leadsto \sqrt{\frac{n + n}{k} \cdot \pi} \]
  6. Add Preprocessing

Alternative 15: 38.2% accurate, 3.1× speedup?

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

\\
\sqrt{\left(\pi + \pi\right) \cdot \frac{n}{k}}
\end{array}
Derivation
  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. Taylor expanded in k around 0

    \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}}} \]
  3. Applied rewrites50.2%

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

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

Reproduce

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