Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.5%
Time: 11.7s
Alternatives: 11
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 99.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_0 := \pi \cdot \left(2 \cdot n\right)\\
\frac{\sqrt{t\_0}}{\sqrt{k} \cdot {t\_0}^{\left(\frac{k}{2}\right)}}
\end{array}
\end{array}
Derivation
  1. Initial program 99.3%

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

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

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

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

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

      \[\leadsto \frac{\frac{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\frac{1}{2}}}{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}}}{\sqrt{\color{blue}{k}}} \]
    6. associate-/l/N/A

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

      \[\leadsto \mathsf{/.f64}\left(\left({\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\frac{1}{2}}\right), \color{blue}{\left(\sqrt{k} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)}\right) \]
    8. unpow1/2N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\sqrt{\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n}\right), \left(\color{blue}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    9. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)\right), \left(\color{blue}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    10. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right), \left(\sqrt{\color{blue}{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\left(\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\right)\right), \left(\sqrt{\color{blue}{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    12. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\left(\mathsf{PI}\left(\right) \cdot \left(n \cdot 2\right)\right)\right), \left(\sqrt{\color{blue}{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(n \cdot 2\right)\right)\right), \left(\sqrt{\color{blue}{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    14. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(n \cdot 2\right)\right)\right), \left(\sqrt{k} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    15. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(2 \cdot n\right)\right)\right), \left(\sqrt{k} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    16. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \left(\sqrt{k} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    17. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \mathsf{*.f64}\left(\left(\sqrt{k}\right), \color{blue}{\left({\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)}\right)\right) \]
    18. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(k\right), \left({\color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}}^{\left(\frac{k}{2}\right)}\right)\right)\right) \]
    19. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(k\right), \mathsf{pow.f64}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right), \color{blue}{\left(\frac{k}{2}\right)}\right)\right)\right) \]
  4. Applied egg-rr99.7%

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

Alternative 2: 54.9% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(\frac{\pi}{k \cdot \frac{k}{\pi}} \cdot \left(4 \cdot \left(n \cdot n\right)\right)\right)}^{0.25}\\


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

    1. Initial program 99.1%

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
      2. sqrt-lowering-sqrt.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      5. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      6. sqrt-lowering-sqrt.f6452.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
    5. Simplified52.7%

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

        \[\leadsto \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2} \]
      2. associate-*l/N/A

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

        \[\leadsto \sqrt{\frac{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}{k}} \]
      4. associate-*r*N/A

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

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

        \[\leadsto \frac{\sqrt{\mathsf{PI}\left(\right) \cdot \left(2 \cdot n\right)}}{\color{blue}{\sqrt{k}}} \]
      7. pow1/2N/A

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

        \[\leadsto \frac{\sqrt{\mathsf{PI}\left(\right) \cdot \left(2 \cdot n\right)}}{{k}^{\left(\mathsf{neg}\left(\frac{-1}{2}\right)\right)}} \]
      9. pow-flipN/A

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \left(\frac{1}{{k}^{\frac{-1}{2}}}\right)\right) \]
      15. pow-flipN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \left({k}^{\color{blue}{\left(\mathsf{neg}\left(\frac{-1}{2}\right)\right)}}\right)\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \left({k}^{\frac{1}{2}}\right)\right) \]
      17. pow1/2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \left(\sqrt{k}\right)\right) \]
      18. sqrt-lowering-sqrt.f6467.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \mathsf{sqrt.f64}\left(k\right)\right) \]
    7. Applied egg-rr67.5%

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

    if 6.70000000000000037e165 < k

    1. Initial program 100.0%

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
      2. sqrt-lowering-sqrt.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      5. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      6. sqrt-lowering-sqrt.f642.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
    5. Simplified2.9%

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{n \cdot \mathsf{PI}\left(\right)}} \cdot 2\right)\right) \]
      4. associate-*l/N/A

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right)\right)\right)\right) \]
      10. PI-lowering-PI.f642.9%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right)\right)\right)\right) \]
    7. Applied egg-rr2.9%

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

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

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\frac{2}{k}\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
      7. PI-lowering-PI.f642.9%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    9. Applied egg-rr2.9%

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

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

        \[\leadsto {\left(\mathsf{PI}\left(\right) \cdot \left(\frac{2}{k} \cdot n\right)\right)}^{\frac{1}{2}} \]
      3. associate-*l/N/A

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

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right) \cdot \left(2 \cdot n\right)}{k}\right)}^{\frac{1}{2}} \]
      5. associate-*l/N/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \left(2 \cdot n\right)\right)}^{\frac{1}{2}} \]
      6. pow-prod-downN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{2}} \cdot \color{blue}{{\left(2 \cdot n\right)}^{\frac{1}{2}}} \]
      7. sqr-powN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot {\color{blue}{\left(2 \cdot n\right)}}^{\frac{1}{2}} \]
      8. sqr-powN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot \color{blue}{{\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{4}} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      10. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      11. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{4}}\right) \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{\color{blue}{2}}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      12. metadata-evalN/A

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

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left(\color{blue}{{\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      14. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\frac{1}{4}} \cdot {\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      15. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      16. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\frac{1}{4}}\right) \]
      17. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
    11. Applied egg-rr37.1%

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

