Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.5%
Time: 7.3s
Alternatives: 8
Speedup: N/A×

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 8 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, N/A× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\color{blue}{\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)}}{\sqrt{k}}} \]
    11. lower-/.f64N/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)}}{\sqrt{k}}} \]
  4. Applied rewrites99.6%

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

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

Alternative 2: 99.5% accurate, N/A× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.4% accurate, N/A× 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}
Derivation
  1. Initial program 99.5%

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

Alternative 4: 99.3% accurate, N/A× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 91.4% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\sqrt{k}}\\ t_1 := {\left(\pi \cdot n\right)}^{0.5}\\ t_2 := \frac{1 - k}{2}\\ t_3 := t\_1 \cdot {k}^{0.5}\\ t_4 := \log \left(n \cdot \left(\pi \cdot 2\right)\right)\\ \mathbf{if}\;t\_0 \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{t\_2} \leq 5 \cdot 10^{-41}:\\ \;\;\;\;t\_0 \cdot \left({\left(\pi \cdot 2\right)}^{t\_2} \cdot {n}^{t\_2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left({2}^{0.5}, t\_3, \mathsf{fma}\left(\mathsf{fma}\left(\left(\left(-0.020833333333333332 \cdot {\left({k}^{3}\right)}^{0.5}\right) \cdot t\_1\right) \cdot \left(\left(t\_4 \cdot t\_4\right) \cdot t\_4\right), {2}^{0.5}, \left(t\_3 \cdot 0.125\right) \cdot \left(t\_4 \cdot \left({2}^{0.5} \cdot t\_4\right)\right)\right), k, \left(\left(t\_3 \cdot -0.5\right) \cdot t\_4\right) \cdot {2}^{0.5}\right) \cdot k\right)}{k}\\ \end{array} \end{array} \]
(FPCore (k n)
 :precision binary64
 (let* ((t_0 (/ 1.0 (sqrt k)))
        (t_1 (pow (* PI n) 0.5))
        (t_2 (/ (- 1.0 k) 2.0))
        (t_3 (* t_1 (pow k 0.5)))
        (t_4 (log (* n (* PI 2.0)))))
   (if (<= (* t_0 (pow (* (* 2.0 PI) n) t_2)) 5e-41)
     (* t_0 (* (pow (* PI 2.0) t_2) (pow n t_2)))
     (/
      (fma
       (pow 2.0 0.5)
       t_3
       (*
        (fma
         (fma
          (*
           (* (* -0.020833333333333332 (pow (pow k 3.0) 0.5)) t_1)
           (* (* t_4 t_4) t_4))
          (pow 2.0 0.5)
          (* (* t_3 0.125) (* t_4 (* (pow 2.0 0.5) t_4))))
         k
         (* (* (* t_3 -0.5) t_4) (pow 2.0 0.5)))
        k))
      k))))
double code(double k, double n) {
	double t_0 = 1.0 / sqrt(k);
	double t_1 = pow((((double) M_PI) * n), 0.5);
	double t_2 = (1.0 - k) / 2.0;
	double t_3 = t_1 * pow(k, 0.5);
	double t_4 = log((n * (((double) M_PI) * 2.0)));
	double tmp;
	if ((t_0 * pow(((2.0 * ((double) M_PI)) * n), t_2)) <= 5e-41) {
		tmp = t_0 * (pow((((double) M_PI) * 2.0), t_2) * pow(n, t_2));
	} else {
		tmp = fma(pow(2.0, 0.5), t_3, (fma(fma((((-0.020833333333333332 * pow(pow(k, 3.0), 0.5)) * t_1) * ((t_4 * t_4) * t_4)), pow(2.0, 0.5), ((t_3 * 0.125) * (t_4 * (pow(2.0, 0.5) * t_4)))), k, (((t_3 * -0.5) * t_4) * pow(2.0, 0.5))) * k)) / k;
	}
	return tmp;
}
function code(k, n)
	t_0 = Float64(1.0 / sqrt(k))
	t_1 = Float64(pi * n) ^ 0.5
	t_2 = Float64(Float64(1.0 - k) / 2.0)
	t_3 = Float64(t_1 * (k ^ 0.5))
	t_4 = log(Float64(n * Float64(pi * 2.0)))
	tmp = 0.0
	if (Float64(t_0 * (Float64(Float64(2.0 * pi) * n) ^ t_2)) <= 5e-41)
		tmp = Float64(t_0 * Float64((Float64(pi * 2.0) ^ t_2) * (n ^ t_2)));
	else
		tmp = Float64(fma((2.0 ^ 0.5), t_3, Float64(fma(fma(Float64(Float64(Float64(-0.020833333333333332 * ((k ^ 3.0) ^ 0.5)) * t_1) * Float64(Float64(t_4 * t_4) * t_4)), (2.0 ^ 0.5), Float64(Float64(t_3 * 0.125) * Float64(t_4 * Float64((2.0 ^ 0.5) * t_4)))), k, Float64(Float64(Float64(t_3 * -0.5) * t_4) * (2.0 ^ 0.5))) * k)) / k);
	end
	return tmp
