Migdal et al, Equation (51)

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

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

Initial Program: 99.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 1.1× speedup?

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

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

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

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

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

      \[\leadsto {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \color{blue}{\frac{1}{\sqrt{k}}} \]
    4. mult-flip-revN/A

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

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

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

Alternative 2: 99.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. 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. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lower-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      5. lower-PI.f64N/A

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

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

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

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. unpow1/2N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{\color{blue}{k}}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{k}} \]
      5. count-2-revN/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      8. distribute-lft-inN/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      9. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      12. sqrt-undivN/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      14. lower-/.f6438.1

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

      \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
      2. mult-flipN/A

        \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
      3. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
      4. *-commutativeN/A

        \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
      5. lift-/.f64N/A

        \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
      6. associate-*l*N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      8. lift-/.f64N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      9. mult-flip-revN/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      10. lower-/.f6438.1

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    8. Applied rewrites38.1%

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    9. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      3. lift-/.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      4. lift-+.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      5. div-addN/A

        \[\leadsto \sqrt{\pi \cdot \left(\frac{n}{k} + \frac{n}{k}\right)} \]
      6. distribute-lft-inN/A

        \[\leadsto \sqrt{\pi \cdot \frac{n}{k} + \pi \cdot \frac{n}{k}} \]
      7. distribute-rgt-outN/A

        \[\leadsto \sqrt{\frac{n}{k} \cdot \left(\pi + \pi\right)} \]
      8. lift-+.f64N/A

        \[\leadsto \sqrt{\frac{n}{k} \cdot \left(\pi + \pi\right)} \]
      9. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{n}{k}} \cdot \color{blue}{\sqrt{\pi + \pi}} \]
      10. sqrt-undivN/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\color{blue}{\pi + \pi}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\color{blue}{\pi} + \pi} \]
      12. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\pi + \color{blue}{\pi}} \]
      13. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\pi + \pi} \]
      14. associate-*l/N/A

        \[\leadsto \frac{\sqrt{n} \cdot \sqrt{\pi + \pi}}{\color{blue}{\sqrt{k}}} \]
      15. associate-/l*N/A

        \[\leadsto \sqrt{n} \cdot \color{blue}{\frac{\sqrt{\pi + \pi}}{\sqrt{k}}} \]
      16. lower-*.f64N/A

        \[\leadsto \sqrt{n} \cdot \color{blue}{\frac{\sqrt{\pi + \pi}}{\sqrt{k}}} \]
      17. lift-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \frac{\sqrt{\pi + \pi}}{\sqrt{\color{blue}{k}}} \]
      18. lift-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \frac{\sqrt{\pi + \pi}}{\sqrt{k}} \]
      19. sqrt-undivN/A

        \[\leadsto \sqrt{n} \cdot \sqrt{\frac{\pi + \pi}{k}} \]
      20. lower-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \sqrt{\frac{\pi + \pi}{k}} \]
    10. Applied rewrites49.5%

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

    if 1.70000000000000007e-50 < k

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \color{blue}{\frac{1}{\sqrt{k}}} \]
      4. mult-flip-revN/A

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

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

      \[\leadsto \color{blue}{\frac{{\left(n \cdot \left(\pi + \pi\right)\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}} \]
    4. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{{\left(n \cdot \left(\pi + \pi\right)\right)}^{\left(\mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)\right)}}{\sqrt{k}}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\color{blue}{{\left(n \cdot \left(\pi + \pi\right)\right)}^{\left(\mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)\right)}}}{\sqrt{k}} \]
      3. exp-to-powN/A

        \[\leadsto \frac{\color{blue}{e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}}{\sqrt{k}} \]
      4. lift-log.f64N/A

        \[\leadsto \frac{e^{\color{blue}{\log \left(n \cdot \left(\pi + \pi\right)\right)} \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}{\sqrt{k}} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{e^{\color{blue}{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}}{\sqrt{k}} \]
      6. exp-fabsN/A

        \[\leadsto \frac{\color{blue}{\left|e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}\right|}}{\sqrt{k}} \]
      7. lift-exp.f64N/A

        \[\leadsto \frac{\left|\color{blue}{e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}\right|}{\sqrt{k}} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{\color{blue}{\sqrt{e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)} \cdot e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}}}{\sqrt{k}} \]
      9. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)} \cdot e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}}{\color{blue}{\sqrt{k}}} \]
      10. sqrt-undivN/A

        \[\leadsto \color{blue}{\sqrt{\frac{e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)} \cdot e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}{k}}} \]
      11. lower-sqrt.f64N/A

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

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(\left(n + n\right) \cdot \pi\right)}^{\left(2 \cdot \mathsf{fma}\left(-0.5, k, 0.5\right)\right)}}{k}}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{{\left(\left(n + n\right) \cdot \pi\right)}^{\color{blue}{\left(2 \cdot \mathsf{fma}\left(\frac{-1}{2}, k, \frac{1}{2}\right)\right)}}}{k}} \]
      2. lift-fma.f64N/A

        \[\leadsto \sqrt{\frac{{\left(\left(n + n\right) \cdot \pi\right)}^{\left(2 \cdot \color{blue}{\left(\frac{-1}{2} \cdot k + \frac{1}{2}\right)}\right)}}{k}} \]
      3. distribute-rgt-inN/A

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

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

        \[\leadsto \sqrt{\frac{{\left(\left(n + n\right) \cdot \pi\right)}^{\left(\color{blue}{k \cdot \left(\frac{-1}{2} \cdot 2\right)} + \frac{1}{2} \cdot 2\right)}}{k}} \]
      6. metadata-evalN/A

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

        \[\leadsto \sqrt{\frac{{\left(\left(n + n\right) \cdot \pi\right)}^{\left(k \cdot -1 + \color{blue}{1}\right)}}{k}} \]
      8. lower-fma.f6488.0

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

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