Alternative 3: 54.8% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(\frac{\pi}{k \cdot \frac{k}{\pi}} \cdot \left(4 \cdot \left(n \cdot n\right)\right)\right)}^{0.25}\\


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

    1. Initial program 99.1%

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
      2. sqrt-lowering-sqrt.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      5. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      6. sqrt-lowering-sqrt.f6452.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
    5. Simplified52.7%

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{n \cdot \mathsf{PI}\left(\right)}} \cdot 2\right)\right) \]
      4. associate-*l/N/A

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right)\right)\right)\right) \]
      10. PI-lowering-PI.f6452.8%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right)\right)\right)\right) \]
    7. Applied egg-rr52.8%

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

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

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\frac{2}{k}\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
      7. PI-lowering-PI.f6452.7%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    9. Applied egg-rr52.7%

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

        \[\leadsto \sqrt{\mathsf{PI}\left(\right) \cdot \left(\frac{2}{k} \cdot n\right)} \]
      2. associate-*l/N/A

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

        \[\leadsto \sqrt{\frac{\mathsf{PI}\left(\right) \cdot \left(2 \cdot n\right)}{k}} \]
      4. associate-*l/N/A

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

        \[\leadsto \sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot \left(n \cdot 2\right)} \]
      6. associate-*r*N/A

        \[\leadsto \sqrt{\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot n\right) \cdot 2} \]
      7. associate-/r/N/A

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

        \[\leadsto \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{\frac{k}{n}}} \]
      9. associate-/r/N/A

        \[\leadsto \sqrt{2 \cdot \left(\frac{\mathsf{PI}\left(\right)}{k} \cdot n\right)} \]
      10. associate-*r*N/A

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

        \[\leadsto \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k}} \cdot \color{blue}{\sqrt{n}} \]
      12. pow1/2N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(2 \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)\right), \left({\color{blue}{n}}^{\frac{1}{2}}\right)\right) \]
      15. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(2 \cdot \frac{1}{\frac{k}{\mathsf{PI}\left(\right)}}\right)\right), \left({n}^{\frac{1}{2}}\right)\right) \]
      16. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(\frac{2}{\frac{k}{\mathsf{PI}\left(\right)}}\right)\right), \left({n}^{\frac{1}{2}}\right)\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \left(\frac{k}{\mathsf{PI}\left(\right)}\right)\right)\right), \left({n}^{\frac{1}{2}}\right)\right) \]
      18. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{PI}\left(\right)\right)\right)\right), \left({n}^{\frac{1}{2}}\right)\right) \]
      19. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{PI.f64}\left(\right)\right)\right)\right), \left({n}^{\frac{1}{2}}\right)\right) \]
      20. pow1/2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{PI.f64}\left(\right)\right)\right)\right), \left(\sqrt{n}\right)\right) \]
      21. sqrt-lowering-sqrt.f6467.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{PI.f64}\left(\right)\right)\right)\right), \mathsf{sqrt.f64}\left(n\right)\right) \]
    11. Applied egg-rr67.3%

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

    if 6.70000000000000037e165 < k

    1. Initial program 100.0%

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
      2. sqrt-lowering-sqrt.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      5. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      6. sqrt-lowering-sqrt.f642.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
    5. Simplified2.9%

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{n \cdot \mathsf{PI}\left(\right)}} \cdot 2\right)\right) \]
      4. associate-*l/N/A

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right)\right)\right)\right) \]
      10. PI-lowering-PI.f642.9%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right)\right)\right)\right) \]
    7. Applied egg-rr2.9%

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

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

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\frac{2}{k}\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
      7. PI-lowering-PI.f642.9%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    9. Applied egg-rr2.9%

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

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

        \[\leadsto {\left(\mathsf{PI}\left(\right) \cdot \left(\frac{2}{k} \cdot n\right)\right)}^{\frac{1}{2}} \]
      3. associate-*l/N/A

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

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right) \cdot \left(2 \cdot n\right)}{k}\right)}^{\frac{1}{2}} \]
      5. associate-*l/N/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \left(2 \cdot n\right)\right)}^{\frac{1}{2}} \]
      6. pow-prod-downN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{2}} \cdot \color{blue}{{\left(2 \cdot n\right)}^{\frac{1}{2}}} \]
      7. sqr-powN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot {\color{blue}{\left(2 \cdot n\right)}}^{\frac{1}{2}} \]
      8. sqr-powN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot \color{blue}{{\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{4}} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      10. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      11. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{4}}\right) \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{\color{blue}{2}}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      12. metadata-evalN/A

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

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left(\color{blue}{{\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      14. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\frac{1}{4}} \cdot {\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      15. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      16. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\frac{1}{4}}\right) \]
      17. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
    11. Applied egg-rr37.1%

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

