Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.5%
Time: 10.7s
Alternatives: 7
Speedup: 1.1×

Specification

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

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

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 7 alternatives:

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

Initial Program: 99.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.9× speedup?

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

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

    \[\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. lift-sqrt.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 1.1× speedup?

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

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

    \[\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. lift-sqrt.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 50.4% accurate, 3.6× speedup?

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

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

    \[\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. *-commutativeN/A

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

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

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

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

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

      \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{n \cdot \mathsf{PI}\left(\right)}}{k}} \]
    7. lower-PI.f6441.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{n \cdot 2} \cdot \color{blue}{\sqrt{\frac{\mathsf{PI}\left(\right)}{k}}} \]
    18. lower-/.f6452.4

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

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

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

Alternative 4: 38.3% accurate, 4.0× speedup?

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

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

    \[\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. *-commutativeN/A

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

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

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

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

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

      \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{n \cdot \mathsf{PI}\left(\right)}}{k}} \]
    7. lower-PI.f6441.6

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{2 \cdot \frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
    6. lower-*.f6441.7

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

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

      \[\leadsto \sqrt{2 \cdot \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
    9. lift-*.f6441.7

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

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

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

      \[\leadsto \sqrt{2 \cdot \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
    3. remove-double-negN/A

      \[\leadsto \sqrt{2 \cdot \frac{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)}}{k}} \]
    4. remove-double-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\frac{n \cdot 2}{\frac{k}{\mathsf{PI}\left(\right)}}}} \]
    18. lower-/.f6441.8

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

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

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

Alternative 5: 38.3% accurate, 4.0× speedup?

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

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

    \[\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. *-commutativeN/A

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

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

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

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

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

      \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{n \cdot \mathsf{PI}\left(\right)}}{k}} \]
    7. lower-PI.f6441.6

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{2 \cdot \frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
    6. lower-*.f6441.7

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

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

      \[\leadsto \sqrt{2 \cdot \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
    9. lift-*.f6441.7

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

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

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

      \[\leadsto \sqrt{2 \cdot \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
    3. remove-double-negN/A

      \[\leadsto \sqrt{2 \cdot \frac{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)}}{k}} \]
    4. remove-double-negN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{\frac{2}{\frac{k}{\mathsf{PI}\left(\right) \cdot n}}}} \]
    14. lower-/.f6441.7

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

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

Alternative 6: 38.3% accurate, 4.8× speedup?

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

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

    \[\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. *-commutativeN/A

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

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

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

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

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

      \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{n \cdot \mathsf{PI}\left(\right)}}{k}} \]
    7. lower-PI.f6441.6

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{2 \cdot \frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
    6. lower-*.f6441.7

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

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

      \[\leadsto \sqrt{2 \cdot \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
    9. lift-*.f6441.7

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

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

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

      \[\leadsto \sqrt{2 \cdot \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
    3. remove-double-negN/A

      \[\leadsto \sqrt{2 \cdot \frac{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\mathsf{PI}\left(\right) \cdot n\right)\right)\right)}}{k}} \]
    4. remove-double-negN/A

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

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

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

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

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

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

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

      \[\leadsto \sqrt{2 \cdot \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot n\right)}} \]
    12. lower-/.f6441.7

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

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

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

Alternative 7: 38.3% accurate, 4.8× speedup?

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

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

    \[\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. *-commutativeN/A

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

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

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

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

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

      \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{n \cdot \mathsf{PI}\left(\right)}}{k}} \]
    7. lower-PI.f6441.6

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{2 \cdot \frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
    6. lower-*.f6441.7

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

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

      \[\leadsto \sqrt{2 \cdot \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
    9. lift-*.f6441.7

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

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

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

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

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

      \[\leadsto \sqrt{2 \cdot \color{blue}{\left(\frac{n}{k} \cdot \mathsf{PI}\left(\right)\right)}} \]
    5. lower-*.f6441.7

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

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

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

Reproduce

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