Alternative 3: 98.3% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{\frac{\pi + \pi}{k}}\\

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


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

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. 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. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lower-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      5. lower-PI.f64N/A

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

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

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

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. unpow1/2N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{\color{blue}{k}}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{k}} \]
      5. count-2-revN/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      8. distribute-lft-inN/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      9. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      12. sqrt-undivN/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      14. lower-/.f6438.1

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

      \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
      2. mult-flipN/A

        \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
      3. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
      4. *-commutativeN/A

        \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
      5. lift-/.f64N/A

        \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
      6. associate-*l*N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      8. lift-/.f64N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      9. mult-flip-revN/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      10. lower-/.f6438.1

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    8. Applied rewrites38.1%

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    9. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      3. lift-/.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      4. lift-+.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      5. div-addN/A

        \[\leadsto \sqrt{\pi \cdot \left(\frac{n}{k} + \frac{n}{k}\right)} \]
      6. distribute-lft-inN/A

        \[\leadsto \sqrt{\pi \cdot \frac{n}{k} + \pi \cdot \frac{n}{k}} \]
      7. distribute-rgt-outN/A

        \[\leadsto \sqrt{\frac{n}{k} \cdot \left(\pi + \pi\right)} \]
      8. lift-+.f64N/A

        \[\leadsto \sqrt{\frac{n}{k} \cdot \left(\pi + \pi\right)} \]
      9. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{n}{k}} \cdot \color{blue}{\sqrt{\pi + \pi}} \]
      10. sqrt-undivN/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\color{blue}{\pi + \pi}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\color{blue}{\pi} + \pi} \]
      12. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\pi + \color{blue}{\pi}} \]
      13. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\pi + \pi} \]
      14. associate-*l/N/A

        \[\leadsto \frac{\sqrt{n} \cdot \sqrt{\pi + \pi}}{\color{blue}{\sqrt{k}}} \]
      15. associate-/l*N/A

        \[\leadsto \sqrt{n} \cdot \color{blue}{\frac{\sqrt{\pi + \pi}}{\sqrt{k}}} \]
      16. lower-*.f64N/A

        \[\leadsto \sqrt{n} \cdot \color{blue}{\frac{\sqrt{\pi + \pi}}{\sqrt{k}}} \]
      17. lift-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \frac{\sqrt{\pi + \pi}}{\sqrt{\color{blue}{k}}} \]
      18. lift-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \frac{\sqrt{\pi + \pi}}{\sqrt{k}} \]
      19. sqrt-undivN/A

        \[\leadsto \sqrt{n} \cdot \sqrt{\frac{\pi + \pi}{k}} \]
      20. lower-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \sqrt{\frac{\pi + \pi}{k}} \]
    10. Applied rewrites49.5%

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

    if 1 < k

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \color{blue}{\frac{1}{\sqrt{k}}} \]
      4. mult-flip-revN/A

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

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

      \[\leadsto \color{blue}{\frac{{\left(n \cdot \left(\pi + \pi\right)\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}} \]
    4. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{{\left(n \cdot \left(\pi + \pi\right)\right)}^{\left(\mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)\right)}}{\sqrt{k}}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\color{blue}{{\left(n \cdot \left(\pi + \pi\right)\right)}^{\left(\mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)\right)}}}{\sqrt{k}} \]
      3. exp-to-powN/A

        \[\leadsto \frac{\color{blue}{e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}}{\sqrt{k}} \]
      4. lift-log.f64N/A

        \[\leadsto \frac{e^{\color{blue}{\log \left(n \cdot \left(\pi + \pi\right)\right)} \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}{\sqrt{k}} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{e^{\color{blue}{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}}{\sqrt{k}} \]
      6. exp-fabsN/A

        \[\leadsto \frac{\color{blue}{\left|e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}\right|}}{\sqrt{k}} \]
      7. lift-exp.f64N/A

        \[\leadsto \frac{\left|\color{blue}{e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}\right|}{\sqrt{k}} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{\color{blue}{\sqrt{e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)} \cdot e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}}}{\sqrt{k}} \]
      9. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)} \cdot e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}}{\color{blue}{\sqrt{k}}} \]
      10. sqrt-undivN/A

        \[\leadsto \color{blue}{\sqrt{\frac{e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)} \cdot e^{\log \left(n \cdot \left(\pi + \pi\right)\right) \cdot \mathsf{fma}\left(k, \frac{-1}{2}, \frac{1}{2}\right)}}{k}}} \]
      11. lower-sqrt.f64N/A

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

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(\left(n + n\right) \cdot \pi\right)}^{\left(2 \cdot \mathsf{fma}\left(-0.5, k, 0.5\right)\right)}}{k}}} \]
    6. Taylor expanded in k around inf

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

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

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