Alternative 4: 54.9% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(\frac{\pi}{k \cdot \frac{k}{\pi}} \cdot \left(4 \cdot \left(n \cdot n\right)\right)\right)}^{0.25}\\


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

    1. Initial program 99.1%

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
      2. sqrt-lowering-sqrt.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      5. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      6. sqrt-lowering-sqrt.f6452.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
    5. Simplified52.7%

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

        \[\leadsto \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2} \]
      2. associate-/l*N/A

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

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

        \[\leadsto \sqrt{n} \cdot \color{blue}{\sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot 2}} \]
      5. pow1/2N/A

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

        \[\leadsto \mathsf{*.f64}\left(\left({n}^{\frac{1}{2}}\right), \color{blue}{\left(\sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot 2}\right)}\right) \]
      7. pow1/2N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{n}\right), \left(\sqrt{\color{blue}{\frac{\mathsf{PI}\left(\right)}{k} \cdot 2}}\right)\right) \]
      8. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(n\right), \left(\sqrt{\color{blue}{\frac{\mathsf{PI}\left(\right)}{k} \cdot 2}}\right)\right) \]
      9. sqrt-lowering-sqrt.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(n\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\left(\frac{\mathsf{PI}\left(\right)}{k}\right), 2\right)\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(n\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI}\left(\right), k\right), 2\right)\right)\right) \]
      12. PI-lowering-PI.f6467.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(n\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), k\right), 2\right)\right)\right) \]
    7. Applied egg-rr67.3%

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

    if 6.70000000000000037e165 < k

    1. Initial program 100.0%

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
      2. sqrt-lowering-sqrt.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      5. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      6. sqrt-lowering-sqrt.f642.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
    5. Simplified2.9%

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{n \cdot \mathsf{PI}\left(\right)}} \cdot 2\right)\right) \]
      4. associate-*l/N/A

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right)\right)\right)\right) \]
      10. PI-lowering-PI.f642.9%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right)\right)\right)\right) \]
    7. Applied egg-rr2.9%

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

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

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\frac{2}{k}\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
      7. PI-lowering-PI.f642.9%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    9. Applied egg-rr2.9%

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

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

        \[\leadsto {\left(\mathsf{PI}\left(\right) \cdot \left(\frac{2}{k} \cdot n\right)\right)}^{\frac{1}{2}} \]
      3. associate-*l/N/A

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

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right) \cdot \left(2 \cdot n\right)}{k}\right)}^{\frac{1}{2}} \]
      5. associate-*l/N/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \left(2 \cdot n\right)\right)}^{\frac{1}{2}} \]
      6. pow-prod-downN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{2}} \cdot \color{blue}{{\left(2 \cdot n\right)}^{\frac{1}{2}}} \]
      7. sqr-powN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot {\color{blue}{\left(2 \cdot n\right)}}^{\frac{1}{2}} \]
      8. sqr-powN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot \color{blue}{{\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{4}} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      10. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      11. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{4}}\right) \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{\color{blue}{2}}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      12. metadata-evalN/A

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

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left(\color{blue}{{\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      14. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\frac{1}{4}} \cdot {\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      15. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      16. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\frac{1}{4}}\right) \]
      17. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
    11. Applied egg-rr37.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 6.7 \cdot 10^{+165}:\\ \;\;\;\;\sqrt{n} \cdot \sqrt{2 \cdot \frac{\pi}{k}}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\pi}{k \cdot \frac{k}{\pi}} \cdot \left(4 \cdot \left(n \cdot n\right)\right)\right)}^{0.25}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\frac{1}{2}}}{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}}}{\sqrt{\color{blue}{k}}} \]
    6. associate-/l/N/A

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

      \[\leadsto \mathsf{/.f64}\left(\left({\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\frac{1}{2}}\right), \color{blue}{\left(\sqrt{k} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)}\right) \]
    8. unpow1/2N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\sqrt{\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n}\right), \left(\color{blue}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    9. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)\right), \left(\color{blue}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    10. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right), \left(\sqrt{\color{blue}{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\left(\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\right)\right), \left(\sqrt{\color{blue}{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    12. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\left(\mathsf{PI}\left(\right) \cdot \left(n \cdot 2\right)\right)\right), \left(\sqrt{\color{blue}{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(n \cdot 2\right)\right)\right), \left(\sqrt{\color{blue}{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    14. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(n \cdot 2\right)\right)\right), \left(\sqrt{k} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    15. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(2 \cdot n\right)\right)\right), \left(\sqrt{k} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    16. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \left(\sqrt{k} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)\right) \]
    17. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \mathsf{*.f64}\left(\left(\sqrt{k}\right), \color{blue}{\left({\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{k}{2}\right)}\right)}\right)\right) \]
    18. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(k\right), \left({\color{blue}{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}}^{\left(\frac{k}{2}\right)}\right)\right)\right) \]
    19. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, n\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(k\right), \mathsf{pow.f64}\left(\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right), \color{blue}{\left(\frac{k}{2}\right)}\right)\right)\right) \]
  4. Applied egg-rr99.7%

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

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

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

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

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

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

      \[\leadsto \frac{\frac{{\left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot n\right)\right)}^{\frac{1}{2}}}{{\left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{k}{2}\right)}}}{\frac{1}{{k}^{\frac{-1}{2}}}} \]
    7. pow-subN/A

      \[\leadsto \frac{{\left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1}{2} - \frac{k}{2}\right)}}{\frac{\color{blue}{1}}{{k}^{\frac{-1}{2}}}} \]
    8. associate-*r*N/A

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

      \[\leadsto \frac{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1}{2} - \frac{k}{2}\right)}}{\frac{1}{{k}^{\frac{-1}{2}}}} \]
    10. metadata-evalN/A

      \[\leadsto \frac{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1}{2} - \frac{k}{2}\right)}}{\frac{1}{{k}^{\frac{-1}{2}}}} \]
    11. div-subN/A

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

      \[\leadsto \mathsf{/.f64}\left(\left({\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}\right), \color{blue}{\left(\frac{1}{{k}^{\frac{-1}{2}}}\right)}\right) \]
  6. Applied egg-rr99.4%

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

