Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.4%
Time: 9.8s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

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 10 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.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

Alternative 2: 99.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

Alternative 3: 98.1% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{k}} \cdot {t\_0}^{\left(-0.5 \cdot k\right)}\\


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

    1. Initial program 98.8%

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

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

        \[\leadsto \sqrt{\frac{1}{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
      2. lower-/.f6498.8

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

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

      \[\leadsto \sqrt{\frac{1}{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{\color{blue}{1}}{2}\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites96.3%

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

      if 1 < k

      1. Initial program 100.0%

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

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

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

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

    Alternative 4: 98.1% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\sqrt{k}}\\ t_1 := \left(2 \cdot \pi\right) \cdot n\\ \mathbf{if}\;k \leq 1:\\ \;\;\;\;t\_0 \cdot {t\_1}^{0.5}\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot {t\_1}^{\left(-0.5 \cdot k\right)}\\ \end{array} \end{array} \]
    (FPCore (k n)
     :precision binary64
     (let* ((t_0 (/ 1.0 (sqrt k))) (t_1 (* (* 2.0 PI) n)))
       (if (<= k 1.0) (* t_0 (pow t_1 0.5)) (* t_0 (pow t_1 (* -0.5 k))))))
    double code(double k, double n) {
    	double t_0 = 1.0 / sqrt(k);
    	double t_1 = (2.0 * ((double) M_PI)) * n;
    	double tmp;
    	if (k <= 1.0) {
    		tmp = t_0 * pow(t_1, 0.5);
    	} else {
    		tmp = t_0 * pow(t_1, (-0.5 * k));
    	}
    	return tmp;
    }
    
    public static double code(double k, double n) {
    	double t_0 = 1.0 / Math.sqrt(k);
    	double t_1 = (2.0 * Math.PI) * n;
    	double tmp;
    	if (k <= 1.0) {
    		tmp = t_0 * Math.pow(t_1, 0.5);
    	} else {
    		tmp = t_0 * Math.pow(t_1, (-0.5 * k));
    	}
    	return tmp;
    }
    
    def code(k, n):
    	t_0 = 1.0 / math.sqrt(k)
    	t_1 = (2.0 * math.pi) * n
    	tmp = 0
    	if k <= 1.0:
    		tmp = t_0 * math.pow(t_1, 0.5)
    	else:
    		tmp = t_0 * math.pow(t_1, (-0.5 * k))
    	return tmp
    
    function code(k, n)
    	t_0 = Float64(1.0 / sqrt(k))
    	t_1 = Float64(Float64(2.0 * pi) * n)
    	tmp = 0.0
    	if (k <= 1.0)
    		tmp = Float64(t_0 * (t_1 ^ 0.5));
    	else
    		tmp = Float64(t_0 * (t_1 ^ Float64(-0.5 * k)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(k, n)
    	t_0 = 1.0 / sqrt(k);
    	t_1 = (2.0 * pi) * n;
    	tmp = 0.0;
    	if (k <= 1.0)
    		tmp = t_0 * (t_1 ^ 0.5);
    	else
    		tmp = t_0 * (t_1 ^ (-0.5 * k));
    	end
    	tmp_2 = tmp;
    end
    
    code[k_, n_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision]}, If[LessEqual[k, 1.0], N[(t$95$0 * N[Power[t$95$1, 0.5], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Power[t$95$1, N[(-0.5 * k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{1}{\sqrt{k}}\\
    t_1 := \left(2 \cdot \pi\right) \cdot n\\
    \mathbf{if}\;k \leq 1:\\
    \;\;\;\;t\_0 \cdot {t\_1}^{0.5}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0 \cdot {t\_1}^{\left(-0.5 \cdot k\right)}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if k < 1

      1. Initial program 98.8%

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

        \[\leadsto \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\color{blue}{\frac{1}{2}}} \]
      3. Step-by-step derivation
        1. Applied rewrites96.3%

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

        if 1 < k

        1. Initial program 100.0%

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

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

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

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

      Alternative 5: 60.8% accurate, 1.1× speedup?

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

        1. Initial program 99.0%

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

          \[\leadsto \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\color{blue}{\frac{1}{2}}} \]
        3. Step-by-step derivation
          1. Applied rewrites98.8%

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

          if 4.19999999999999977e-13 < k

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

            \[\leadsto \color{blue}{\frac{\frac{-1}{2} \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) \cdot \sqrt{2}\right)\right) + \sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \sqrt{2}}{k}} \]
          3. Step-by-step derivation
            1. lower-/.f64N/A

              \[\leadsto \frac{\frac{-1}{2} \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) \cdot \sqrt{2}\right)\right) + \sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \sqrt{2}}{\color{blue}{k}} \]
          4. Applied rewrites34.9%

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

            \[\leadsto \frac{n \cdot \left(\frac{-1}{2} \cdot \left(\sqrt{\frac{{k}^{3} \cdot \mathsf{PI}\left(\right)}{n}} \cdot \left(\sqrt{2} \cdot \left(\log \left(2 \cdot \mathsf{PI}\left(\right)\right) + -1 \cdot \log \left(\frac{1}{n}\right)\right)\right)\right) + \sqrt{\frac{k \cdot \mathsf{PI}\left(\right)}{n}} \cdot \sqrt{2}\right)}{k} \]
          6. Step-by-step derivation
            1. lower-*.f64N/A

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

              \[\leadsto \frac{n \cdot \mathsf{fma}\left(\frac{-1}{2}, \sqrt{\frac{{k}^{3} \cdot \mathsf{PI}\left(\right)}{n}} \cdot \left(\sqrt{2} \cdot \left(\log \left(2 \cdot \mathsf{PI}\left(\right)\right) + -1 \cdot \log \left(\frac{1}{n}\right)\right)\right), \sqrt{\frac{k \cdot \mathsf{PI}\left(\right)}{n}} \cdot \sqrt{2}\right)}{k} \]
          7. Applied rewrites43.8%

            \[\leadsto \frac{n \cdot \mathsf{fma}\left(-0.5, \sqrt{\frac{{k}^{3} \cdot \pi}{n}} \cdot \left(\sqrt{2} \cdot \left(\log \left(2 \cdot \pi\right) + -1 \cdot \log \left(\frac{1}{n}\right)\right)\right), \sqrt{\frac{k \cdot \pi}{n}} \cdot \sqrt{2}\right)}{k} \]
          8. Taylor expanded in k around 0

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

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

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

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

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

              \[\leadsto \frac{n \cdot \left(\sqrt{\frac{k \cdot \pi}{n}} \cdot \sqrt{2}\right)}{k} \]
            6. lift-*.f6427.7

              \[\leadsto \frac{n \cdot \left(\sqrt{\frac{k \cdot \pi}{n}} \cdot \sqrt{2}\right)}{k} \]
          10. Applied rewrites27.7%

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

        Alternative 6: 60.7% accurate, 1.5× speedup?

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

          1. Initial program 99.4%

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

            \[\leadsto \color{blue}{\frac{\frac{-1}{2} \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) \cdot \sqrt{2}\right)\right) + \sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \sqrt{2}}{k}} \]
          3. Step-by-step derivation
            1. lower-/.f64N/A

              \[\leadsto \frac{\frac{-1}{2} \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) \cdot \sqrt{2}\right)\right) + \sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \sqrt{2}}{\color{blue}{k}} \]
          4. Applied rewrites58.9%

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

            \[\leadsto \frac{n \cdot \left(\frac{-1}{2} \cdot \left(\sqrt{\frac{{k}^{3} \cdot \mathsf{PI}\left(\right)}{n}} \cdot \left(\sqrt{2} \cdot \left(\log \left(2 \cdot \mathsf{PI}\left(\right)\right) + -1 \cdot \log \left(\frac{1}{n}\right)\right)\right)\right) + \sqrt{\frac{k \cdot \mathsf{PI}\left(\right)}{n}} \cdot \sqrt{2}\right)}{k} \]
          6. Step-by-step derivation
            1. lower-*.f64N/A

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

              \[\leadsto \frac{n \cdot \mathsf{fma}\left(\frac{-1}{2}, \sqrt{\frac{{k}^{3} \cdot \mathsf{PI}\left(\right)}{n}} \cdot \left(\sqrt{2} \cdot \left(\log \left(2 \cdot \mathsf{PI}\left(\right)\right) + -1 \cdot \log \left(\frac{1}{n}\right)\right)\right), \sqrt{\frac{k \cdot \mathsf{PI}\left(\right)}{n}} \cdot \sqrt{2}\right)}{k} \]
          7. Applied rewrites91.4%

            \[\leadsto \frac{n \cdot \mathsf{fma}\left(-0.5, \sqrt{\frac{{k}^{3} \cdot \pi}{n}} \cdot \left(\sqrt{2} \cdot \left(\log \left(2 \cdot \pi\right) + -1 \cdot \log \left(\frac{1}{n}\right)\right)\right), \sqrt{\frac{k \cdot \pi}{n}} \cdot \sqrt{2}\right)}{k} \]
          8. Taylor expanded in k around 0

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

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

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

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

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

              \[\leadsto \frac{n \cdot \left(\sqrt{\frac{k \cdot \pi}{n}} \cdot \sqrt{2}\right)}{k} \]
            6. lift-*.f6474.4

              \[\leadsto \frac{n \cdot \left(\sqrt{\frac{k \cdot \pi}{n}} \cdot \sqrt{2}\right)}{k} \]
          10. Applied rewrites74.4%

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

          if 1.0000000000000001e-18 < n

          1. Initial program 99.4%

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

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

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

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

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

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

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

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

        Alternative 7: 48.2% accurate, 0.7× speedup?

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

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

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

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

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

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

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

              \[\leadsto \sqrt{\frac{n \cdot \pi}{k}} \cdot \sqrt{2} \]
            6. lower-sqrt.f6455.9

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

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

          if 1.00000000000000005e142 < (*.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.6%

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

            \[\leadsto \color{blue}{\frac{\frac{-1}{2} \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) \cdot \sqrt{2}\right)\right) + \sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \sqrt{2}}{k}} \]
          3. Step-by-step derivation
            1. lower-/.f64N/A

              \[\leadsto \frac{\frac{-1}{2} \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) \cdot \sqrt{2}\right)\right) + \sqrt{k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)} \cdot \sqrt{2}}{\color{blue}{k}} \]
          4. Applied rewrites78.4%

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

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

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

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

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

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

              \[\leadsto \frac{\sqrt{k \cdot \left(n \cdot \pi\right)} \cdot \sqrt{2}}{k} \]
            6. lift-*.f6436.6

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

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

        Alternative 8: 48.2% accurate, 2.0× speedup?

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

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

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

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

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

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

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

            \[\leadsto \frac{1}{\sqrt{k}} \cdot \left(\sqrt{n \cdot \pi} \cdot \sqrt{2}\right) \]
        4. Applied rewrites48.2%

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

        Alternative 9: 48.2% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \sqrt{\frac{1}{k}} \cdot \left(\sqrt{n \cdot \pi} \cdot \sqrt{2}\right) \]
          5. lift-sqrt.f6448.2

            \[\leadsto \sqrt{\frac{1}{k}} \cdot \left(\sqrt{n \cdot \pi} \cdot \sqrt{2}\right) \]
        7. Applied rewrites48.2%

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

        Alternative 10: 37.0% accurate, 2.7× speedup?

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

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

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

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

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

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

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

            \[\leadsto \sqrt{\frac{n \cdot \pi}{k}} \cdot \sqrt{2} \]
          6. lower-sqrt.f6437.0

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

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

        Reproduce

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