Alternative 4: 61.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. 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. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lower-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      5. lower-PI.f64N/A

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

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

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

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. unpow1/2N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{\color{blue}{k}}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{k}} \]
      5. count-2-revN/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      8. distribute-lft-inN/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      9. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      12. sqrt-undivN/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      14. lower-/.f6438.1

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

      \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
      2. mult-flipN/A

        \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
      3. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
      4. *-commutativeN/A

        \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
      5. lift-/.f64N/A

        \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
      6. associate-*l*N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      8. lift-/.f64N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      9. mult-flip-revN/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      10. lower-/.f6438.1

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    8. Applied rewrites38.1%

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    9. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      3. lift-/.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      4. lift-+.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      5. div-addN/A

        \[\leadsto \sqrt{\pi \cdot \left(\frac{n}{k} + \frac{n}{k}\right)} \]
      6. distribute-lft-inN/A

        \[\leadsto \sqrt{\pi \cdot \frac{n}{k} + \pi \cdot \frac{n}{k}} \]
      7. distribute-rgt-outN/A

        \[\leadsto \sqrt{\frac{n}{k} \cdot \left(\pi + \pi\right)} \]
      8. lift-+.f64N/A

        \[\leadsto \sqrt{\frac{n}{k} \cdot \left(\pi + \pi\right)} \]
      9. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{n}{k}} \cdot \color{blue}{\sqrt{\pi + \pi}} \]
      10. sqrt-undivN/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\color{blue}{\pi + \pi}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\color{blue}{\pi} + \pi} \]
      12. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\pi + \color{blue}{\pi}} \]
      13. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\pi + \pi} \]
      14. associate-*l/N/A

        \[\leadsto \frac{\sqrt{n} \cdot \sqrt{\pi + \pi}}{\color{blue}{\sqrt{k}}} \]
      15. associate-/l*N/A

        \[\leadsto \sqrt{n} \cdot \color{blue}{\frac{\sqrt{\pi + \pi}}{\sqrt{k}}} \]
      16. lower-*.f64N/A

        \[\leadsto \sqrt{n} \cdot \color{blue}{\frac{\sqrt{\pi + \pi}}{\sqrt{k}}} \]
      17. lift-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \frac{\sqrt{\pi + \pi}}{\sqrt{\color{blue}{k}}} \]
      18. lift-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \frac{\sqrt{\pi + \pi}}{\sqrt{k}} \]
      19. sqrt-undivN/A

        \[\leadsto \sqrt{n} \cdot \sqrt{\frac{\pi + \pi}{k}} \]
      20. lower-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \sqrt{\frac{\pi + \pi}{k}} \]
    10. Applied rewrites49.5%

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

    if 7.00000000000000048e-8 < k < 1.16e176

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. 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. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lower-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      5. lower-PI.f64N/A

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

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

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

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. unpow1/2N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{\color{blue}{k}}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{k}} \]
      5. count-2-revN/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      8. distribute-lft-inN/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      9. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      12. sqrt-undivN/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      14. lower-/.f6438.1

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

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

      \[\leadsto n \cdot \color{blue}{\sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}}} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}} \]
      2. lower-sqrt.f64N/A

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}} \]
      3. lower-*.f64N/A

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}} \]
      4. lower-/.f64N/A

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}} \]
      5. lower-PI.f64N/A

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\pi}{k \cdot n}} \]
      6. lower-*.f6449.4

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\pi}{k \cdot n}} \]
    9. Applied rewrites49.4%

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

    if 1.16e176 < k

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. 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. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lower-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      5. lower-PI.f64N/A

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

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

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

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. unpow1/2N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{\color{blue}{k}}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{k}} \]
      5. count-2-revN/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      8. distribute-lft-inN/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      9. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      12. sqrt-undivN/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      14. lower-/.f6438.1

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

      \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
      2. mult-flipN/A

        \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
      3. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
      4. *-commutativeN/A

        \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
      5. lift-/.f64N/A

        \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
      6. associate-*l*N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      8. lift-/.f64N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      9. mult-flip-revN/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      10. lower-/.f6438.1

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    8. Applied rewrites38.1%

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      2. *-commutativeN/A

        \[\leadsto \sqrt{\frac{n + n}{k} \cdot \pi} \]
      3. lift-PI.f64N/A

        \[\leadsto \sqrt{\frac{n + n}{k} \cdot \mathsf{PI}\left(\right)} \]
      4. add-log-expN/A

        \[\leadsto \sqrt{\frac{n + n}{k} \cdot \log \left(e^{\mathsf{PI}\left(\right)}\right)} \]
      5. log-pow-revN/A

        \[\leadsto \sqrt{\log \left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{\left(\frac{n + n}{k}\right)}\right)} \]
      6. lower-log.f64N/A

        \[\leadsto \sqrt{\log \left({\left(e^{\mathsf{PI}\left(\right)}\right)}^{\left(\frac{n + n}{k}\right)}\right)} \]
      7. lift-PI.f64N/A

        \[\leadsto \sqrt{\log \left({\left(e^{\pi}\right)}^{\left(\frac{n + n}{k}\right)}\right)} \]
      8. pow-expN/A

        \[\leadsto \sqrt{\log \left(e^{\pi \cdot \frac{n + n}{k}}\right)} \]
      9. lift-/.f64N/A

        \[\leadsto \sqrt{\log \left(e^{\pi \cdot \frac{n + n}{k}}\right)} \]
      10. associate-*r/N/A

        \[\leadsto \sqrt{\log \left(e^{\frac{\pi \cdot \left(n + n\right)}{k}}\right)} \]
      11. *-commutativeN/A

        \[\leadsto \sqrt{\log \left(e^{\frac{\left(n + n\right) \cdot \pi}{k}}\right)} \]
      12. lift-*.f64N/A

        \[\leadsto \sqrt{\log \left(e^{\frac{\left(n + n\right) \cdot \pi}{k}}\right)} \]
      13. lift-/.f64N/A

        \[\leadsto \sqrt{\log \left(e^{\frac{\left(n + n\right) \cdot \pi}{k}}\right)} \]
      14. lower-exp.f6414.7

        \[\leadsto \sqrt{\log \left(e^{\frac{\left(n + n\right) \cdot \pi}{k}}\right)} \]
      15. lift-/.f64N/A

        \[\leadsto \sqrt{\log \left(e^{\frac{\left(n + n\right) \cdot \pi}{k}}\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \sqrt{\log \left(e^{\frac{\left(n + n\right) \cdot \pi}{k}}\right)} \]
      17. associate-*l/N/A

        \[\leadsto \sqrt{\log \left(e^{\frac{n + n}{k} \cdot \pi}\right)} \]
      18. lift-/.f64N/A

        \[\leadsto \sqrt{\log \left(e^{\frac{n + n}{k} \cdot \pi}\right)} \]
      19. lower-*.f6414.7

        \[\leadsto \sqrt{\log \left(e^{\frac{n + n}{k} \cdot \pi}\right)} \]
    10. Applied rewrites14.7%

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

Alternative 5: 60.5% accurate, 2.0× speedup?

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

\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 k < 7.00000000000000048e-8

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. 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. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lower-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      5. lower-PI.f64N/A

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

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

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

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. unpow1/2N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{\color{blue}{k}}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{k}} \]
      5. count-2-revN/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      8. distribute-lft-inN/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      9. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      12. sqrt-undivN/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      14. lower-/.f6438.1

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

      \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
      2. mult-flipN/A

        \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
      3. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
      4. *-commutativeN/A

        \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
      5. lift-/.f64N/A

        \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
      6. associate-*l*N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      8. lift-/.f64N/A

        \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
      9. mult-flip-revN/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      10. lower-/.f6438.1

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    8. Applied rewrites38.1%

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    9. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      3. lift-/.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      4. lift-+.f64N/A

        \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
      5. div-addN/A

        \[\leadsto \sqrt{\pi \cdot \left(\frac{n}{k} + \frac{n}{k}\right)} \]
      6. distribute-lft-inN/A

        \[\leadsto \sqrt{\pi \cdot \frac{n}{k} + \pi \cdot \frac{n}{k}} \]
      7. distribute-rgt-outN/A

        \[\leadsto \sqrt{\frac{n}{k} \cdot \left(\pi + \pi\right)} \]
      8. lift-+.f64N/A

        \[\leadsto \sqrt{\frac{n}{k} \cdot \left(\pi + \pi\right)} \]
      9. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{n}{k}} \cdot \color{blue}{\sqrt{\pi + \pi}} \]
      10. sqrt-undivN/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\color{blue}{\pi + \pi}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\color{blue}{\pi} + \pi} \]
      12. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\pi + \color{blue}{\pi}} \]
      13. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\pi + \pi} \]
      14. associate-*l/N/A

        \[\leadsto \frac{\sqrt{n} \cdot \sqrt{\pi + \pi}}{\color{blue}{\sqrt{k}}} \]
      15. associate-/l*N/A

        \[\leadsto \sqrt{n} \cdot \color{blue}{\frac{\sqrt{\pi + \pi}}{\sqrt{k}}} \]
      16. lower-*.f64N/A

        \[\leadsto \sqrt{n} \cdot \color{blue}{\frac{\sqrt{\pi + \pi}}{\sqrt{k}}} \]
      17. lift-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \frac{\sqrt{\pi + \pi}}{\sqrt{\color{blue}{k}}} \]
      18. lift-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \frac{\sqrt{\pi + \pi}}{\sqrt{k}} \]
      19. sqrt-undivN/A

        \[\leadsto \sqrt{n} \cdot \sqrt{\frac{\pi + \pi}{k}} \]
      20. lower-sqrt.f64N/A

        \[\leadsto \sqrt{n} \cdot \sqrt{\frac{\pi + \pi}{k}} \]
    10. Applied rewrites49.5%

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

    if 7.00000000000000048e-8 < k

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
    2. 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. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lower-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
      5. lower-PI.f64N/A

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

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

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

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
      3. unpow1/2N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{\color{blue}{k}}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{k}} \]
      5. count-2-revN/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
      8. distribute-lft-inN/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      9. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
      12. sqrt-undivN/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
      14. lower-/.f6438.1

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

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

      \[\leadsto n \cdot \color{blue}{\sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}}} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}} \]
      2. lower-sqrt.f64N/A

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}} \]
      3. lower-*.f64N/A

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}} \]
      4. lower-/.f64N/A

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k \cdot n}} \]
      5. lower-PI.f64N/A

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\pi}{k \cdot n}} \]
      6. lower-*.f6449.4

        \[\leadsto n \cdot \sqrt{2 \cdot \frac{\pi}{k \cdot n}} \]
    9. Applied rewrites49.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 6: 49.5% accurate, 2.7× speedup?

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

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

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. 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. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
    2. lower-pow.f64N/A

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
    3. lower-*.f64N/A

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
    5. lower-PI.f64N/A

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

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

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

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
    2. lift-pow.f64N/A

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
    3. unpow1/2N/A

      \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{\color{blue}{k}}} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{k}} \]
    5. count-2-revN/A

      \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
    6. lift-*.f64N/A

      \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
    7. lift-*.f64N/A

      \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
    8. distribute-lft-inN/A

      \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
    9. lift-+.f64N/A

      \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
    10. lift-*.f64N/A

      \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
    11. lift-sqrt.f64N/A

      \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
    12. sqrt-undivN/A

      \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
    13. lower-sqrt.f64N/A

      \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
    14. lower-/.f6438.1

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

    \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
  7. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
    2. mult-flipN/A

      \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
    3. lift-*.f64N/A

      \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
    4. *-commutativeN/A

      \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
    5. lift-/.f64N/A

      \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
    6. associate-*l*N/A

      \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
    7. lower-*.f64N/A

      \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
    8. lift-/.f64N/A

      \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
    9. mult-flip-revN/A

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    10. lower-/.f6438.1

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
  8. Applied rewrites38.1%

    \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
  9. Step-by-step derivation
    1. lift-sqrt.f64N/A

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    2. lift-*.f64N/A

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    3. lift-/.f64N/A

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    4. lift-+.f64N/A

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    5. div-addN/A

      \[\leadsto \sqrt{\pi \cdot \left(\frac{n}{k} + \frac{n}{k}\right)} \]
    6. distribute-lft-inN/A

      \[\leadsto \sqrt{\pi \cdot \frac{n}{k} + \pi \cdot \frac{n}{k}} \]
    7. distribute-rgt-outN/A

      \[\leadsto \sqrt{\frac{n}{k} \cdot \left(\pi + \pi\right)} \]
    8. lift-+.f64N/A

      \[\leadsto \sqrt{\frac{n}{k} \cdot \left(\pi + \pi\right)} \]
    9. sqrt-unprodN/A

      \[\leadsto \sqrt{\frac{n}{k}} \cdot \color{blue}{\sqrt{\pi + \pi}} \]
    10. sqrt-undivN/A

      \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\color{blue}{\pi + \pi}} \]
    11. lift-sqrt.f64N/A

      \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\color{blue}{\pi} + \pi} \]
    12. lift-sqrt.f64N/A

      \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\pi + \color{blue}{\pi}} \]
    13. lift-sqrt.f64N/A

      \[\leadsto \frac{\sqrt{n}}{\sqrt{k}} \cdot \sqrt{\pi + \pi} \]
    14. associate-*l/N/A

      \[\leadsto \frac{\sqrt{n} \cdot \sqrt{\pi + \pi}}{\color{blue}{\sqrt{k}}} \]
    15. associate-/l*N/A

      \[\leadsto \sqrt{n} \cdot \color{blue}{\frac{\sqrt{\pi + \pi}}{\sqrt{k}}} \]
    16. lower-*.f64N/A

      \[\leadsto \sqrt{n} \cdot \color{blue}{\frac{\sqrt{\pi + \pi}}{\sqrt{k}}} \]
    17. lift-sqrt.f64N/A

      \[\leadsto \sqrt{n} \cdot \frac{\sqrt{\pi + \pi}}{\sqrt{\color{blue}{k}}} \]
    18. lift-sqrt.f64N/A

      \[\leadsto \sqrt{n} \cdot \frac{\sqrt{\pi + \pi}}{\sqrt{k}} \]
    19. sqrt-undivN/A

      \[\leadsto \sqrt{n} \cdot \sqrt{\frac{\pi + \pi}{k}} \]
    20. lower-sqrt.f64N/A

      \[\leadsto \sqrt{n} \cdot \sqrt{\frac{\pi + \pi}{k}} \]
  10. Applied rewrites49.5%

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