Alternative 6: 42.9% accurate, 1.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(\frac{\pi}{k \cdot \frac{k}{\pi}} \cdot \left(4 \cdot \left(n \cdot n\right)\right)\right)}^{0.25}\\


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

    1. Initial program 99.1%

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
      2. sqrt-lowering-sqrt.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      5. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      6. sqrt-lowering-sqrt.f6452.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
    5. Simplified52.7%

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{n \cdot \mathsf{PI}\left(\right)}} \cdot 2\right)\right) \]
      4. associate-*l/N/A

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right)\right)\right)\right) \]
      10. PI-lowering-PI.f6452.8%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right)\right)\right)\right) \]
    7. Applied egg-rr52.8%

      \[\leadsto \color{blue}{\sqrt{\frac{2}{\frac{k}{\pi \cdot n}}}} \]
    8. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{\frac{k}{\mathsf{PI}\left(\right) \cdot n}}{2}}\right)\right) \]
      2. associate-/r/N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{\mathsf{PI}\left(\right) \cdot n}} \cdot 2\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{\mathsf{PI}\left(\right) \cdot n}{k} \cdot 2\right)\right) \]
      4. associate-*l/N/A

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot n\right), 2\right)\right) \]
      6. associate-*l/N/A

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\mathsf{PI}\left(\right) \cdot n\right), k\right), 2\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right), k\right), 2\right)\right) \]
      9. PI-lowering-PI.f6452.8%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right), k\right), 2\right)\right) \]
    9. Applied egg-rr52.8%

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

    if 6.70000000000000037e165 < k

    1. Initial program 100.0%

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
      2. sqrt-lowering-sqrt.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      5. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
      6. sqrt-lowering-sqrt.f642.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
    5. Simplified2.9%

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{n \cdot \mathsf{PI}\left(\right)}} \cdot 2\right)\right) \]
      4. associate-*l/N/A

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right)\right)\right)\right) \]
      10. PI-lowering-PI.f642.9%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right)\right)\right)\right) \]
    7. Applied egg-rr2.9%

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

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

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\frac{2}{k}\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
      7. PI-lowering-PI.f642.9%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    9. Applied egg-rr2.9%

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

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

        \[\leadsto {\left(\mathsf{PI}\left(\right) \cdot \left(\frac{2}{k} \cdot n\right)\right)}^{\frac{1}{2}} \]
      3. associate-*l/N/A

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

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right) \cdot \left(2 \cdot n\right)}{k}\right)}^{\frac{1}{2}} \]
      5. associate-*l/N/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \left(2 \cdot n\right)\right)}^{\frac{1}{2}} \]
      6. pow-prod-downN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{2}} \cdot \color{blue}{{\left(2 \cdot n\right)}^{\frac{1}{2}}} \]
      7. sqr-powN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot {\color{blue}{\left(2 \cdot n\right)}}^{\frac{1}{2}} \]
      8. sqr-powN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot \color{blue}{{\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{4}} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      10. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \cdot \left({\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      11. metadata-evalN/A

        \[\leadsto \left({\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{PI}\left(\right)}{k}\right)}^{\frac{1}{4}}\right) \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{\color{blue}{2}}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      12. metadata-evalN/A

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

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left(\color{blue}{{\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}} \cdot {\left(2 \cdot n\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      14. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\frac{1}{4}} \cdot {\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      15. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot \color{blue}{n}\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right) \]
      16. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\frac{1}{4}}\right) \]
      17. metadata-evalN/A

        \[\leadsto {\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \frac{\mathsf{PI}\left(\right)}{k}\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot \left({\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \frac{-1}{2}\right)} \cdot {\left(2 \cdot n\right)}^{\left(\frac{-1}{2} \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
    11. Applied egg-rr37.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 6.7 \cdot 10^{+165}:\\ \;\;\;\;\sqrt{2 \cdot \frac{\pi \cdot n}{k}}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\pi}{k \cdot \frac{k}{\pi}} \cdot \left(4 \cdot \left(n \cdot n\right)\right)\right)}^{0.25}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 37.6% accurate, 2.0× speedup?

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
    2. sqrt-lowering-sqrt.f64N/A

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    5. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    6. sqrt-lowering-sqrt.f6442.6%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
  5. Simplified42.6%

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2\right)\right) \]
    3. clear-numN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{n \cdot \mathsf{PI}\left(\right)}} \cdot 2\right)\right) \]
    4. associate-*l/N/A

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

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right)\right)\right)\right) \]
    10. PI-lowering-PI.f6442.7%

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right)\right)\right)\right) \]
  7. Applied egg-rr42.7%

    \[\leadsto \color{blue}{\sqrt{\frac{2}{\frac{k}{\pi \cdot n}}}} \]
  8. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{\frac{k}{\mathsf{PI}\left(\right) \cdot n}}{2}}\right)\right) \]
    2. associate-/r/N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{\mathsf{PI}\left(\right) \cdot n}} \cdot 2\right)\right) \]
    3. clear-numN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{\mathsf{PI}\left(\right) \cdot n}{k} \cdot 2\right)\right) \]
    4. associate-*l/N/A

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot n\right), 2\right)\right) \]
    6. associate-*l/N/A

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\mathsf{PI}\left(\right) \cdot n\right), k\right), 2\right)\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right), k\right), 2\right)\right) \]
    9. PI-lowering-PI.f6442.7%

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right), k\right), 2\right)\right) \]
  9. Applied egg-rr42.7%

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

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