end
code[k_, n_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(Pi * n), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * N[Power[k, 0.5], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Log[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$0 * N[Power[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], t$95$2], $MachinePrecision]), $MachinePrecision], 5e-41], N[(t$95$0 * N[(N[Power[N[(Pi * 2.0), $MachinePrecision], t$95$2], $MachinePrecision] * N[Power[n, t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[2.0, 0.5], $MachinePrecision] * t$95$3 + N[(N[(N[(N[(N[(N[(-0.020833333333333332 * N[Power[N[Power[k, 3.0], $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(N[(t$95$4 * t$95$4), $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision] + N[(N[(t$95$3 * 0.125), $MachinePrecision] * N[(t$95$4 * N[(N[Power[2.0, 0.5], $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * k + N[(N[(N[(t$95$3 * -0.5), $MachinePrecision] * t$95$4), $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{k}}\\
t_1 := {\left(\pi \cdot n\right)}^{0.5}\\
t_2 := \frac{1 - k}{2}\\
t_3 := t\_1 \cdot {k}^{0.5}\\
t_4 := \log \left(n \cdot \left(\pi \cdot 2\right)\right)\\
\mathbf{if}\;t\_0 \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{t\_2} \leq 5 \cdot 10^{-41}:\\
\;\;\;\;t\_0 \cdot \left({\left(\pi \cdot 2\right)}^{t\_2} \cdot {n}^{t\_2}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left({2}^{0.5}, t\_3, \mathsf{fma}\left(\mathsf{fma}\left(\left(\left(-0.020833333333333332 \cdot {\left({k}^{3}\right)}^{0.5}\right) \cdot t\_1\right) \cdot \left(\left(t\_4 \cdot t\_4\right) \cdot t\_4\right), {2}^{0.5}, \left(t\_3 \cdot 0.125\right) \cdot \left(t\_4 \cdot \left({2}^{0.5} \cdot t\_4\right)\right)\right), k, \left(\left(t\_3 \cdot -0.5\right) \cdot t\_4\right) \cdot {2}^{0.5}\right) \cdot k\right)}{k}\\


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.4%

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

      \[\leadsto \color{blue}{\frac{k \cdot \left(\frac{-1}{2} \cdot \left(\sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \left(\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)\right) + k \cdot \left(\frac{-1}{48} \cdot \left(\sqrt{{k}^{3} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \left({\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{3} \cdot \sqrt{2}\right)\right) + \frac{1}{8} \cdot \left(\sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \left({\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \sqrt{2}\right)\right)\right)\right) + \sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \sqrt{2}}{k}} \]
    4. Applied rewrites73.6%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.020833333333333332 \cdot \left(\sqrt{{k}^{3}} \cdot {\left(\pi \cdot n\right)}^{0.5}\right), \left(\left(\log \left(\left(\pi \cdot 2\right) \cdot n\right) \cdot \log \left(\left(\pi \cdot 2\right) \cdot n\right)\right) \cdot \log \left(\left(\pi \cdot 2\right) \cdot n\right)\right) \cdot {2}^{0.5}, \left(0.125 \cdot {\left(\left(\pi \cdot n\right) \cdot k\right)}^{0.5}\right) \cdot \left(\left(\log \left(\left(\pi \cdot 2\right) \cdot n\right) \cdot \log \left(\left(\pi \cdot 2\right) \cdot n\right)\right) \cdot {2}^{0.5}\right)\right), k, \left(-0.5 \cdot {\left(\left(\pi \cdot n\right) \cdot k\right)}^{0.5}\right) \cdot \left(\log \left(\left(\pi \cdot 2\right) \cdot n\right) \cdot {2}^{0.5}\right)\right), k, {\left(\left(\pi \cdot n\right) \cdot k\right)}^{0.5} \cdot {2}^{0.5}\right)}{k}} \]
    5. Applied rewrites87.4%

      \[\leadsto \frac{\mathsf{fma}\left({2}^{0.5}, {\left(\pi \cdot n\right)}^{0.5} \cdot {k}^{0.5}, \mathsf{fma}\left(\mathsf{fma}\left(\left(\left(-0.020833333333333332 \cdot {\left({k}^{3}\right)}^{0.5}\right) \cdot {\left(\pi \cdot n\right)}^{0.5}\right) \cdot \left(\left(\log \left(n \cdot \left(\pi \cdot 2\right)\right) \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right) \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right), {2}^{0.5}, \left(\left({\left(\pi \cdot n\right)}^{0.5} \cdot {k}^{0.5}\right) \cdot 0.125\right) \cdot \left(\log \left(n \cdot \left(\pi \cdot 2\right)\right) \cdot \left({2}^{0.5} \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right)\right)\right), k, \left(\left(\left({\left(\pi \cdot n\right)}^{0.5} \cdot {k}^{0.5}\right) \cdot -0.5\right) \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right) \cdot {2}^{0.5}\right) \cdot k\right)}{k} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 91.1% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\pi \cdot n\right)}^{0.5}\\ t_1 := \frac{1}{\sqrt{k}}\\ t_2 := \frac{1 - k}{2}\\ t_3 := t\_0 \cdot {k}^{0.5}\\ t_4 := \log \left(n \cdot \left(\pi \cdot 2\right)\right)\\ \mathbf{if}\;t\_1 \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{t\_2} \leq 5 \cdot 10^{-65}:\\ \;\;\;\;t\_1 \cdot \left({\left(\pi \cdot 2\right)}^{\left(\frac{\left({k}^{-1} - 1\right) \cdot k}{2}\right)} \cdot e^{\log n \cdot t\_2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left({2}^{0.5}, t\_3, \mathsf{fma}\left(\mathsf{fma}\left(\left(\left(-0.020833333333333332 \cdot {\left({k}^{3}\right)}^{0.5}\right) \cdot t\_0\right) \cdot \left(\left(t\_4 \cdot t\_4\right) \cdot t\_4\right), {2}^{0.5}, \left(t\_3 \cdot 0.125\right) \cdot \left(t\_4 \cdot \left({2}^{0.5} \cdot t\_4\right)\right)\right), k, \left(\left(t\_3 \cdot -0.5\right) \cdot t\_4\right) \cdot {2}^{0.5}\right) \cdot k\right)}{k}\\ \end{array} \end{array} \]
(FPCore (k n)
 :precision binary64
 (let* ((t_0 (pow (* PI n) 0.5))
        (t_1 (/ 1.0 (sqrt k)))
        (t_2 (/ (- 1.0 k) 2.0))
        (t_3 (* t_0 (pow k 0.5)))
        (t_4 (log (* n (* PI 2.0)))))
   (if (<= (* t_1 (pow (* (* 2.0 PI) n) t_2)) 5e-65)
     (*
      t_1
      (*
       (pow (* PI 2.0) (/ (* (- (pow k -1.0) 1.0) k) 2.0))
       (exp (* (log n) t_2))))
     (/
      (fma
       (pow 2.0 0.5)
       t_3
       (*
        (fma
         (fma
          (*
           (* (* -0.020833333333333332 (pow (pow k 3.0) 0.5)) t_0)
           (* (* t_4 t_4) t_4))
          (pow 2.0 0.5)
          (* (* t_3 0.125) (* t_4 (* (pow 2.0 0.5) t_4))))
         k
         (* (* (* t_3 -0.5) t_4) (pow 2.0 0.5)))
        k))
      k))))
double code(double k, double n) {
	double t_0 = pow((((double) M_PI) * n), 0.5);
	double t_1 = 1.0 / sqrt(k);
	double t_2 = (1.0 - k) / 2.0;
	double t_3 = t_0 * pow(k, 0.5);
	double t_4 = log((n * (((double) M_PI) * 2.0)));
	double tmp;
	if ((t_1 * pow(((2.0 * ((double) M_PI)) * n), t_2)) <= 5e-65) {
		tmp = t_1 * (pow((((double) M_PI) * 2.0), (((pow(k, -1.0) - 1.0) * k) / 2.0)) * exp((log(n) * t_2)));
	} else {
		tmp = fma(pow(2.0, 0.5), t_3, (fma(fma((((-0.020833333333333332 * pow(pow(k, 3.0), 0.5)) * t_0) * ((t_4 * t_4) * t_4)), pow(2.0, 0.5), ((t_3 * 0.125) * (t_4 * (pow(2.0, 0.5) * t_4)))), k, (((t_3 * -0.5) * t_4) * pow(2.0, 0.5))) * k)) / k;
	}
	return tmp;
}
function code(k, n)
	t_0 = Float64(pi * n) ^ 0.5
	t_1 = Float64(1.0 / sqrt(k))
	t_2 = Float64(Float64(1.0 - k) / 2.0)
	t_3 = Float64(t_0 * (k ^ 0.5))
	t_4 = log(Float64(n * Float64(pi * 2.0)))
	tmp = 0.0
	if (Float64(t_1 * (Float64(Float64(2.0 * pi) * n) ^ t_2)) <= 5e-65)
		tmp = Float64(t_1 * Float64((Float64(pi * 2.0) ^ Float64(Float64(Float64((k ^ -1.0) - 1.0) * k) / 2.0)) * exp(Float64(log(n) * t_2))));
	else
		tmp = Float64(fma((2.0 ^ 0.5), t_3, Float64(fma(fma(Float64(Float64(Float64(-0.020833333333333332 * ((k ^ 3.0) ^ 0.5)) * t_0) * Float64(Float64(t_4 * t_4) * t_4)), (2.0 ^ 0.5), Float64(Float64(t_3 * 0.125) * Float64(t_4 * Float64((2.0 ^ 0.5) * t_4)))), k, Float64(Float64(Float64(t_3 * -0.5) * t_4) * (2.0 ^ 0.5))) * k)) / k);
	end
	return tmp
end
code[k_, n_] := Block[{t$95$0 = N[Power[N[(Pi * n), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[Power[k, 0.5], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Log[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$1 * N[Power[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], t$95$2], $MachinePrecision]), $MachinePrecision], 5e-65], N[(t$95$1 * N[(N[Power[N[(Pi * 2.0), $MachinePrecision], N[(N[(N[(N[Power[k, -1.0], $MachinePrecision] - 1.0), $MachinePrecision] * k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[Log[n], $MachinePrecision] * t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[2.0, 0.5], $MachinePrecision] * t$95$3 + N[(N[(N[(N[(N[(N[(-0.020833333333333332 * N[Power[N[Power[k, 3.0], $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(N[(t$95$4 * t$95$4), $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision] + N[(N[(t$95$3 * 0.125), $MachinePrecision] * N[(t$95$4 * N[(N[Power[2.0, 0.5], $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * k + N[(N[(N[(t$95$3 * -0.5), $MachinePrecision] * t$95$4), $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\pi \cdot n\right)}^{0.5}\\
t_1 := \frac{1}{\sqrt{k}}\\
t_2 := \frac{1 - k}{2}\\
t_3 := t\_0 \cdot {k}^{0.5}\\
t_4 := \log \left(n \cdot \left(\pi \cdot 2\right)\right)\\
\mathbf{if}\;t\_1 \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{t\_2} \leq 5 \cdot 10^{-65}:\\
\;\;\;\;t\_1 \cdot \left({\left(\pi \cdot 2\right)}^{\left(\frac{\left({k}^{-1} - 1\right) \cdot k}{2}\right)} \cdot e^{\log n \cdot t\_2}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left({2}^{0.5}, t\_3, \mathsf{fma}\left(\mathsf{fma}\left(\left(\left(-0.020833333333333332 \cdot {\left({k}^{3}\right)}^{0.5}\right) \cdot t\_0\right) \cdot \left(\left(t\_4 \cdot t\_4\right) \cdot t\_4\right), {2}^{0.5}, \left(t\_3 \cdot 0.125\right) \cdot \left(t\_4 \cdot \left({2}^{0.5} \cdot t\_4\right)\right)\right), k, \left(\left(t\_3 \cdot -0.5\right) \cdot t\_4\right) \cdot {2}^{0.5}\right) \cdot k\right)}{k}\\


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{k}} \cdot \left({\left(\pi \cdot 2\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \color{blue}{e^{\log n \cdot \frac{1 - k}{2}}}\right) \]
    7. Taylor expanded in k around inf

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

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

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

        \[\leadsto \frac{1}{\sqrt{k}} \cdot \left({\left(\pi \cdot 2\right)}^{\left(\frac{\left(\frac{1}{k} - 1\right) \cdot k}{2}\right)} \cdot e^{\log n \cdot \frac{1 - k}{2}}\right) \]
      4. inv-powN/A

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

        \[\leadsto \frac{1}{\sqrt{k}} \cdot \left({\left(\pi \cdot 2\right)}^{\left(\frac{\left({k}^{-1} - 1\right) \cdot k}{2}\right)} \cdot e^{\log n \cdot \frac{1 - k}{2}}\right) \]
    9. Applied rewrites99.1%

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

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

    1. Initial program 99.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}{\frac{k \cdot \left(\frac{-1}{2} \cdot \left(\sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \left(\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)\right) + k \cdot \left(\frac{-1}{48} \cdot \left(\sqrt{{k}^{3} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \left({\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{3} \cdot \sqrt{2}\right)\right) + \frac{1}{8} \cdot \left(\sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \left({\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \sqrt{2}\right)\right)\right)\right) + \sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \sqrt{2}}{k}} \]
    4. Applied rewrites72.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.020833333333333332 \cdot \left(\sqrt{{k}^{3}} \cdot {\left(\pi \cdot n\right)}^{0.5}\right), \left(\left(\log \left(\left(\pi \cdot 2\right) \cdot n\right) \cdot \log \left(\left(\pi \cdot 2\right) \cdot n\right)\right) \cdot \log \left(\left(\pi \cdot 2\right) \cdot n\right)\right) \cdot {2}^{0.5}, \left(0.125 \cdot {\left(\left(\pi \cdot n\right) \cdot k\right)}^{0.5}\right) \cdot \left(\left(\log \left(\left(\pi \cdot 2\right) \cdot n\right) \cdot \log \left(\left(\pi \cdot 2\right) \cdot n\right)\right) \cdot {2}^{0.5}\right)\right), k, \left(-0.5 \cdot {\left(\left(\pi \cdot n\right) \cdot k\right)}^{0.5}\right) \cdot \left(\log \left(\left(\pi \cdot 2\right) \cdot n\right) \cdot {2}^{0.5}\right)\right), k, {\left(\left(\pi \cdot n\right) \cdot k\right)}^{0.5} \cdot {2}^{0.5}\right)}{k}} \]
    5. Applied rewrites87.6%

      \[\leadsto \frac{\mathsf{fma}\left({2}^{0.5}, {\left(\pi \cdot n\right)}^{0.5} \cdot {k}^{0.5}, \mathsf{fma}\left(\mathsf{fma}\left(\left(\left(-0.020833333333333332 \cdot {\left({k}^{3}\right)}^{0.5}\right) \cdot {\left(\pi \cdot n\right)}^{0.5}\right) \cdot \left(\left(\log \left(n \cdot \left(\pi \cdot 2\right)\right) \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right) \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right), {2}^{0.5}, \left(\left({\left(\pi \cdot n\right)}^{0.5} \cdot {k}^{0.5}\right) \cdot 0.125\right) \cdot \left(\log \left(n \cdot \left(\pi \cdot 2\right)\right) \cdot \left({2}^{0.5} \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right)\right)\right), k, \left(\left(\left({\left(\pi \cdot n\right)}^{0.5} \cdot {k}^{0.5}\right) \cdot -0.5\right) \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right) \cdot {2}^{0.5}\right) \cdot k\right)}{k} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 66.4% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\pi \cdot n\right)}^{0.5}\\ t_1 := t\_0 \cdot {k}^{0.5}\\ t_2 := \log \left(n \cdot \left(\pi \cdot 2\right)\right)\\ \frac{\mathsf{fma}\left({2}^{0.5}, t\_1, \mathsf{fma}\left(\mathsf{fma}\left(\left(\left(-0.020833333333333332 \cdot {\left({k}^{3}\right)}^{0.5}\right) \cdot t\_0\right) \cdot \left(\left(t\_2 \cdot t\_2\right) \cdot t\_2\right), {2}^{0.5}, \left(t\_1 \cdot 0.125\right) \cdot \left(t\_2 \cdot \left({2}^{0.5} \cdot t\_2\right)\right)\right), k, \left(\left(t\_1 \cdot -0.5\right) \cdot t\_2\right) \cdot {2}^{0.5}\right) \cdot k\right)}{k} \end{array} \end{array} \]
(FPCore (k n)
 :precision binary64
 (let* ((t_0 (pow (* PI n) 0.5))
        (t_1 (* t_0 (pow k 0.5)))
        (t_2 (log (* n (* PI 2.0)))))
   (/
    (fma
     (pow 2.0 0.5)
     t_1
     (*
      (fma
       (fma
        (*
         (* (* -0.020833333333333332 (pow (pow k 3.0) 0.5)) t_0)
         (* (* t_2 t_2) t_2))
        (pow 2.0 0.5)
        (* (* t_1 0.125) (* t_2 (* (pow 2.0 0.5) t_2))))
       k
       (* (* (* t_1 -0.5) t_2) (pow 2.0 0.5)))
      k))
    k)))
double code(double k, double n) {
	double t_0 = pow((((double) M_PI) * n), 0.5);
	double t_1 = t_0 * pow(k, 0.5);
	double t_2 = log((n * (((double) M_PI) * 2.0)));
	return fma(pow(2.0, 0.5), t_1, (fma(fma((((-0.020833333333333332 * pow(pow(k, 3.0), 0.5)) * t_0) * ((t_2 * t_2) * t_2)), pow(2.0, 0.5), ((t_1 * 0.125) * (t_2 * (pow(2.0, 0.5) * t_2)))), k, (((t_1 * -0.5) * t_2) * pow(2.0, 0.5))) * k)) / k;
}
function code(k, n)
	t_0 = Float64(pi * n) ^ 0.5
	t_1 = Float64(t_0 * (k ^ 0.5))
	t_2 = log(Float64(n * Float64(pi * 2.0)))
	return Float64(fma((2.0 ^ 0.5), t_1, Float64(fma(fma(Float64(Float64(Float64(-0.020833333333333332 * ((k ^ 3.0) ^ 0.5)) * t_0) * Float64(Float64(t_2 * t_2) * t_2)), (2.0 ^ 0.5), Float64(Float64(t_1 * 0.125) * Float64(t_2 * Float64((2.0 ^ 0.5) * t_2)))), k, Float64(Float64(Float64(t_1 * -0.5) * t_2) * (2.0 ^ 0.5))) * k)) / k)
end
code[k_, n_] := Block[{t$95$0 = N[Power[N[(Pi * n), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Power[k, 0.5], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Log[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[Power[2.0, 0.5], $MachinePrecision] * t$95$1 + N[(N[(N[(N[(N[(N[(-0.020833333333333332 * N[Power[N[Power[k, 3.0], $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(N[(t$95$2 * t$95$2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision] + N[(N[(t$95$1 * 0.125), $MachinePrecision] * N[(t$95$2 * N[(N[Power[2.0, 0.5], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * k + N[(N[(N[(t$95$1 * -0.5), $MachinePrecision] * t$95$2), $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\pi \cdot n\right)}^{0.5}\\
t_1 := t\_0 \cdot {k}^{0.5}\\
t_2 := \log \left(n \cdot \left(\pi \cdot 2\right)\right)\\
\frac{\mathsf{fma}\left({2}^{0.5}, t\_1, \mathsf{fma}\left(\mathsf{fma}\left(\left(\left(-0.020833333333333332 \cdot {\left({k}^{3}\right)}^{0.5}\right) \cdot t\_0\right) \cdot \left(\left(t\_2 \cdot t\_2\right) \cdot t\_2\right), {2}^{0.5}, \left(t\_1 \cdot 0.125\right) \cdot \left(t\_2 \cdot \left({2}^{0.5} \cdot t\_2\right)\right)\right), k, \left(\left(t\_1 \cdot -0.5\right) \cdot t\_2\right) \cdot {2}^{0.5}\right) \cdot k\right)}{k}
\end{array}
\end{array}
Derivation
  1. Initial program 99.5%

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

    \[\leadsto \color{blue}{\frac{k \cdot \left(\frac{-1}{2} \cdot \left(\sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \left(\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)\right) + k \cdot \left(\frac{-1}{48} \cdot \left(\sqrt{{k}^{3} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \left({\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{3} \cdot \sqrt{2}\right)\right) + \frac{1}{8} \cdot \left(\sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \left({\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot \sqrt{2}\right)\right)\right)\right) + \sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \sqrt{2}}{k}} \]
  4. Applied rewrites51.3%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.020833333333333332 \cdot \left(\sqrt{{k}^{3}} \cdot {\left(\pi \cdot n\right)}^{0.5}\right), \left(\left(\log \left(\left(\pi \cdot 2\right) \cdot n\right) \cdot \log \left(\left(\pi \cdot 2\right) \cdot n\right)\right) \cdot \log \left(\left(\pi \cdot 2\right) \cdot n\right)\right) \cdot {2}^{0.5}, \left(0.125 \cdot {\left(\left(\pi \cdot n\right) \cdot k\right)}^{0.5}\right) \cdot \left(\left(\log \left(\left(\pi \cdot 2\right) \cdot n\right) \cdot \log \left(\left(\pi \cdot 2\right) \cdot n\right)\right) \cdot {2}^{0.5}\right)\right), k, \left(-0.5 \cdot {\left(\left(\pi \cdot n\right) \cdot k\right)}^{0.5}\right) \cdot \left(\log \left(\left(\pi \cdot 2\right) \cdot n\right) \cdot {2}^{0.5}\right)\right), k, {\left(\left(\pi \cdot n\right) \cdot k\right)}^{0.5} \cdot {2}^{0.5}\right)}{k}} \]
  5. Applied rewrites63.5%

    \[\leadsto \frac{\mathsf{fma}\left({2}^{0.5}, {\left(\pi \cdot n\right)}^{0.5} \cdot {k}^{0.5}, \mathsf{fma}\left(\mathsf{fma}\left(\left(\left(-0.020833333333333332 \cdot {\left({k}^{3}\right)}^{0.5}\right) \cdot {\left(\pi \cdot n\right)}^{0.5}\right) \cdot \left(\left(\log \left(n \cdot \left(\pi \cdot 2\right)\right) \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right) \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right), {2}^{0.5}, \left(\left({\left(\pi \cdot n\right)}^{0.5} \cdot {k}^{0.5}\right) \cdot 0.125\right) \cdot \left(\log \left(n \cdot \left(\pi \cdot 2\right)\right) \cdot \left({2}^{0.5} \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right)\right)\right), k, \left(\left(\left({\left(\pi \cdot n\right)}^{0.5} \cdot {k}^{0.5}\right) \cdot -0.5\right) \cdot \log \left(n \cdot \left(\pi \cdot 2\right)\right)\right) \cdot {2}^{0.5}\right) \cdot k\right)}{k} \]
  6. Add Preprocessing

Alternative 8: 49.7% accurate, N/A× speedup?

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

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

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. 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 \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
    2. lower-*.f64N/A

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

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

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

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

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

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

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

      \[\leadsto {2}^{\frac{1}{2}} \cdot {\left(\frac{\mathsf{PI}\left(\right) \cdot n}{k}\right)}^{\frac{1}{2}} \]
    10. lift-PI.f6437.5

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

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

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

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

      \[\leadsto {2}^{\frac{1}{2}} \cdot \sqrt{\frac{\pi \cdot n}{k}} \]
    4. lift-PI.f64N/A

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

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

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

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

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

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

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

      \[\leadsto {2}^{\frac{1}{2}} \cdot \frac{\sqrt{\pi \cdot n}}{\sqrt{k}} \]
    12. unpow1/2N/A

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

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

      \[\leadsto {2}^{\frac{1}{2}} \cdot \frac{{\left(\pi \cdot n\right)}^{\frac{1}{2}}}{{k}^{\color{blue}{\frac{1}{2}}}} \]
    15. lift-pow.f6450.7

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

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

Reproduce

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