Alternative 7: 38.1% accurate, 3.1× speedup?

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

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

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. 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. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
    2. lower-pow.f64N/A

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
    3. lower-*.f64N/A

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}}{\sqrt{k}} \]
    5. lower-PI.f64N/A

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

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

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

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\color{blue}{\sqrt{k}}} \]
    2. lift-pow.f64N/A

      \[\leadsto \frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\frac{1}{2}}}{\sqrt{\color{blue}{k}}} \]
    3. unpow1/2N/A

      \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{\color{blue}{k}}} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \pi\right)}}{\sqrt{k}} \]
    5. count-2-revN/A

      \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
    6. lift-*.f64N/A

      \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
    7. lift-*.f64N/A

      \[\leadsto \frac{\sqrt{n \cdot \pi + n \cdot \pi}}{\sqrt{k}} \]
    8. distribute-lft-inN/A

      \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
    9. lift-+.f64N/A

      \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
    10. lift-*.f64N/A

      \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
    11. lift-sqrt.f64N/A

      \[\leadsto \frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{k}} \]
    12. sqrt-undivN/A

      \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
    13. lower-sqrt.f64N/A

      \[\leadsto \sqrt{\frac{n \cdot \left(\pi + \pi\right)}{k}} \]
    14. lower-/.f6438.1

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

    \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
  7. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \sqrt{\frac{\left(n + n\right) \cdot \pi}{k}} \]
    2. mult-flipN/A

      \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
    3. lift-*.f64N/A

      \[\leadsto \sqrt{\left(\left(n + n\right) \cdot \pi\right) \cdot \frac{1}{k}} \]
    4. *-commutativeN/A

      \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
    5. lift-/.f64N/A

      \[\leadsto \sqrt{\left(\pi \cdot \left(n + n\right)\right) \cdot \frac{1}{k}} \]
    6. associate-*l*N/A

      \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
    7. lower-*.f64N/A

      \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
    8. lift-/.f64N/A

      \[\leadsto \sqrt{\pi \cdot \left(\left(n + n\right) \cdot \frac{1}{k}\right)} \]
    9. mult-flip-revN/A

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
    10. lower-/.f6438.1

      \[\leadsto \sqrt{\pi \cdot \frac{n + n}{k}} \]
  8. Applied rewrites38.1%

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

Reproduce

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