Alternative 8: 37.6% accurate, 2.0× speedup?

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
    2. sqrt-lowering-sqrt.f64N/A

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    5. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    6. sqrt-lowering-sqrt.f6442.6%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
  5. Simplified42.6%

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2\right)\right) \]
    3. clear-numN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{n \cdot \mathsf{PI}\left(\right)}} \cdot 2\right)\right) \]
    4. associate-*l/N/A

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

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right)\right)\right)\right) \]
    10. PI-lowering-PI.f6442.7%

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right)\right)\right)\right) \]
  7. Applied egg-rr42.7%

    \[\leadsto \color{blue}{\sqrt{\frac{2}{\frac{k}{\pi \cdot n}}}} \]
  8. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{\frac{k}{\mathsf{PI}\left(\right) \cdot n}}{2}}\right)\right) \]
    2. associate-/r/N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{\mathsf{PI}\left(\right) \cdot n}} \cdot 2\right)\right) \]
    3. clear-numN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{\mathsf{PI}\left(\right) \cdot n}{k} \cdot 2\right)\right) \]
    4. associate-*l/N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot n\right) \cdot 2\right)\right) \]
    5. associate-*l*N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot \left(n \cdot 2\right)\right)\right) \]
    6. *-commutativeN/A

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI}\left(\right), k\right), \left(2 \cdot n\right)\right)\right) \]
    9. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), k\right), \left(2 \cdot n\right)\right)\right) \]
    10. *-lowering-*.f6442.7%

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), k\right), \mathsf{*.f64}\left(2, n\right)\right)\right) \]
  9. Applied egg-rr42.7%

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

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

