
(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 14 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 (if (<= k 2.45e-62) (* (sqrt (/ PI k)) (sqrt (* n 2.0))) (/ 1.0 (sqrt (/ k (pow (* PI (* n 2.0)) (- 1.0 k)))))))
double code(double k, double n) {
double tmp;
if (k <= 2.45e-62) {
tmp = sqrt((((double) M_PI) / k)) * sqrt((n * 2.0));
} else {
tmp = 1.0 / sqrt((k / pow((((double) M_PI) * (n * 2.0)), (1.0 - k))));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.45e-62) {
tmp = Math.sqrt((Math.PI / k)) * Math.sqrt((n * 2.0));
} else {
tmp = 1.0 / Math.sqrt((k / Math.pow((Math.PI * (n * 2.0)), (1.0 - k))));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.45e-62: tmp = math.sqrt((math.pi / k)) * math.sqrt((n * 2.0)) else: tmp = 1.0 / math.sqrt((k / math.pow((math.pi * (n * 2.0)), (1.0 - k)))) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.45e-62) tmp = Float64(sqrt(Float64(pi / k)) * sqrt(Float64(n * 2.0))); else tmp = Float64(1.0 / sqrt(Float64(k / (Float64(pi * Float64(n * 2.0)) ^ Float64(1.0 - k))))); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.45e-62) tmp = sqrt((pi / k)) * sqrt((n * 2.0)); else tmp = 1.0 / sqrt((k / ((pi * (n * 2.0)) ^ (1.0 - k)))); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.45e-62], N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(n * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sqrt[N[(k / N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.45 \cdot 10^{-62}:\\
\;\;\;\;\sqrt{\frac{\pi}{k}} \cdot \sqrt{n \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{k}{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(1 - k\right)}}}}\\
\end{array}
\end{array}
if k < 2.4500000000000002e-62Initial program 99.2%
add-sqr-sqrt99.1%
sqrt-unprod69.0%
*-commutative69.0%
div-inv69.0%
*-commutative69.0%
div-inv69.0%
frac-times69.0%
Applied egg-rr69.1%
Simplified69.3%
Taylor expanded in k around 0 69.3%
associate-*r/69.3%
associate-*r*69.3%
*-commutative69.3%
associate-/l*69.3%
Simplified69.3%
associate-/r/69.3%
sqrt-prod99.5%
*-commutative99.5%
Applied egg-rr99.5%
if 2.4500000000000002e-62 < k Initial program 99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
*-commutative99.8%
div-inv99.8%
*-commutative99.8%
div-inv99.8%
frac-times99.8%
Applied egg-rr99.8%
Simplified99.9%
clear-num99.9%
sqrt-div99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.7%
(FPCore (k n) :precision binary64 (let* ((t_0 (* n (* 2.0 PI)))) (/ (sqrt t_0) (sqrt (* k (pow t_0 k))))))
double code(double k, double n) {
double t_0 = n * (2.0 * ((double) M_PI));
return sqrt(t_0) / sqrt((k * pow(t_0, k)));
}
public static double code(double k, double n) {
double t_0 = n * (2.0 * Math.PI);
return Math.sqrt(t_0) / Math.sqrt((k * Math.pow(t_0, k)));
}
def code(k, n): t_0 = n * (2.0 * math.pi) return math.sqrt(t_0) / math.sqrt((k * math.pow(t_0, k)))
function code(k, n) t_0 = Float64(n * Float64(2.0 * pi)) return Float64(sqrt(t_0) / sqrt(Float64(k * (t_0 ^ k)))) end
function tmp = code(k, n) t_0 = n * (2.0 * pi); tmp = sqrt(t_0) / sqrt((k * (t_0 ^ k))); end
code[k_, n_] := Block[{t$95$0 = N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(k * N[Power[t$95$0, k], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(2 \cdot \pi\right)\\
\frac{\sqrt{t_0}}{\sqrt{k \cdot {t_0}^{k}}}
\end{array}
\end{array}
Initial program 99.6%
*-commutative99.6%
associate-*r*99.6%
div-sub99.6%
metadata-eval99.6%
div-inv99.6%
pow-sub99.7%
pow1/299.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%
Simplified99.7%
div-inv99.6%
*-commutative99.6%
pow1/299.6%
pow-unpow99.6%
pow-prod-down99.6%
*-commutative99.6%
Applied egg-rr99.6%
*-commutative99.6%
associate-*l/99.7%
*-lft-identity99.7%
*-commutative99.7%
*-commutative99.7%
associate-*l*99.7%
unpow1/299.7%
*-commutative99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (* (pow (* 2.0 (* n PI)) (- 0.5 (* k 0.5))) (pow k -0.5)))
double code(double k, double n) {
return pow((2.0 * (n * ((double) M_PI))), (0.5 - (k * 0.5))) * pow(k, -0.5);
}
public static double code(double k, double n) {
return Math.pow((2.0 * (n * Math.PI)), (0.5 - (k * 0.5))) * Math.pow(k, -0.5);
}
def code(k, n): return math.pow((2.0 * (n * math.pi)), (0.5 - (k * 0.5))) * math.pow(k, -0.5)
function code(k, n) return Float64((Float64(2.0 * Float64(n * pi)) ^ Float64(0.5 - Float64(k * 0.5))) * (k ^ -0.5)) end
function tmp = code(k, n) tmp = ((2.0 * (n * pi)) ^ (0.5 - (k * 0.5))) * (k ^ -0.5); end
code[k_, n_] := N[(N[Power[N[(2.0 * N[(n * Pi), $MachinePrecision]), $MachinePrecision], N[(0.5 - N[(k * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[k, -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\left(0.5 - k \cdot 0.5\right)} \cdot {k}^{-0.5}
\end{array}
Initial program 99.6%
associate-*l/99.6%
*-lft-identity99.6%
sqr-pow99.4%
pow-sqr99.6%
associate-*l*99.6%
*-commutative99.6%
associate-*l/99.6%
associate-/l*99.6%
metadata-eval99.6%
/-rgt-identity99.6%
div-sub99.6%
metadata-eval99.6%
Simplified99.6%
div-inv99.6%
div-inv99.6%
metadata-eval99.6%
pow1/299.6%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 1.55e-65) (* (sqrt (/ PI k)) (sqrt (* n 2.0))) (sqrt (/ (pow (* PI (* n 2.0)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 1.55e-65) {
tmp = sqrt((((double) M_PI) / k)) * sqrt((n * 2.0));
} else {
tmp = sqrt((pow((((double) M_PI) * (n * 2.0)), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1.55e-65) {
tmp = Math.sqrt((Math.PI / k)) * Math.sqrt((n * 2.0));
} else {
tmp = Math.sqrt((Math.pow((Math.PI * (n * 2.0)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 1.55e-65: tmp = math.sqrt((math.pi / k)) * math.sqrt((n * 2.0)) else: tmp = math.sqrt((math.pow((math.pi * (n * 2.0)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 1.55e-65) tmp = Float64(sqrt(Float64(pi / k)) * sqrt(Float64(n * 2.0))); else tmp = sqrt(Float64((Float64(pi * Float64(n * 2.0)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 1.55e-65) tmp = sqrt((pi / k)) * sqrt((n * 2.0)); else tmp = sqrt((((pi * (n * 2.0)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.55e-65], N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(n * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.55 \cdot 10^{-65}:\\
\;\;\;\;\sqrt{\frac{\pi}{k}} \cdot \sqrt{n \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 1.55000000000000008e-65Initial program 99.2%
add-sqr-sqrt99.0%
sqrt-unprod68.4%
*-commutative68.4%
div-inv68.4%
*-commutative68.4%
div-inv68.4%
frac-times68.4%
Applied egg-rr68.5%
Simplified68.7%
Taylor expanded in k around 0 68.7%
associate-*r/68.7%
associate-*r*68.7%
*-commutative68.7%
associate-/l*68.7%
Simplified68.7%
associate-/r/68.7%
sqrt-prod99.5%
*-commutative99.5%
Applied egg-rr99.5%
if 1.55000000000000008e-65 < k Initial program 99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
*-commutative99.8%
div-inv99.8%
*-commutative99.8%
div-inv99.8%
frac-times99.8%
Applied egg-rr99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (k n) :precision binary64 (/ (pow (* 2.0 (* n PI)) (- 0.5 (/ k 2.0))) (sqrt k)))
double code(double k, double n) {
return pow((2.0 * (n * ((double) M_PI))), (0.5 - (k / 2.0))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow((2.0 * (n * Math.PI)), (0.5 - (k / 2.0))) / Math.sqrt(k);
}
def code(k, n): return math.pow((2.0 * (n * math.pi)), (0.5 - (k / 2.0))) / math.sqrt(k)
function code(k, n) return Float64((Float64(2.0 * Float64(n * pi)) ^ Float64(0.5 - Float64(k / 2.0))) / sqrt(k)) end
function tmp = code(k, n) tmp = ((2.0 * (n * pi)) ^ (0.5 - (k / 2.0))) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(2.0 * N[(n * Pi), $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(n \cdot \pi\right)\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.6%
associate-*l/99.6%
*-lft-identity99.6%
sqr-pow99.4%
pow-sqr99.6%
associate-*l*99.6%
*-commutative99.6%
associate-*l/99.6%
associate-/l*99.6%
metadata-eval99.6%
/-rgt-identity99.6%
div-sub99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 1.6e+226) (* (sqrt (/ PI k)) (sqrt (* n 2.0))) (pow (pow (* (/ PI k) (* n 2.0)) 2.0) 0.25)))
double code(double k, double n) {
double tmp;
if (k <= 1.6e+226) {
tmp = sqrt((((double) M_PI) / k)) * sqrt((n * 2.0));
} else {
tmp = pow(pow(((((double) M_PI) / k) * (n * 2.0)), 2.0), 0.25);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1.6e+226) {
tmp = Math.sqrt((Math.PI / k)) * Math.sqrt((n * 2.0));
} else {
tmp = Math.pow(Math.pow(((Math.PI / k) * (n * 2.0)), 2.0), 0.25);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 1.6e+226: tmp = math.sqrt((math.pi / k)) * math.sqrt((n * 2.0)) else: tmp = math.pow(math.pow(((math.pi / k) * (n * 2.0)), 2.0), 0.25) return tmp
function code(k, n) tmp = 0.0 if (k <= 1.6e+226) tmp = Float64(sqrt(Float64(pi / k)) * sqrt(Float64(n * 2.0))); else tmp = (Float64(Float64(pi / k) * Float64(n * 2.0)) ^ 2.0) ^ 0.25; end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 1.6e+226) tmp = sqrt((pi / k)) * sqrt((n * 2.0)); else tmp = (((pi / k) * (n * 2.0)) ^ 2.0) ^ 0.25; end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.6e+226], N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(n * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(N[(Pi / k), $MachinePrecision] * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 0.25], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.6 \cdot 10^{+226}:\\
\;\;\;\;\sqrt{\frac{\pi}{k}} \cdot \sqrt{n \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;{\left({\left(\frac{\pi}{k} \cdot \left(n \cdot 2\right)\right)}^{2}\right)}^{0.25}\\
\end{array}
\end{array}
if k < 1.59999999999999989e226Initial program 99.5%
add-sqr-sqrt99.4%
sqrt-unprod84.5%
*-commutative84.5%
div-inv84.5%
*-commutative84.5%
div-inv84.5%
frac-times84.5%
Applied egg-rr84.6%
Simplified84.7%
Taylor expanded in k around 0 44.6%
associate-*r/44.6%
associate-*r*44.6%
*-commutative44.6%
associate-/l*44.6%
Simplified44.6%
associate-/r/44.6%
sqrt-prod59.6%
*-commutative59.6%
Applied egg-rr59.6%
if 1.59999999999999989e226 < k Initial program 100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
*-commutative100.0%
div-inv100.0%
*-commutative100.0%
div-inv100.0%
frac-times100.0%
Applied egg-rr100.0%
Simplified100.0%
Taylor expanded in k around 0 3.0%
associate-*r/3.0%
associate-*r*3.0%
*-commutative3.0%
associate-/l*3.0%
Simplified3.0%
pow1/23.0%
metadata-eval3.0%
pow-prod-up3.0%
pow-prod-down20.3%
Applied egg-rr20.3%
*-commutative20.3%
associate-*l*20.3%
*-commutative20.3%
associate-*l*20.3%
Simplified20.3%
Final simplification52.9%
(FPCore (k n) :precision binary64 (if (<= k 2.4e+228) (* (sqrt (/ PI k)) (sqrt (* n 2.0))) (cbrt (pow (* 2.0 (* PI (/ n k))) 1.5))))
double code(double k, double n) {
double tmp;
if (k <= 2.4e+228) {
tmp = sqrt((((double) M_PI) / k)) * sqrt((n * 2.0));
} else {
tmp = cbrt(pow((2.0 * (((double) M_PI) * (n / k))), 1.5));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.4e+228) {
tmp = Math.sqrt((Math.PI / k)) * Math.sqrt((n * 2.0));
} else {
tmp = Math.cbrt(Math.pow((2.0 * (Math.PI * (n / k))), 1.5));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 2.4e+228) tmp = Float64(sqrt(Float64(pi / k)) * sqrt(Float64(n * 2.0))); else tmp = cbrt((Float64(2.0 * Float64(pi * Float64(n / k))) ^ 1.5)); end return tmp end
code[k_, n_] := If[LessEqual[k, 2.4e+228], N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(n * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(2.0 * N[(Pi * N[(n / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.4 \cdot 10^{+228}:\\
\;\;\;\;\sqrt{\frac{\pi}{k}} \cdot \sqrt{n \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(2 \cdot \left(\pi \cdot \frac{n}{k}\right)\right)}^{1.5}}\\
\end{array}
\end{array}
if k < 2.39999999999999989e228Initial program 99.5%
add-sqr-sqrt99.4%
sqrt-unprod84.5%
*-commutative84.5%
div-inv84.5%
*-commutative84.5%
div-inv84.5%
frac-times84.5%
Applied egg-rr84.6%
Simplified84.7%
Taylor expanded in k around 0 44.6%
associate-*r/44.6%
associate-*r*44.6%
*-commutative44.6%
associate-/l*44.6%
Simplified44.6%
associate-/r/44.6%
sqrt-prod59.6%
*-commutative59.6%
Applied egg-rr59.6%
if 2.39999999999999989e228 < k Initial program 100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
*-commutative100.0%
div-inv100.0%
*-commutative100.0%
div-inv100.0%
frac-times100.0%
Applied egg-rr100.0%
Simplified100.0%
Taylor expanded in k around 0 3.0%
associate-*r/3.0%
associate-*r*3.0%
*-commutative3.0%
associate-/l*3.0%
Simplified3.0%
pow1/23.0%
metadata-eval3.0%
pow-pow3.0%
add-cbrt-cube13.8%
pow1/313.8%
Applied egg-rr13.8%
unpow1/313.8%
*-commutative13.8%
associate-*r*13.8%
associate-*r/13.8%
associate-*l/13.8%
associate-*r/13.8%
associate-*l*13.8%
Simplified13.8%
Final simplification51.7%
(FPCore (k n) :precision binary64 (* (sqrt (/ PI k)) (sqrt (* n 2.0))))
double code(double k, double n) {
return sqrt((((double) M_PI) / k)) * sqrt((n * 2.0));
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI / k)) * Math.sqrt((n * 2.0));
}
def code(k, n): return math.sqrt((math.pi / k)) * math.sqrt((n * 2.0))
function code(k, n) return Float64(sqrt(Float64(pi / k)) * sqrt(Float64(n * 2.0))) end
function tmp = code(k, n) tmp = sqrt((pi / k)) * sqrt((n * 2.0)); end
code[k_, n_] := N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(n * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{\pi}{k}} \cdot \sqrt{n \cdot 2}
\end{array}
Initial program 99.6%
add-sqr-sqrt99.5%
sqrt-unprod87.2%
*-commutative87.2%
div-inv87.2%
*-commutative87.2%
div-inv87.2%
frac-times87.2%
Applied egg-rr87.2%
Simplified87.3%
Taylor expanded in k around 0 37.5%
associate-*r/37.5%
associate-*r*37.5%
*-commutative37.5%
associate-/l*37.5%
Simplified37.5%
associate-/r/37.5%
sqrt-prod49.9%
*-commutative49.9%
Applied egg-rr49.9%
Final simplification49.9%
(FPCore (k n) :precision binary64 (pow (* 0.5 (/ (/ k n) PI)) -0.5))
double code(double k, double n) {
return pow((0.5 * ((k / n) / ((double) M_PI))), -0.5);
}
public static double code(double k, double n) {
return Math.pow((0.5 * ((k / n) / Math.PI)), -0.5);
}
def code(k, n): return math.pow((0.5 * ((k / n) / math.pi)), -0.5)
function code(k, n) return Float64(0.5 * Float64(Float64(k / n) / pi)) ^ -0.5 end
function tmp = code(k, n) tmp = (0.5 * ((k / n) / pi)) ^ -0.5; end
code[k_, n_] := N[Power[N[(0.5 * N[(N[(k / n), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(0.5 \cdot \frac{\frac{k}{n}}{\pi}\right)}^{-0.5}
\end{array}
Initial program 99.6%
add-sqr-sqrt99.5%
sqrt-unprod87.2%
*-commutative87.2%
div-inv87.2%
*-commutative87.2%
div-inv87.2%
frac-times87.2%
Applied egg-rr87.2%
Simplified87.3%
Taylor expanded in k around 0 37.5%
associate-*r/37.5%
associate-*r*37.5%
*-commutative37.5%
associate-/l*37.5%
Simplified37.5%
Taylor expanded in k around 0 37.5%
associate-/l*37.4%
associate-/r/37.4%
associate-*l*37.4%
*-commutative37.4%
associate-*r*37.4%
*-commutative37.4%
associate-*l*37.4%
Simplified37.4%
associate-*r/37.5%
*-commutative37.5%
metadata-eval37.5%
times-frac37.5%
*-commutative37.5%
associate-/l*37.5%
metadata-eval37.5%
add-sqr-sqrt37.4%
frac-times37.4%
sqrt-unprod38.0%
add-sqr-sqrt38.0%
inv-pow38.0%
sqrt-pow238.1%
Applied egg-rr38.1%
*-commutative38.1%
associate-/r*38.1%
Simplified38.1%
Final simplification38.1%
(FPCore (k n) :precision binary64 (pow (/ (* k 0.5) (* n PI)) -0.5))
double code(double k, double n) {
return pow(((k * 0.5) / (n * ((double) M_PI))), -0.5);
}
public static double code(double k, double n) {
return Math.pow(((k * 0.5) / (n * Math.PI)), -0.5);
}
def code(k, n): return math.pow(((k * 0.5) / (n * math.pi)), -0.5)
function code(k, n) return Float64(Float64(k * 0.5) / Float64(n * pi)) ^ -0.5 end
function tmp = code(k, n) tmp = ((k * 0.5) / (n * pi)) ^ -0.5; end
code[k_, n_] := N[Power[N[(N[(k * 0.5), $MachinePrecision] / N[(n * Pi), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{k \cdot 0.5}{n \cdot \pi}\right)}^{-0.5}
\end{array}
Initial program 99.6%
add-sqr-sqrt99.5%
sqrt-unprod87.2%
*-commutative87.2%
div-inv87.2%
*-commutative87.2%
div-inv87.2%
frac-times87.2%
Applied egg-rr87.2%
Simplified87.3%
Taylor expanded in k around 0 37.5%
associate-*r/37.5%
associate-*r*37.5%
*-commutative37.5%
associate-/l*37.5%
Simplified37.5%
Taylor expanded in k around 0 37.5%
associate-/l*37.4%
associate-/r/37.4%
associate-*l*37.4%
*-commutative37.4%
associate-*r*37.4%
*-commutative37.4%
associate-*l*37.4%
Simplified37.4%
associate-*r/37.5%
*-commutative37.5%
metadata-eval37.5%
times-frac37.5%
*-commutative37.5%
associate-/l*37.5%
metadata-eval37.5%
add-sqr-sqrt37.4%
frac-times37.4%
sqrt-unprod38.0%
add-sqr-sqrt38.0%
inv-pow38.0%
sqrt-pow238.1%
Applied egg-rr38.1%
associate-*r/38.1%
*-commutative38.1%
*-commutative38.1%
Simplified38.1%
Final simplification38.1%
(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.6%
add-sqr-sqrt99.5%
sqrt-unprod87.2%
*-commutative87.2%
div-inv87.2%
*-commutative87.2%
div-inv87.2%
frac-times87.2%
Applied egg-rr87.2%
Simplified87.3%
Taylor expanded in k around 0 37.5%
associate-*r/37.5%
associate-*r*37.5%
*-commutative37.5%
associate-/l*37.5%
Simplified37.5%
Taylor expanded in k around 0 37.5%
associate-/l*37.4%
associate-/r/37.4%
associate-*l*37.4%
*-commutative37.4%
associate-*r*37.4%
*-commutative37.4%
associate-*l*37.4%
Simplified37.4%
Final simplification37.4%
(FPCore (k n) :precision binary64 (sqrt (* (/ PI k) (/ n 0.5))))
double code(double k, double n) {
return sqrt(((((double) M_PI) / k) * (n / 0.5)));
}
public static double code(double k, double n) {
return Math.sqrt(((Math.PI / k) * (n / 0.5)));
}
def code(k, n): return math.sqrt(((math.pi / k) * (n / 0.5)))
function code(k, n) return sqrt(Float64(Float64(pi / k) * Float64(n / 0.5))) end
function tmp = code(k, n) tmp = sqrt(((pi / k) * (n / 0.5))); end
code[k_, n_] := N[Sqrt[N[(N[(Pi / k), $MachinePrecision] * N[(n / 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{\pi}{k} \cdot \frac{n}{0.5}}
\end{array}
Initial program 99.6%
add-sqr-sqrt99.5%
sqrt-unprod87.2%
*-commutative87.2%
div-inv87.2%
*-commutative87.2%
div-inv87.2%
frac-times87.2%
Applied egg-rr87.2%
Simplified87.3%
Taylor expanded in k around 0 37.5%
associate-*r/37.5%
associate-*r*37.5%
*-commutative37.5%
associate-/l*37.5%
Simplified37.5%
add-sqr-sqrt37.2%
*-un-lft-identity37.2%
times-frac37.3%
associate-/r*37.3%
div-inv37.3%
metadata-eval37.3%
Applied egg-rr37.3%
/-rgt-identity37.3%
associate-*r/37.2%
rem-square-sqrt37.5%
associate-/l*37.5%
associate-/r/37.5%
Simplified37.5%
Final simplification37.5%
(FPCore (k n) :precision binary64 (sqrt (/ PI (/ k (* n 2.0)))))
double code(double k, double n) {
return sqrt((((double) M_PI) / (k / (n * 2.0))));
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI / (k / (n * 2.0))));
}
def code(k, n): return math.sqrt((math.pi / (k / (n * 2.0))))
function code(k, n) return sqrt(Float64(pi / Float64(k / Float64(n * 2.0)))) end
function tmp = code(k, n) tmp = sqrt((pi / (k / (n * 2.0)))); end
code[k_, n_] := N[Sqrt[N[(Pi / N[(k / N[(n * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{\pi}{\frac{k}{n \cdot 2}}}
\end{array}
Initial program 99.6%
add-sqr-sqrt99.5%
sqrt-unprod87.2%
*-commutative87.2%
div-inv87.2%
*-commutative87.2%
div-inv87.2%
frac-times87.2%
Applied egg-rr87.2%
Simplified87.3%
Taylor expanded in k around 0 37.5%
associate-*r/37.5%
associate-*r*37.5%
*-commutative37.5%
associate-/l*37.5%
Simplified37.5%
Final simplification37.5%
(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 * Float64(n * 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[(n * 2.0), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{\pi \cdot \left(n \cdot 2\right)}{k}}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0 49.7%
associate-*l/49.7%
*-un-lft-identity49.7%
sqrt-unprod49.8%
*-commutative49.8%
associate-*l*49.8%
sqrt-undiv37.5%
*-commutative37.5%
Applied egg-rr37.5%
Final simplification37.5%
herbie shell --seed 2023301
(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))))