
(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 (* (* 2.0 n) PI))) (* (pow k -0.5) (/ (sqrt t_0) (pow t_0 (* k 0.5))))))
double code(double k, double n) {
double t_0 = (2.0 * n) * ((double) M_PI);
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 = (2.0 * n) * Math.PI;
return Math.pow(k, -0.5) * (Math.sqrt(t_0) / Math.pow(t_0, (k * 0.5)));
}
def code(k, n): t_0 = (2.0 * n) * math.pi return math.pow(k, -0.5) * (math.sqrt(t_0) / math.pow(t_0, (k * 0.5)))
function code(k, n) t_0 = Float64(Float64(2.0 * n) * pi) return Float64((k ^ -0.5) * Float64(sqrt(t_0) / (t_0 ^ Float64(k * 0.5)))) end
function tmp = code(k, n) t_0 = (2.0 * n) * pi; tmp = (k ^ -0.5) * (sqrt(t_0) / (t_0 ^ (k * 0.5))); end
code[k_, n_] := Block[{t$95$0 = N[(N[(2.0 * n), $MachinePrecision] * Pi), $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 := \left(2 \cdot n\right) \cdot \pi\\
{k}^{-0.5} \cdot \frac{\sqrt{t_0}}{{t_0}^{\left(k \cdot 0.5\right)}}
\end{array}
\end{array}
Initial program 99.5%
div-sub99.5%
metadata-eval99.5%
pow-sub99.7%
pow1/299.7%
associate-*l*99.7%
associate-*l*99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
expm1-log1p-u96.5%
expm1-udef73.0%
pow1/273.0%
pow-flip73.0%
metadata-eval73.0%
Applied egg-rr73.0%
expm1-def96.5%
expm1-log1p99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (* 2.0 n) PI)))
(if (<= k 3e-39)
(/ 1.0 (/ (sqrt k) (sqrt t_0)))
(/ 1.0 (sqrt (/ k (pow t_0 (- 1.0 k))))))))
double code(double k, double n) {
double t_0 = (2.0 * n) * ((double) M_PI);
double tmp;
if (k <= 3e-39) {
tmp = 1.0 / (sqrt(k) / sqrt(t_0));
} else {
tmp = 1.0 / sqrt((k / pow(t_0, (1.0 - k))));
}
return tmp;
}
public static double code(double k, double n) {
double t_0 = (2.0 * n) * Math.PI;
double tmp;
if (k <= 3e-39) {
tmp = 1.0 / (Math.sqrt(k) / Math.sqrt(t_0));
} else {
tmp = 1.0 / Math.sqrt((k / Math.pow(t_0, (1.0 - k))));
}
return tmp;
}
def code(k, n): t_0 = (2.0 * n) * math.pi tmp = 0 if k <= 3e-39: tmp = 1.0 / (math.sqrt(k) / math.sqrt(t_0)) else: tmp = 1.0 / math.sqrt((k / math.pow(t_0, (1.0 - k)))) return tmp
function code(k, n) t_0 = Float64(Float64(2.0 * n) * pi) tmp = 0.0 if (k <= 3e-39) tmp = Float64(1.0 / Float64(sqrt(k) / sqrt(t_0))); else tmp = Float64(1.0 / sqrt(Float64(k / (t_0 ^ Float64(1.0 - k))))); end return tmp end
function tmp_2 = code(k, n) t_0 = (2.0 * n) * pi; tmp = 0.0; if (k <= 3e-39) tmp = 1.0 / (sqrt(k) / sqrt(t_0)); else tmp = 1.0 / sqrt((k / (t_0 ^ (1.0 - k)))); end tmp_2 = tmp; end
code[k_, n_] := Block[{t$95$0 = N[(N[(2.0 * n), $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[k, 3e-39], N[(1.0 / N[(N[Sqrt[k], $MachinePrecision] / N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sqrt[N[(k / N[Power[t$95$0, N[(1.0 - k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot n\right) \cdot \pi\\
\mathbf{if}\;k \leq 3 \cdot 10^{-39}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{k}}{\sqrt{t_0}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{k}{{t_0}^{\left(1 - k\right)}}}}\\
\end{array}
\end{array}
if k < 3.00000000000000028e-39Initial program 99.3%
*-commutative99.3%
associate-*r*99.3%
associate-/r/99.4%
add-sqr-sqrt99.0%
sqrt-unprod99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
pow-prod-up99.4%
Applied egg-rr99.4%
sqrt-undiv77.0%
*-commutative77.0%
associate-*l*77.0%
*-commutative77.0%
Applied egg-rr77.0%
Taylor expanded in k around 0 77.0%
*-commutative77.0%
*-commutative77.0%
associate-*l*77.0%
Simplified77.0%
sqrt-div99.4%
*-commutative99.4%
Applied egg-rr99.4%
if 3.00000000000000028e-39 < k Initial program 99.6%
*-commutative99.6%
associate-*r*99.6%
associate-/r/99.6%
add-sqr-sqrt99.5%
sqrt-unprod99.6%
associate-*r*99.6%
*-commutative99.6%
associate-*r*99.6%
*-commutative99.6%
pow-prod-up99.6%
Applied egg-rr99.6%
sqrt-undiv99.6%
*-commutative99.6%
associate-*l*99.6%
*-commutative99.6%
Applied egg-rr99.6%
Final simplification99.5%
(FPCore (k n) :precision binary64 (/ (pow k -0.5) (pow (* (* 2.0 n) PI) (/ (+ k -1.0) 2.0))))
double code(double k, double n) {
return pow(k, -0.5) / pow(((2.0 * n) * ((double) M_PI)), ((k + -1.0) / 2.0));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) / Math.pow(((2.0 * n) * Math.PI), ((k + -1.0) / 2.0));
}
def code(k, n): return math.pow(k, -0.5) / math.pow(((2.0 * n) * math.pi), ((k + -1.0) / 2.0))
function code(k, n) return Float64((k ^ -0.5) / (Float64(Float64(2.0 * n) * pi) ^ Float64(Float64(k + -1.0) / 2.0))) end
function tmp = code(k, n) tmp = (k ^ -0.5) / (((2.0 * n) * pi) ^ ((k + -1.0) / 2.0)); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] / N[Power[N[(N[(2.0 * n), $MachinePrecision] * Pi), $MachinePrecision], N[(N[(k + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{k}^{-0.5}}{{\left(\left(2 \cdot n\right) \cdot \pi\right)}^{\left(\frac{k + -1}{2}\right)}}
\end{array}
Initial program 99.5%
div-sub99.5%
metadata-eval99.5%
pow-sub99.7%
pow1/299.7%
associate-*l*99.7%
associate-*l*99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
expm1-log1p-u96.5%
expm1-udef73.0%
pow1/273.0%
pow-flip73.0%
metadata-eval73.0%
Applied egg-rr73.0%
expm1-def96.5%
expm1-log1p99.7%
Simplified99.7%
clear-num99.7%
un-div-inv99.7%
pow-unpow99.7%
pow1/299.7%
pow199.7%
pow-div99.5%
associate-*l*99.5%
Applied egg-rr99.5%
*-commutative99.5%
*-commutative99.5%
associate-*l*99.5%
sub-neg99.5%
metadata-eval99.5%
Simplified99.5%
sqrt-pow299.6%
associate-*r*99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r*99.6%
*-commutative99.6%
pow-to-exp96.1%
Applied egg-rr96.1%
exp-to-pow99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (* 2.0 n) PI)))
(if (<= k 1.8e-45)
(/ 1.0 (/ (sqrt k) (sqrt t_0)))
(sqrt (/ (pow t_0 (- 1.0 k)) k)))))
double code(double k, double n) {
double t_0 = (2.0 * n) * ((double) M_PI);
double tmp;
if (k <= 1.8e-45) {
tmp = 1.0 / (sqrt(k) / sqrt(t_0));
} else {
tmp = sqrt((pow(t_0, (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double t_0 = (2.0 * n) * Math.PI;
double tmp;
if (k <= 1.8e-45) {
tmp = 1.0 / (Math.sqrt(k) / Math.sqrt(t_0));
} else {
tmp = Math.sqrt((Math.pow(t_0, (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): t_0 = (2.0 * n) * math.pi tmp = 0 if k <= 1.8e-45: tmp = 1.0 / (math.sqrt(k) / math.sqrt(t_0)) else: tmp = math.sqrt((math.pow(t_0, (1.0 - k)) / k)) return tmp
function code(k, n) t_0 = Float64(Float64(2.0 * n) * pi) tmp = 0.0 if (k <= 1.8e-45) tmp = Float64(1.0 / Float64(sqrt(k) / sqrt(t_0))); else tmp = sqrt(Float64((t_0 ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) t_0 = (2.0 * n) * pi; tmp = 0.0; if (k <= 1.8e-45) tmp = 1.0 / (sqrt(k) / sqrt(t_0)); else tmp = sqrt(((t_0 ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := Block[{t$95$0 = N[(N[(2.0 * n), $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[k, 1.8e-45], N[(1.0 / N[(N[Sqrt[k], $MachinePrecision] / N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[t$95$0, N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot n\right) \cdot \pi\\
\mathbf{if}\;k \leq 1.8 \cdot 10^{-45}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{k}}{\sqrt{t_0}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{t_0}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 1.8e-45Initial program 99.3%
*-commutative99.3%
associate-*r*99.3%
associate-/r/99.4%
add-sqr-sqrt99.0%
sqrt-unprod99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
pow-prod-up99.4%
Applied egg-rr99.4%
sqrt-undiv76.2%
*-commutative76.2%
associate-*l*76.2%
*-commutative76.2%
Applied egg-rr76.2%
Taylor expanded in k around 0 76.2%
*-commutative76.2%
*-commutative76.2%
associate-*l*76.2%
Simplified76.2%
sqrt-div99.4%
*-commutative99.4%
Applied egg-rr99.4%
if 1.8e-45 < k Initial program 99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r*99.6%
div-inv99.6%
expm1-log1p-u99.1%
expm1-udef94.2%
Applied egg-rr94.2%
expm1-def99.1%
expm1-log1p99.6%
*-commutative99.6%
associate-*r*99.6%
Simplified99.6%
Final simplification99.5%
(FPCore (k n) :precision binary64 (/ (pow (* (* 2.0 n) PI) (/ (- 1.0 k) 2.0)) (sqrt k)))
double code(double k, double n) {
return pow(((2.0 * n) * ((double) M_PI)), ((1.0 - k) / 2.0)) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow(((2.0 * n) * Math.PI), ((1.0 - k) / 2.0)) / Math.sqrt(k);
}
def code(k, n): return math.pow(((2.0 * n) * math.pi), ((1.0 - k) / 2.0)) / math.sqrt(k)
function code(k, n) return Float64((Float64(Float64(2.0 * n) * pi) ^ Float64(Float64(1.0 - k) / 2.0)) / sqrt(k)) end
function tmp = code(k, n) tmp = (((2.0 * n) * pi) ^ ((1.0 - k) / 2.0)) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(N[(2.0 * n), $MachinePrecision] * Pi), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\left(2 \cdot n\right) \cdot \pi\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.5%
associate-*l/99.5%
*-lft-identity99.5%
*-commutative99.5%
associate-*l*99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (k n) :precision binary64 (/ 1.0 (* (sqrt k) (sqrt (/ 0.5 (* n PI))))))
double code(double k, double n) {
return 1.0 / (sqrt(k) * sqrt((0.5 / (n * ((double) M_PI)))));
}
public static double code(double k, double n) {
return 1.0 / (Math.sqrt(k) * Math.sqrt((0.5 / (n * Math.PI))));
}
def code(k, n): return 1.0 / (math.sqrt(k) * math.sqrt((0.5 / (n * math.pi))))
function code(k, n) return Float64(1.0 / Float64(sqrt(k) * sqrt(Float64(0.5 / Float64(n * pi))))) end
function tmp = code(k, n) tmp = 1.0 / (sqrt(k) * sqrt((0.5 / (n * pi)))); end
code[k_, n_] := N[(1.0 / N[(N[Sqrt[k], $MachinePrecision] * N[Sqrt[N[(0.5 / N[(n * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{k} \cdot \sqrt{\frac{0.5}{n \cdot \pi}}}
\end{array}
Initial program 99.5%
*-commutative99.5%
associate-*r*99.5%
associate-/r/99.5%
add-sqr-sqrt99.3%
sqrt-unprod99.5%
associate-*r*99.5%
*-commutative99.5%
associate-*r*99.5%
*-commutative99.5%
pow-prod-up99.5%
Applied egg-rr99.5%
sqrt-undiv89.9%
*-commutative89.9%
associate-*l*89.9%
*-commutative89.9%
Applied egg-rr89.9%
Taylor expanded in k around 0 39.2%
*-commutative39.2%
*-commutative39.2%
associate-*l*39.2%
Simplified39.2%
pow1/239.2%
div-inv39.2%
unpow-prod-down48.9%
pow1/248.9%
*-commutative48.9%
Applied egg-rr48.9%
unpow1/248.9%
*-commutative48.9%
associate-*r*48.9%
*-commutative48.9%
associate-/r*48.9%
metadata-eval48.9%
Simplified48.9%
Final simplification48.9%
(FPCore (k n) :precision binary64 (/ 1.0 (/ (sqrt k) (sqrt (* (* 2.0 n) PI)))))
double code(double k, double n) {
return 1.0 / (sqrt(k) / sqrt(((2.0 * n) * ((double) M_PI))));
}
public static double code(double k, double n) {
return 1.0 / (Math.sqrt(k) / Math.sqrt(((2.0 * n) * Math.PI)));
}
def code(k, n): return 1.0 / (math.sqrt(k) / math.sqrt(((2.0 * n) * math.pi)))
function code(k, n) return Float64(1.0 / Float64(sqrt(k) / sqrt(Float64(Float64(2.0 * n) * pi)))) end
function tmp = code(k, n) tmp = 1.0 / (sqrt(k) / sqrt(((2.0 * n) * pi))); end
code[k_, n_] := N[(1.0 / N[(N[Sqrt[k], $MachinePrecision] / N[Sqrt[N[(N[(2.0 * n), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{\sqrt{k}}{\sqrt{\left(2 \cdot n\right) \cdot \pi}}}
\end{array}
Initial program 99.5%
*-commutative99.5%
associate-*r*99.5%
associate-/r/99.5%
add-sqr-sqrt99.3%
sqrt-unprod99.5%
associate-*r*99.5%
*-commutative99.5%
associate-*r*99.5%
*-commutative99.5%
pow-prod-up99.5%
Applied egg-rr99.5%
sqrt-undiv89.9%
*-commutative89.9%
associate-*l*89.9%
*-commutative89.9%
Applied egg-rr89.9%
Taylor expanded in k around 0 39.2%
*-commutative39.2%
*-commutative39.2%
associate-*l*39.2%
Simplified39.2%
sqrt-div48.9%
*-commutative48.9%
Applied egg-rr48.9%
Final simplification48.9%
(FPCore (k n) :precision binary64 (pow (/ (/ k 2.0) (* n PI)) -0.5))
double code(double k, double n) {
return pow(((k / 2.0) / (n * ((double) M_PI))), -0.5);
}
public static double code(double k, double n) {
return Math.pow(((k / 2.0) / (n * Math.PI)), -0.5);
}
def code(k, n): return math.pow(((k / 2.0) / (n * math.pi)), -0.5)
function code(k, n) return Float64(Float64(k / 2.0) / Float64(n * pi)) ^ -0.5 end
function tmp = code(k, n) tmp = ((k / 2.0) / (n * pi)) ^ -0.5; end
code[k_, n_] := N[Power[N[(N[(k / 2.0), $MachinePrecision] / N[(n * Pi), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{\frac{k}{2}}{n \cdot \pi}\right)}^{-0.5}
\end{array}
Initial program 99.5%
*-commutative99.5%
associate-*r*99.5%
associate-/r/99.5%
add-sqr-sqrt99.3%
sqrt-unprod99.5%
associate-*r*99.5%
*-commutative99.5%
associate-*r*99.5%
*-commutative99.5%
pow-prod-up99.5%
Applied egg-rr99.5%
sqrt-undiv89.9%
*-commutative89.9%
associate-*l*89.9%
*-commutative89.9%
Applied egg-rr89.9%
Taylor expanded in k around 0 39.2%
*-commutative39.2%
*-commutative39.2%
associate-*l*39.2%
Simplified39.2%
expm1-log1p-u37.6%
expm1-udef33.6%
pow1/233.6%
pow-flip33.6%
*-commutative33.6%
metadata-eval33.6%
Applied egg-rr33.6%
expm1-def37.6%
expm1-log1p39.3%
*-commutative39.3%
associate-*r*39.3%
*-commutative39.3%
associate-/r*39.3%
Simplified39.3%
Final simplification39.3%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (* PI (/ n k)))))
double code(double k, double n) {
return sqrt((2.0 * (((double) M_PI) * (n / k))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (Math.PI * (n / k))));
}
def code(k, n): return math.sqrt((2.0 * (math.pi * (n / k))))
function code(k, n) return sqrt(Float64(2.0 * Float64(pi * Float64(n / k)))) end
function tmp = code(k, n) tmp = sqrt((2.0 * (pi * (n / k)))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(Pi * N[(n / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \left(\pi \cdot \frac{n}{k}\right)}
\end{array}
Initial program 99.5%
*-commutative99.5%
*-commutative99.5%
associate-*r*99.5%
div-inv99.5%
expm1-log1p-u96.9%
expm1-udef84.9%
Applied egg-rr76.0%
expm1-def88.0%
expm1-log1p89.8%
*-commutative89.8%
associate-*r*89.8%
Simplified89.8%
pow-sub90.0%
pow190.0%
*-commutative90.0%
*-commutative90.0%
Applied egg-rr90.0%
Taylor expanded in k around 0 39.1%
associate-/l*39.1%
associate-/r/39.1%
Simplified39.1%
Final simplification39.1%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (/ n (/ k PI)))))
double code(double k, double n) {
return sqrt((2.0 * (n / (k / ((double) M_PI)))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (n / (k / Math.PI))));
}
def code(k, n): return math.sqrt((2.0 * (n / (k / math.pi))))
function code(k, n) return sqrt(Float64(2.0 * Float64(n / Float64(k / pi)))) end
function tmp = code(k, n) tmp = sqrt((2.0 * (n / (k / pi)))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(n / N[(k / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \frac{n}{\frac{k}{\pi}}}
\end{array}
Initial program 99.5%
*-commutative99.5%
*-commutative99.5%
associate-*r*99.5%
div-inv99.5%
expm1-log1p-u96.9%
expm1-udef84.9%
Applied egg-rr76.0%
expm1-def88.0%
expm1-log1p89.8%
*-commutative89.8%
associate-*r*89.8%
Simplified89.8%
pow-sub90.0%
pow190.0%
*-commutative90.0%
*-commutative90.0%
Applied egg-rr90.0%
Taylor expanded in k around 0 39.1%
associate-/l*39.1%
Simplified39.1%
Final simplification39.1%
herbie shell --seed 2023174
(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))))