Alternative 9: 37.6% accurate, 2.0× speedup?

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
    2. sqrt-lowering-sqrt.f64N/A

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    5. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    6. sqrt-lowering-sqrt.f6442.6%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
  5. Simplified42.6%

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2\right)\right) \]
    3. clear-numN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{n \cdot \mathsf{PI}\left(\right)}} \cdot 2\right)\right) \]
    4. associate-*l/N/A

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

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right)\right)\right)\right) \]
    10. PI-lowering-PI.f6442.7%

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right)\right)\right)\right) \]
  7. Applied egg-rr42.7%

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

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

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

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\frac{2}{k}\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
    6. /-lowering-/.f64N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
    7. PI-lowering-PI.f6442.6%

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
  9. Applied egg-rr42.6%

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\left(n \cdot \frac{2}{k}\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    2. clear-numN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\left(n \cdot \frac{1}{\frac{k}{2}}\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    3. associate-*r/N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\left(\frac{n \cdot 1}{\frac{k}{2}}\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    4. div-invN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\left(\frac{n \cdot 1}{k \cdot \frac{1}{2}}\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\left(\frac{n \cdot 1}{k \cdot \frac{1}{2}}\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    6. times-fracN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\left(\frac{n}{k} \cdot \frac{1}{\frac{1}{2}}\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    7. metadata-evalN/A

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\frac{n}{k}\right), 2\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
    9. /-lowering-/.f6442.7%

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(n, k\right), 2\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
  11. Applied egg-rr42.7%

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

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

Alternative 10: 37.6% accurate, 2.0× speedup?

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
    2. sqrt-lowering-sqrt.f64N/A

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    5. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    6. sqrt-lowering-sqrt.f6442.6%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
  5. Simplified42.6%

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2\right)\right) \]
    3. clear-numN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{n \cdot \mathsf{PI}\left(\right)}} \cdot 2\right)\right) \]
    4. associate-*l/N/A

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

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right)\right)\right)\right) \]
    10. PI-lowering-PI.f6442.7%

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right)\right)\right)\right) \]
  7. Applied egg-rr42.7%

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

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{2}{k} \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right) \]
    2. associate-*r*N/A

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\frac{2}{k}\right), \mathsf{PI}\left(\right)\right), n\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), \mathsf{PI}\left(\right)\right), n\right)\right) \]
    6. PI-lowering-PI.f6442.6%

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), \mathsf{PI.f64}\left(\right)\right), n\right)\right) \]
  9. Applied egg-rr42.6%

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

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

