
(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 11 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 (/ (sqrt (* (/ PI (pow (* 2.0 (* PI n)) k)) (* 2.0 n))) (sqrt k)))
double code(double k, double n) {
return sqrt(((((double) M_PI) / pow((2.0 * (((double) M_PI) * n)), k)) * (2.0 * n))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.sqrt(((Math.PI / Math.pow((2.0 * (Math.PI * n)), k)) * (2.0 * n))) / Math.sqrt(k);
}
def code(k, n): return math.sqrt(((math.pi / math.pow((2.0 * (math.pi * n)), k)) * (2.0 * n))) / math.sqrt(k)
function code(k, n) return Float64(sqrt(Float64(Float64(pi / (Float64(2.0 * Float64(pi * n)) ^ k)) * Float64(2.0 * n))) / sqrt(k)) end
function tmp = code(k, n) tmp = sqrt(((pi / ((2.0 * (pi * n)) ^ k)) * (2.0 * n))) / sqrt(k); end
code[k_, n_] := N[(N[Sqrt[N[(N[(Pi / N[Power[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision], k], $MachinePrecision]), $MachinePrecision] * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{\frac{\pi}{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{k}} \cdot \left(2 \cdot n\right)}}{\sqrt{k}}
\end{array}
Initial program 99.5%
*-commutative99.5%
*-commutative99.5%
associate-*r*99.5%
div-inv99.5%
expm1-log1p-u97.1%
expm1-udef85.6%
Applied egg-rr76.0%
expm1-def87.6%
expm1-log1p89.0%
*-commutative89.0%
associate-*r*89.0%
*-commutative89.0%
Simplified89.0%
pow-sub89.2%
pow189.2%
*-commutative89.2%
*-commutative89.2%
*-commutative89.2%
*-commutative89.2%
*-commutative89.2%
*-commutative89.2%
Applied egg-rr89.2%
associate-/l*89.2%
associate-/r/89.3%
*-commutative89.3%
associate-*l*89.3%
*-commutative89.3%
Simplified89.3%
sqrt-div99.7%
*-commutative99.7%
associate-*r*99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (/ (pow k -0.5) (pow (pow (* n (* PI 2.0)) (- 1.0 k)) -0.5)))
double code(double k, double n) {
return pow(k, -0.5) / pow(pow((n * (((double) M_PI) * 2.0)), (1.0 - k)), -0.5);
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) / Math.pow(Math.pow((n * (Math.PI * 2.0)), (1.0 - k)), -0.5);
}
def code(k, n): return math.pow(k, -0.5) / math.pow(math.pow((n * (math.pi * 2.0)), (1.0 - k)), -0.5)
function code(k, n) return Float64((k ^ -0.5) / ((Float64(n * Float64(pi * 2.0)) ^ Float64(1.0 - k)) ^ -0.5)) end
function tmp = code(k, n) tmp = (k ^ -0.5) / (((n * (pi * 2.0)) ^ (1.0 - k)) ^ -0.5); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] / N[Power[N[Power[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{k}^{-0.5}}{{\left({\left(n \cdot \left(\pi \cdot 2\right)\right)}^{\left(1 - k\right)}\right)}^{-0.5}}
\end{array}
Initial program 99.5%
*-commutative99.5%
associate-*r*99.5%
associate-/r/99.4%
add-sqr-sqrt99.3%
sqrt-unprod99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
pow-prod-up99.4%
Applied egg-rr99.4%
pow-sub99.6%
pow199.6%
Applied egg-rr99.6%
inv-pow99.6%
div-inv99.6%
unpow-prod-down99.6%
inv-pow99.6%
pow1/299.6%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.5%
unpow-199.5%
associate-*r/99.5%
*-rgt-identity99.5%
*-commutative99.5%
*-commutative99.5%
associate-*l*99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (k n) :precision binary64 (if (<= k 1e-42) (* (sqrt n) (sqrt (* PI (/ 2.0 k)))) (pow (/ k (pow (* n (* PI 2.0)) (- 1.0 k))) -0.5)))
double code(double k, double n) {
double tmp;
if (k <= 1e-42) {
tmp = sqrt(n) * sqrt((((double) M_PI) * (2.0 / k)));
} else {
tmp = pow((k / pow((n * (((double) M_PI) * 2.0)), (1.0 - k))), -0.5);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1e-42) {
tmp = Math.sqrt(n) * Math.sqrt((Math.PI * (2.0 / k)));
} else {
tmp = Math.pow((k / Math.pow((n * (Math.PI * 2.0)), (1.0 - k))), -0.5);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 1e-42: tmp = math.sqrt(n) * math.sqrt((math.pi * (2.0 / k))) else: tmp = math.pow((k / math.pow((n * (math.pi * 2.0)), (1.0 - k))), -0.5) return tmp
function code(k, n) tmp = 0.0 if (k <= 1e-42) tmp = Float64(sqrt(n) * sqrt(Float64(pi * Float64(2.0 / k)))); else tmp = Float64(k / (Float64(n * Float64(pi * 2.0)) ^ Float64(1.0 - k))) ^ -0.5; end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 1e-42) tmp = sqrt(n) * sqrt((pi * (2.0 / k))); else tmp = (k / ((n * (pi * 2.0)) ^ (1.0 - k))) ^ -0.5; end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1e-42], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(k / N[Power[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 10^{-42}:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{\pi \cdot \frac{2}{k}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{k}{{\left(n \cdot \left(\pi \cdot 2\right)\right)}^{\left(1 - k\right)}}\right)}^{-0.5}\\
\end{array}
\end{array}
if k < 1.00000000000000004e-42Initial program 99.3%
Taylor expanded in n around 0 92.1%
Taylor expanded in k around 0 92.1%
*-commutative92.1%
exp-prod92.1%
log-prod92.8%
associate-*r*92.8%
log-prod92.3%
exp-sum92.5%
rem-exp-log92.5%
rem-exp-log99.4%
*-commutative99.4%
associate-*r*99.4%
unpow1/299.4%
*-commutative99.4%
associate-*l*99.4%
Simplified99.4%
sqrt-unprod72.5%
pow1/272.5%
*-commutative72.5%
associate-*r*72.5%
Applied egg-rr72.5%
*-commutative72.5%
unpow1/272.5%
*-commutative72.5%
associate-*l*72.5%
*-commutative72.5%
*-commutative72.5%
associate-*l/72.5%
metadata-eval72.5%
Simplified72.5%
associate-*l*72.5%
sqrt-prod99.4%
Applied egg-rr99.4%
if 1.00000000000000004e-42 < k Initial program 99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r*99.6%
div-inv99.5%
expm1-log1p-u99.3%
expm1-udef94.6%
Applied egg-rr94.6%
expm1-def99.3%
expm1-log1p99.6%
*-commutative99.6%
associate-*r*99.6%
*-commutative99.6%
Simplified99.6%
pow-sub100.0%
pow1100.0%
*-commutative100.0%
*-commutative100.0%
*-commutative100.0%
*-commutative100.0%
*-commutative100.0%
*-commutative100.0%
Applied egg-rr100.0%
associate-/l*99.9%
associate-/r/100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
Simplified100.0%
sqrt-div99.9%
*-commutative99.9%
associate-*r*99.9%
Applied egg-rr99.9%
clear-num99.9%
associate-*l/99.9%
*-commutative99.9%
pow199.9%
*-commutative99.9%
associate-*r*99.9%
pow-sub99.6%
sqrt-div99.6%
pow1/299.6%
pow-flip99.6%
Applied egg-rr99.6%
Simplified99.6%
Final simplification99.5%
(FPCore (k n) :precision binary64 (* (pow k -0.5) (pow (* n (* PI 2.0)) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return pow(k, -0.5) * pow((n * (((double) M_PI) * 2.0)), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) * Math.pow((n * (Math.PI * 2.0)), ((1.0 - k) / 2.0));
}
def code(k, n): return math.pow(k, -0.5) * math.pow((n * (math.pi * 2.0)), ((1.0 - k) / 2.0))
function code(k, n) return Float64((k ^ -0.5) * (Float64(n * Float64(pi * 2.0)) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = (k ^ -0.5) * ((n * (pi * 2.0)) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{k}^{-0.5} \cdot {\left(n \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Initial program 99.5%
expm1-log1p-u96.3%
expm1-udef74.1%
inv-pow74.1%
sqrt-pow274.1%
metadata-eval74.1%
Applied egg-rr74.1%
expm1-def96.3%
expm1-log1p99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (k n) :precision binary64 (if (<= k 3e-34) (* (sqrt n) (sqrt (* PI (/ 2.0 k)))) (sqrt (/ (pow (* PI (* 2.0 n)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 3e-34) {
tmp = sqrt(n) * sqrt((((double) M_PI) * (2.0 / k)));
} else {
tmp = sqrt((pow((((double) M_PI) * (2.0 * n)), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 3e-34) {
tmp = Math.sqrt(n) * Math.sqrt((Math.PI * (2.0 / k)));
} else {
tmp = Math.sqrt((Math.pow((Math.PI * (2.0 * n)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 3e-34: tmp = math.sqrt(n) * math.sqrt((math.pi * (2.0 / k))) else: tmp = math.sqrt((math.pow((math.pi * (2.0 * n)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 3e-34) tmp = Float64(sqrt(n) * sqrt(Float64(pi * Float64(2.0 / k)))); else tmp = sqrt(Float64((Float64(pi * Float64(2.0 * n)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 3e-34) tmp = sqrt(n) * sqrt((pi * (2.0 / k))); else tmp = sqrt((((pi * (2.0 * n)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3e-34], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3 \cdot 10^{-34}:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{\pi \cdot \frac{2}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 3e-34Initial program 99.3%
Taylor expanded in n around 0 92.2%
Taylor expanded in k around 0 92.2%
*-commutative92.2%
exp-prod92.2%
log-prod92.8%
associate-*r*92.8%
log-prod92.3%
exp-sum92.6%
rem-exp-log92.6%
rem-exp-log99.4%
*-commutative99.4%
associate-*r*99.4%
unpow1/299.4%
*-commutative99.4%
associate-*l*99.4%
Simplified99.4%
sqrt-unprod73.6%
pow1/273.6%
*-commutative73.6%
associate-*r*73.6%
Applied egg-rr73.6%
*-commutative73.6%
unpow1/273.6%
*-commutative73.6%
associate-*l*73.6%
*-commutative73.6%
*-commutative73.6%
associate-*l/73.6%
metadata-eval73.6%
Simplified73.6%
associate-*l*73.5%
sqrt-prod99.4%
Applied egg-rr99.4%
if 3e-34 < k Initial program 99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r*99.6%
div-inv99.6%
expm1-log1p-u99.3%
expm1-udef95.8%
Applied egg-rr95.8%
expm1-def99.4%
expm1-log1p99.6%
*-commutative99.6%
associate-*r*99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.5%
(FPCore (k n) :precision binary64 (/ (pow (* PI (* 2.0 n)) (/ (- 1.0 k) 2.0)) (sqrt k)))
double code(double k, double n) {
return pow((((double) M_PI) * (2.0 * n)), ((1.0 - k) / 2.0)) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow((Math.PI * (2.0 * n)), ((1.0 - k) / 2.0)) / Math.sqrt(k);
}
def code(k, n): return math.pow((math.pi * (2.0 * n)), ((1.0 - k) / 2.0)) / math.sqrt(k)
function code(k, n) return Float64((Float64(pi * Float64(2.0 * n)) ^ Float64(Float64(1.0 - k) / 2.0)) / sqrt(k)) end
function tmp = code(k, n) tmp = ((pi * (2.0 * n)) ^ ((1.0 - k) / 2.0)) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\pi \cdot \left(2 \cdot n\right)\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 (if (<= k 5e+236) (* (sqrt n) (sqrt (* PI (/ 2.0 k)))) (cbrt (pow (* PI (/ n (/ k 2.0))) 1.5))))
double code(double k, double n) {
double tmp;
if (k <= 5e+236) {
tmp = sqrt(n) * sqrt((((double) M_PI) * (2.0 / k)));
} else {
tmp = cbrt(pow((((double) M_PI) * (n / (k / 2.0))), 1.5));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 5e+236) {
tmp = Math.sqrt(n) * Math.sqrt((Math.PI * (2.0 / k)));
} else {
tmp = Math.cbrt(Math.pow((Math.PI * (n / (k / 2.0))), 1.5));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 5e+236) tmp = Float64(sqrt(n) * sqrt(Float64(pi * Float64(2.0 / k)))); else tmp = cbrt((Float64(pi * Float64(n / Float64(k / 2.0))) ^ 1.5)); end return tmp end
code[k_, n_] := If[LessEqual[k, 5e+236], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(Pi * N[(n / N[(k / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 5 \cdot 10^{+236}:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{\pi \cdot \frac{2}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(\pi \cdot \frac{n}{\frac{k}{2}}\right)}^{1.5}}\\
\end{array}
\end{array}
if k < 4.9999999999999997e236Initial program 99.4%
Taylor expanded in n around 0 95.7%
Taylor expanded in k around 0 50.4%
*-commutative50.4%
exp-prod50.4%
log-prod50.7%
associate-*r*50.7%
log-prod50.5%
exp-sum50.6%
rem-exp-log50.6%
rem-exp-log54.1%
*-commutative54.1%
associate-*r*54.1%
unpow1/254.1%
*-commutative54.1%
associate-*l*54.1%
Simplified54.1%
sqrt-unprod41.7%
pow1/241.7%
*-commutative41.7%
associate-*r*41.7%
Applied egg-rr41.7%
*-commutative41.7%
unpow1/241.7%
*-commutative41.7%
associate-*l*41.7%
*-commutative41.7%
*-commutative41.7%
associate-*l/41.7%
metadata-eval41.7%
Simplified41.7%
associate-*l*41.7%
sqrt-prod54.1%
Applied egg-rr54.1%
if 4.9999999999999997e236 < k Initial program 100.0%
Taylor expanded in n around 0 100.0%
Taylor expanded in k around 0 2.9%
*-commutative2.9%
exp-prod2.9%
log-prod2.9%
associate-*r*2.9%
log-prod2.9%
exp-sum2.9%
rem-exp-log2.9%
rem-exp-log2.9%
*-commutative2.9%
associate-*r*2.9%
unpow1/22.9%
*-commutative2.9%
associate-*l*2.9%
Simplified2.9%
sqrt-unprod2.8%
pow1/22.8%
*-commutative2.8%
associate-*r*2.8%
Applied egg-rr2.8%
*-commutative2.8%
unpow1/22.8%
*-commutative2.8%
associate-*l*2.8%
*-commutative2.8%
*-commutative2.8%
associate-*l/2.8%
metadata-eval2.8%
Simplified2.8%
add-cbrt-cube15.3%
pow1/315.3%
add-sqr-sqrt15.3%
pow115.3%
pow1/215.3%
pow-prod-up15.3%
*-commutative15.3%
associate-*r*15.3%
metadata-eval15.3%
Applied egg-rr15.3%
unpow1/315.3%
*-commutative15.3%
associate-*l/15.3%
*-commutative15.3%
associate-/l*15.3%
Simplified15.3%
Final simplification48.3%
(FPCore (k n) :precision binary64 (* (sqrt n) (sqrt (* PI (/ 2.0 k)))))
double code(double k, double n) {
return sqrt(n) * sqrt((((double) M_PI) * (2.0 / k)));
}
public static double code(double k, double n) {
return Math.sqrt(n) * Math.sqrt((Math.PI * (2.0 / k)));
}
def code(k, n): return math.sqrt(n) * math.sqrt((math.pi * (2.0 / k)))
function code(k, n) return Float64(sqrt(n) * sqrt(Float64(pi * Float64(2.0 / k)))) end
function tmp = code(k, n) tmp = sqrt(n) * sqrt((pi * (2.0 / k))); end
code[k_, n_] := N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{n} \cdot \sqrt{\pi \cdot \frac{2}{k}}
\end{array}
Initial program 99.5%
Taylor expanded in n around 0 96.3%
Taylor expanded in k around 0 43.3%
*-commutative43.3%
exp-prod43.3%
log-prod43.6%
associate-*r*43.6%
log-prod43.4%
exp-sum43.5%
rem-exp-log43.5%
rem-exp-log46.5%
*-commutative46.5%
associate-*r*46.5%
unpow1/246.5%
*-commutative46.5%
associate-*l*46.5%
Simplified46.5%
sqrt-unprod36.0%
pow1/236.0%
*-commutative36.0%
associate-*r*36.0%
Applied egg-rr36.0%
*-commutative36.0%
unpow1/236.0%
*-commutative36.0%
associate-*l*36.0%
*-commutative36.0%
*-commutative36.0%
associate-*l/36.0%
metadata-eval36.0%
Simplified36.0%
associate-*l*35.9%
sqrt-prod46.5%
Applied egg-rr46.5%
Final simplification46.5%
(FPCore (k n) :precision binary64 (sqrt (* PI (/ n (/ k 2.0)))))
double code(double k, double n) {
return sqrt((((double) M_PI) * (n / (k / 2.0))));
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI * (n / (k / 2.0))));
}
def code(k, n): return math.sqrt((math.pi * (n / (k / 2.0))))
function code(k, n) return sqrt(Float64(pi * Float64(n / Float64(k / 2.0)))) end
function tmp = code(k, n) tmp = sqrt((pi * (n / (k / 2.0)))); end
code[k_, n_] := N[Sqrt[N[(Pi * N[(n / N[(k / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\pi \cdot \frac{n}{\frac{k}{2}}}
\end{array}
Initial program 99.5%
Taylor expanded in n around 0 96.3%
Taylor expanded in k around 0 43.3%
*-commutative43.3%
exp-prod43.3%
log-prod43.6%
associate-*r*43.6%
log-prod43.4%
exp-sum43.5%
rem-exp-log43.5%
rem-exp-log46.5%
*-commutative46.5%
associate-*r*46.5%
unpow1/246.5%
*-commutative46.5%
associate-*l*46.5%
Simplified46.5%
sqrt-unprod36.0%
pow1/236.0%
*-commutative36.0%
associate-*r*36.0%
Applied egg-rr36.0%
*-commutative36.0%
unpow1/236.0%
*-commutative36.0%
associate-*l*36.0%
*-commutative36.0%
*-commutative36.0%
associate-*l/36.0%
metadata-eval36.0%
Simplified36.0%
Taylor expanded in n around 0 36.0%
associate-*r/36.0%
associate-*r*36.0%
*-commutative36.0%
associate-*r/35.9%
*-commutative35.9%
associate-/l*35.9%
Simplified35.9%
Final simplification35.9%
(FPCore (k n) :precision binary64 (sqrt (* (* PI n) (/ 2.0 k))))
double code(double k, double n) {
return sqrt(((((double) M_PI) * n) * (2.0 / k)));
}
public static double code(double k, double n) {
return Math.sqrt(((Math.PI * n) * (2.0 / k)));
}
def code(k, n): return math.sqrt(((math.pi * n) * (2.0 / k)))
function code(k, n) return sqrt(Float64(Float64(pi * n) * Float64(2.0 / k))) end
function tmp = code(k, n) tmp = sqrt(((pi * n) * (2.0 / k))); end
code[k_, n_] := N[Sqrt[N[(N[(Pi * n), $MachinePrecision] * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left(\pi \cdot n\right) \cdot \frac{2}{k}}
\end{array}
Initial program 99.5%
Taylor expanded in n around 0 96.3%
Taylor expanded in k around 0 43.3%
*-commutative43.3%
exp-prod43.3%
log-prod43.6%
associate-*r*43.6%
log-prod43.4%
exp-sum43.5%
rem-exp-log43.5%
rem-exp-log46.5%
*-commutative46.5%
associate-*r*46.5%
unpow1/246.5%
*-commutative46.5%
associate-*l*46.5%
Simplified46.5%
sqrt-unprod36.0%
pow1/236.0%
*-commutative36.0%
associate-*r*36.0%
Applied egg-rr36.0%
*-commutative36.0%
unpow1/236.0%
*-commutative36.0%
associate-*l*36.0%
*-commutative36.0%
*-commutative36.0%
associate-*l/36.0%
metadata-eval36.0%
Simplified36.0%
Final simplification36.0%
(FPCore (k n) :precision binary64 (sqrt (/ (* n (* PI 2.0)) k)))
double code(double k, double n) {
return sqrt(((n * (((double) M_PI) * 2.0)) / k));
}
public static double code(double k, double n) {
return Math.sqrt(((n * (Math.PI * 2.0)) / k));
}
def code(k, n): return math.sqrt(((n * (math.pi * 2.0)) / k))
function code(k, n) return sqrt(Float64(Float64(n * Float64(pi * 2.0)) / k)) end
function tmp = code(k, n) tmp = sqrt(((n * (pi * 2.0)) / k)); end
code[k_, n_] := N[Sqrt[N[(N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{n \cdot \left(\pi \cdot 2\right)}{k}}
\end{array}
Initial program 99.5%
Taylor expanded in n around 0 96.3%
Taylor expanded in k around 0 43.3%
*-commutative43.3%
exp-prod43.3%
log-prod43.6%
associate-*r*43.6%
log-prod43.4%
exp-sum43.5%
rem-exp-log43.5%
rem-exp-log46.5%
*-commutative46.5%
associate-*r*46.5%
unpow1/246.5%
*-commutative46.5%
associate-*l*46.5%
Simplified46.5%
sqrt-unprod36.0%
pow1/236.0%
*-commutative36.0%
associate-*r*36.0%
Applied egg-rr36.0%
*-commutative36.0%
unpow1/236.0%
*-commutative36.0%
associate-*l*36.0%
*-commutative36.0%
*-commutative36.0%
associate-*l/36.0%
metadata-eval36.0%
Simplified36.0%
Taylor expanded in n around 0 36.0%
associate-*r/36.0%
associate-*r*36.0%
*-commutative36.0%
associate-*r*36.0%
*-commutative36.0%
Simplified36.0%
Final simplification36.0%
herbie shell --seed 2023200
(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))))