
(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:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (k n) :precision binary64 (let* ((t_0 (* PI (* 2.0 n)))) (/ (* (pow k -0.5) (sqrt t_0)) (pow (pow t_0 k) 0.5))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (2.0 * n);
return (pow(k, -0.5) * sqrt(t_0)) / pow(pow(t_0, k), 0.5);
}
public static double code(double k, double n) {
double t_0 = Math.PI * (2.0 * n);
return (Math.pow(k, -0.5) * Math.sqrt(t_0)) / Math.pow(Math.pow(t_0, k), 0.5);
}
def code(k, n): t_0 = math.pi * (2.0 * n) return (math.pow(k, -0.5) * math.sqrt(t_0)) / math.pow(math.pow(t_0, k), 0.5)
function code(k, n) t_0 = Float64(pi * Float64(2.0 * n)) return Float64(Float64((k ^ -0.5) * sqrt(t_0)) / ((t_0 ^ k) ^ 0.5)) end
function tmp = code(k, n) t_0 = pi * (2.0 * n); tmp = ((k ^ -0.5) * sqrt(t_0)) / ((t_0 ^ k) ^ 0.5); end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Power[k, -0.5], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Power[t$95$0, k], $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(2 \cdot n\right)\\
\frac{{k}^{-0.5} \cdot \sqrt{t_0}}{{\left({t_0}^{k}\right)}^{0.5}}
\end{array}
\end{array}
Initial program 99.3%
associate-*r*99.3%
div-sub99.3%
metadata-eval99.3%
pow-sub99.6%
pow1/299.6%
associate-*r/99.6%
pow1/299.6%
pow-flip99.7%
metadata-eval99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*l*99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (let* ((t_0 (* PI (* 2.0 n)))) (* (pow k -0.5) (* (sqrt t_0) (pow t_0 (* k -0.5))))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (2.0 * n);
return pow(k, -0.5) * (sqrt(t_0) * pow(t_0, (k * -0.5)));
}
public static double code(double k, double n) {
double t_0 = Math.PI * (2.0 * n);
return Math.pow(k, -0.5) * (Math.sqrt(t_0) * Math.pow(t_0, (k * -0.5)));
}
def code(k, n): t_0 = math.pi * (2.0 * n) return math.pow(k, -0.5) * (math.sqrt(t_0) * math.pow(t_0, (k * -0.5)))
function code(k, n) t_0 = Float64(pi * Float64(2.0 * n)) return Float64((k ^ -0.5) * Float64(sqrt(t_0) * (t_0 ^ Float64(k * -0.5)))) end
function tmp = code(k, n) t_0 = pi * (2.0 * n); tmp = (k ^ -0.5) * (sqrt(t_0) * (t_0 ^ (k * -0.5))); end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[k, -0.5], $MachinePrecision] * N[(N[Sqrt[t$95$0], $MachinePrecision] * N[Power[t$95$0, N[(k * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(2 \cdot n\right)\\
{k}^{-0.5} \cdot \left(\sqrt{t_0} \cdot {t_0}^{\left(k \cdot -0.5\right)}\right)
\end{array}
\end{array}
Initial program 99.3%
associate-*r*99.3%
div-sub99.3%
metadata-eval99.3%
sub-neg99.3%
unpow-prod-up99.6%
pow1/299.6%
associate-*r*99.6%
*-commutative99.6%
associate-*l*99.6%
associate-*r*99.6%
*-commutative99.6%
associate-*l*99.6%
div-inv99.6%
metadata-eval99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Applied egg-rr99.6%
expm1-log1p-u96.3%
expm1-udef77.2%
pow1/277.2%
pow-flip77.2%
metadata-eval77.2%
Applied egg-rr77.2%
expm1-def96.3%
expm1-log1p99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* PI (* 2.0 n))))
(if (<= k 1e-39)
(/ 1.0 (/ (sqrt k) (sqrt t_0)))
(pow (/ k (pow t_0 (- 1.0 k))) -0.5))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (2.0 * n);
double tmp;
if (k <= 1e-39) {
tmp = 1.0 / (sqrt(k) / sqrt(t_0));
} else {
tmp = pow((k / pow(t_0, (1.0 - k))), -0.5);
}
return tmp;
}
public static double code(double k, double n) {
double t_0 = Math.PI * (2.0 * n);
double tmp;
if (k <= 1e-39) {
tmp = 1.0 / (Math.sqrt(k) / Math.sqrt(t_0));
} else {
tmp = Math.pow((k / Math.pow(t_0, (1.0 - k))), -0.5);
}
return tmp;
}
def code(k, n): t_0 = math.pi * (2.0 * n) tmp = 0 if k <= 1e-39: tmp = 1.0 / (math.sqrt(k) / math.sqrt(t_0)) else: tmp = math.pow((k / math.pow(t_0, (1.0 - k))), -0.5) return tmp
function code(k, n) t_0 = Float64(pi * Float64(2.0 * n)) tmp = 0.0 if (k <= 1e-39) tmp = Float64(1.0 / Float64(sqrt(k) / sqrt(t_0))); else tmp = Float64(k / (t_0 ^ Float64(1.0 - k))) ^ -0.5; end return tmp end
function tmp_2 = code(k, n) t_0 = pi * (2.0 * n); tmp = 0.0; if (k <= 1e-39) tmp = 1.0 / (sqrt(k) / sqrt(t_0)); else tmp = (k / (t_0 ^ (1.0 - k))) ^ -0.5; end tmp_2 = tmp; end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k, 1e-39], N[(1.0 / N[(N[Sqrt[k], $MachinePrecision] / N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(k / N[Power[t$95$0, N[(1.0 - k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(2 \cdot n\right)\\
\mathbf{if}\;k \leq 10^{-39}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{k}}{\sqrt{t_0}}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{k}{{t_0}^{\left(1 - k\right)}}\right)}^{-0.5}\\
\end{array}
\end{array}
if k < 9.99999999999999929e-40Initial program 99.3%
add-sqr-sqrt98.9%
sqrt-unprod75.5%
*-commutative75.5%
div-inv75.5%
*-commutative75.5%
div-inv75.6%
frac-times75.5%
Applied egg-rr75.6%
Simplified75.7%
clear-num75.7%
sqrt-div76.3%
metadata-eval76.3%
associate-*r*76.3%
*-commutative76.3%
*-commutative76.3%
Applied egg-rr76.3%
Taylor expanded in k around 0 76.3%
*-commutative76.3%
associate-*l*76.3%
*-commutative76.3%
Simplified76.3%
sqrt-div99.3%
*-commutative99.3%
Applied egg-rr99.3%
*-commutative99.3%
associate-*r*99.3%
Simplified99.3%
if 9.99999999999999929e-40 < k Initial program 99.3%
associate-*r*99.3%
div-sub99.3%
metadata-eval99.3%
sub-neg99.3%
unpow-prod-up99.9%
pow1/299.9%
associate-*r*99.9%
*-commutative99.9%
associate-*l*99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*l*99.9%
div-inv99.9%
metadata-eval99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
Applied egg-rr99.9%
*-commutative99.9%
div-inv99.8%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (* (pow k -0.5) (pow (* PI (* 2.0 n)) (- 0.5 (* k 0.5)))))
double code(double k, double n) {
return pow(k, -0.5) * pow((((double) M_PI) * (2.0 * n)), (0.5 - (k * 0.5)));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) * Math.pow((Math.PI * (2.0 * n)), (0.5 - (k * 0.5)));
}
def code(k, n): return math.pow(k, -0.5) * math.pow((math.pi * (2.0 * n)), (0.5 - (k * 0.5)))
function code(k, n) return Float64((k ^ -0.5) * (Float64(pi * Float64(2.0 * n)) ^ Float64(0.5 - Float64(k * 0.5)))) end
function tmp = code(k, n) tmp = (k ^ -0.5) * ((pi * (2.0 * n)) ^ (0.5 - (k * 0.5))); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision], N[(0.5 - N[(k * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{k}^{-0.5} \cdot {\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(0.5 - k \cdot 0.5\right)}
\end{array}
Initial program 99.3%
associate-*l/99.4%
*-lft-identity99.4%
sqr-pow99.2%
pow-sqr99.4%
associate-*l*99.4%
*-commutative99.4%
associate-*l/99.4%
associate-/l*99.4%
metadata-eval99.4%
/-rgt-identity99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
div-inv99.3%
associate-*r*99.3%
*-commutative99.3%
associate-*l*99.3%
div-inv99.3%
metadata-eval99.3%
pow1/299.3%
pow-flip99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (if (<= k 5e-39) (/ 1.0 (/ (sqrt k) (sqrt (* PI (* 2.0 n))))) (sqrt (/ (pow (* n (* PI 2.0)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 5e-39) {
tmp = 1.0 / (sqrt(k) / sqrt((((double) M_PI) * (2.0 * n))));
} else {
tmp = sqrt((pow((n * (((double) M_PI) * 2.0)), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 5e-39) {
tmp = 1.0 / (Math.sqrt(k) / Math.sqrt((Math.PI * (2.0 * n))));
} else {
tmp = Math.sqrt((Math.pow((n * (Math.PI * 2.0)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 5e-39: tmp = 1.0 / (math.sqrt(k) / math.sqrt((math.pi * (2.0 * n)))) else: tmp = math.sqrt((math.pow((n * (math.pi * 2.0)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 5e-39) tmp = Float64(1.0 / Float64(sqrt(k) / sqrt(Float64(pi * Float64(2.0 * n))))); else tmp = sqrt(Float64((Float64(n * Float64(pi * 2.0)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 5e-39) tmp = 1.0 / (sqrt(k) / sqrt((pi * (2.0 * n)))); else tmp = sqrt((((n * (pi * 2.0)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 5e-39], N[(1.0 / N[(N[Sqrt[k], $MachinePrecision] / N[Sqrt[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 5 \cdot 10^{-39}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{k}}{\sqrt{\pi \cdot \left(2 \cdot n\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(n \cdot \left(\pi \cdot 2\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 4.9999999999999998e-39Initial program 99.3%
add-sqr-sqrt98.9%
sqrt-unprod75.5%
*-commutative75.5%
div-inv75.5%
*-commutative75.5%
div-inv75.6%
frac-times75.5%
Applied egg-rr75.6%
Simplified75.7%
clear-num75.7%
sqrt-div76.3%
metadata-eval76.3%
associate-*r*76.3%
*-commutative76.3%
*-commutative76.3%
Applied egg-rr76.3%
Taylor expanded in k around 0 76.3%
*-commutative76.3%
associate-*l*76.3%
*-commutative76.3%
Simplified76.3%
sqrt-div99.3%
*-commutative99.3%
Applied egg-rr99.3%
*-commutative99.3%
associate-*r*99.3%
Simplified99.3%
if 4.9999999999999998e-39 < k Initial program 99.3%
add-sqr-sqrt99.3%
sqrt-unprod99.3%
*-commutative99.3%
div-inv99.3%
*-commutative99.3%
div-inv99.3%
frac-times99.3%
Applied egg-rr99.3%
Simplified99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (/ (pow (* 2.0 (* PI n)) (- 0.5 (/ k 2.0))) (sqrt k)))
double code(double k, double n) {
return pow((2.0 * (((double) M_PI) * n)), (0.5 - (k / 2.0))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow((2.0 * (Math.PI * n)), (0.5 - (k / 2.0))) / Math.sqrt(k);
}
def code(k, n): return math.pow((2.0 * (math.pi * n)), (0.5 - (k / 2.0))) / math.sqrt(k)
function code(k, n) return Float64((Float64(2.0 * Float64(pi * n)) ^ Float64(0.5 - Float64(k / 2.0))) / sqrt(k)) end
function tmp = code(k, n) tmp = ((2.0 * (pi * n)) ^ (0.5 - (k / 2.0))) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision], N[(0.5 - N[(k / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.3%
associate-*l/99.4%
*-lft-identity99.4%
sqr-pow99.2%
pow-sqr99.4%
associate-*l*99.4%
*-commutative99.4%
associate-*l/99.4%
associate-/l*99.4%
metadata-eval99.4%
/-rgt-identity99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (/ 1.0 (* (sqrt k) (sqrt (/ (/ 0.5 PI) n)))))
double code(double k, double n) {
return 1.0 / (sqrt(k) * sqrt(((0.5 / ((double) M_PI)) / n)));
}
public static double code(double k, double n) {
return 1.0 / (Math.sqrt(k) * Math.sqrt(((0.5 / Math.PI) / n)));
}
def code(k, n): return 1.0 / (math.sqrt(k) * math.sqrt(((0.5 / math.pi) / n)))
function code(k, n) return Float64(1.0 / Float64(sqrt(k) * sqrt(Float64(Float64(0.5 / pi) / n)))) end
function tmp = code(k, n) tmp = 1.0 / (sqrt(k) * sqrt(((0.5 / pi) / n))); end
code[k_, n_] := N[(1.0 / N[(N[Sqrt[k], $MachinePrecision] * N[Sqrt[N[(N[(0.5 / Pi), $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{k} \cdot \sqrt{\frac{\frac{0.5}{\pi}}{n}}}
\end{array}
Initial program 99.3%
add-sqr-sqrt99.1%
sqrt-unprod89.5%
*-commutative89.5%
div-inv89.5%
*-commutative89.5%
div-inv89.5%
frac-times89.5%
Applied egg-rr89.5%
Simplified89.6%
clear-num89.6%
sqrt-div89.8%
metadata-eval89.8%
associate-*r*89.8%
*-commutative89.8%
*-commutative89.8%
Applied egg-rr89.8%
Taylor expanded in k around 0 40.8%
*-commutative40.8%
associate-*l*40.8%
*-commutative40.8%
Simplified40.8%
pow1/240.8%
div-inv40.8%
unpow-prod-down50.4%
pow1/250.4%
*-commutative50.4%
Applied egg-rr50.4%
unpow1/250.4%
*-commutative50.4%
associate-/r*50.4%
*-commutative50.4%
associate-/r*50.4%
metadata-eval50.4%
Simplified50.4%
Final simplification50.4%
(FPCore (k n) :precision binary64 (/ 1.0 (/ (sqrt k) (sqrt (* PI (* 2.0 n))))))
double code(double k, double n) {
return 1.0 / (sqrt(k) / sqrt((((double) M_PI) * (2.0 * n))));
}
public static double code(double k, double n) {
return 1.0 / (Math.sqrt(k) / Math.sqrt((Math.PI * (2.0 * n))));
}
def code(k, n): return 1.0 / (math.sqrt(k) / math.sqrt((math.pi * (2.0 * n))))
function code(k, n) return Float64(1.0 / Float64(sqrt(k) / sqrt(Float64(pi * Float64(2.0 * n))))) end
function tmp = code(k, n) tmp = 1.0 / (sqrt(k) / sqrt((pi * (2.0 * n)))); end
code[k_, n_] := N[(1.0 / N[(N[Sqrt[k], $MachinePrecision] / N[Sqrt[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{\sqrt{k}}{\sqrt{\pi \cdot \left(2 \cdot n\right)}}}
\end{array}
Initial program 99.3%
add-sqr-sqrt99.1%
sqrt-unprod89.5%
*-commutative89.5%
div-inv89.5%
*-commutative89.5%
div-inv89.5%
frac-times89.5%
Applied egg-rr89.5%
Simplified89.6%
clear-num89.6%
sqrt-div89.8%
metadata-eval89.8%
associate-*r*89.8%
*-commutative89.8%
*-commutative89.8%
Applied egg-rr89.8%
Taylor expanded in k around 0 40.8%
*-commutative40.8%
associate-*l*40.8%
*-commutative40.8%
Simplified40.8%
sqrt-div50.4%
*-commutative50.4%
Applied egg-rr50.4%
*-commutative50.4%
associate-*r*50.4%
Simplified50.4%
Final simplification50.4%
(FPCore (k n) :precision binary64 (pow (* 0.5 (/ (/ k PI) n)) -0.5))
double code(double k, double n) {
return pow((0.5 * ((k / ((double) M_PI)) / n)), -0.5);
}
public static double code(double k, double n) {
return Math.pow((0.5 * ((k / Math.PI) / n)), -0.5);
}
def code(k, n): return math.pow((0.5 * ((k / math.pi) / n)), -0.5)
function code(k, n) return Float64(0.5 * Float64(Float64(k / pi) / n)) ^ -0.5 end
function tmp = code(k, n) tmp = (0.5 * ((k / pi) / n)) ^ -0.5; end
code[k_, n_] := N[Power[N[(0.5 * N[(N[(k / Pi), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(0.5 \cdot \frac{\frac{k}{\pi}}{n}\right)}^{-0.5}
\end{array}
Initial program 99.3%
add-sqr-sqrt99.1%
sqrt-unprod89.5%
*-commutative89.5%
div-inv89.5%
*-commutative89.5%
div-inv89.5%
frac-times89.5%
Applied egg-rr89.5%
Simplified89.6%
clear-num89.6%
sqrt-div89.8%
metadata-eval89.8%
associate-*r*89.8%
*-commutative89.8%
*-commutative89.8%
Applied egg-rr89.8%
Taylor expanded in k around 0 40.8%
*-commutative40.8%
associate-*l*40.8%
*-commutative40.8%
Simplified40.8%
expm1-log1p-u39.3%
expm1-udef39.1%
pow1/239.1%
pow-flip39.1%
*-commutative39.1%
metadata-eval39.1%
Applied egg-rr39.1%
expm1-def39.3%
expm1-log1p40.9%
*-lft-identity40.9%
associate-*r*40.9%
*-commutative40.9%
*-commutative40.9%
times-frac40.9%
metadata-eval40.9%
associate-/r*40.9%
Simplified40.9%
Final simplification40.9%
(FPCore (k n) :precision binary64 (pow (/ k (* PI (* 2.0 n))) -0.5))
double code(double k, double n) {
return pow((k / (((double) M_PI) * (2.0 * n))), -0.5);
}
public static double code(double k, double n) {
return Math.pow((k / (Math.PI * (2.0 * n))), -0.5);
}
def code(k, n): return math.pow((k / (math.pi * (2.0 * n))), -0.5)
function code(k, n) return Float64(k / Float64(pi * Float64(2.0 * n))) ^ -0.5 end
function tmp = code(k, n) tmp = (k / (pi * (2.0 * n))) ^ -0.5; end
code[k_, n_] := N[Power[N[(k / N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{k}{\pi \cdot \left(2 \cdot n\right)}\right)}^{-0.5}
\end{array}
Initial program 99.3%
add-sqr-sqrt99.1%
sqrt-unprod89.5%
*-commutative89.5%
div-inv89.5%
*-commutative89.5%
div-inv89.5%
frac-times89.5%
Applied egg-rr89.5%
Simplified89.6%
clear-num89.6%
sqrt-div89.8%
metadata-eval89.8%
associate-*r*89.8%
*-commutative89.8%
*-commutative89.8%
Applied egg-rr89.8%
Taylor expanded in k around 0 40.8%
*-commutative40.8%
associate-*l*40.8%
*-commutative40.8%
Simplified40.8%
expm1-log1p-u39.3%
expm1-udef39.1%
pow1/239.1%
pow-flip39.1%
*-commutative39.1%
metadata-eval39.1%
Applied egg-rr39.1%
expm1-def39.3%
expm1-log1p40.9%
associate-*r*40.9%
*-commutative40.9%
*-commutative40.9%
*-commutative40.9%
associate-*r*40.9%
*-commutative40.9%
Simplified40.9%
Final simplification40.9%
herbie shell --seed 2023314
(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))))