Alternative 11: 37.6% accurate, 2.0× speedup?

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}\right), \color{blue}{\left(\sqrt{2}\right)}\right) \]
    2. sqrt-lowering-sqrt.f64N/A

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\left(n \cdot \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    5. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \left(\sqrt{2}\right)\right) \]
    6. sqrt-lowering-sqrt.f6442.6%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(n, \mathsf{PI.f64}\left(\right)\right), k\right)\right), \mathsf{sqrt.f64}\left(2\right)\right) \]
  5. Simplified42.6%

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2\right)\right) \]
    3. clear-numN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{\frac{k}{n \cdot \mathsf{PI}\left(\right)}} \cdot 2\right)\right) \]
    4. associate-*l/N/A

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

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), n\right)\right)\right)\right) \]
    10. PI-lowering-PI.f6442.7%

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(2, \mathsf{/.f64}\left(k, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), n\right)\right)\right)\right) \]
  7. Applied egg-rr42.7%

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

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

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

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

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

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\frac{2}{k}\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
    6. /-lowering-/.f64N/A

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI}\left(\right)\right)\right) \]
    7. PI-lowering-PI.f6442.6%

      \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(2, k\right), n\right), \mathsf{PI.f64}\left(\right)\right)\right) \]
  9. Applied egg-rr42.6%

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

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

Reproduce

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