
(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 9 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 (* n (* 2.0 PI))))
(if (<= k 1.2e-39)
(/ (pow k -0.5) (pow t_0 -0.5))
(/ 1.0 (sqrt (/ k (pow t_0 (- 1.0 k))))))))
double code(double k, double n) {
double t_0 = n * (2.0 * ((double) M_PI));
double tmp;
if (k <= 1.2e-39) {
tmp = pow(k, -0.5) / pow(t_0, -0.5);
} 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 = n * (2.0 * Math.PI);
double tmp;
if (k <= 1.2e-39) {
tmp = Math.pow(k, -0.5) / Math.pow(t_0, -0.5);
} else {
tmp = 1.0 / Math.sqrt((k / Math.pow(t_0, (1.0 - k))));
}
return tmp;
}
def code(k, n): t_0 = n * (2.0 * math.pi) tmp = 0 if k <= 1.2e-39: tmp = math.pow(k, -0.5) / math.pow(t_0, -0.5) else: tmp = 1.0 / math.sqrt((k / math.pow(t_0, (1.0 - k)))) return tmp
function code(k, n) t_0 = Float64(n * Float64(2.0 * pi)) tmp = 0.0 if (k <= 1.2e-39) tmp = Float64((k ^ -0.5) / (t_0 ^ -0.5)); 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 = n * (2.0 * pi); tmp = 0.0; if (k <= 1.2e-39) tmp = (k ^ -0.5) / (t_0 ^ -0.5); 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 * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k, 1.2e-39], N[(N[Power[k, -0.5], $MachinePrecision] / N[Power[t$95$0, -0.5], $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 := n \cdot \left(2 \cdot \pi\right)\\
\mathbf{if}\;k \leq 1.2 \cdot 10^{-39}:\\
\;\;\;\;\frac{{k}^{-0.5}}{{t\_0}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{k}{{t\_0}^{\left(1 - k\right)}}}}\\
\end{array}
\end{array}
if k < 1.20000000000000008e-39Initial program 99.3%
add-sqr-sqrt99.0%
sqrt-unprod69.2%
*-commutative69.2%
*-commutative69.2%
associate-*r*69.2%
div-sub69.2%
metadata-eval69.2%
div-inv69.2%
*-commutative69.2%
Applied egg-rr69.3%
Simplified69.5%
Taylor expanded in k around 0 69.5%
associate-/l*69.5%
Simplified69.5%
associate-/r/69.5%
Applied egg-rr69.5%
*-commutative69.5%
associate-*l/69.5%
associate-*l/69.5%
associate-*r*69.5%
sqrt-undiv99.3%
sqrt-prod98.9%
*-commutative98.9%
sqrt-prod99.3%
clear-num99.3%
div-inv99.2%
associate-/r*99.2%
pow1/299.2%
pow-flip99.2%
metadata-eval99.2%
pow1/299.2%
pow-flip99.4%
metadata-eval99.4%
Applied egg-rr99.4%
if 1.20000000000000008e-39 < k Initial program 99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r*99.8%
div-sub99.8%
metadata-eval99.8%
div-inv99.9%
*-commutative99.9%
Applied egg-rr99.9%
Simplified99.9%
clear-num99.9%
sqrt-div99.9%
metadata-eval99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*r*99.9%
Applied egg-rr99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*99.9%
Simplified99.9%
Final simplification99.7%
(FPCore (k n) :precision binary64 (if (<= k 3e-40) (/ (pow k -0.5) (pow (* n (* 2.0 PI)) -0.5)) (sqrt (/ (pow (* PI (* n 2.0)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 3e-40) {
tmp = pow(k, -0.5) / pow((n * (2.0 * ((double) M_PI))), -0.5);
} 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 <= 3e-40) {
tmp = Math.pow(k, -0.5) / Math.pow((n * (2.0 * Math.PI)), -0.5);
} 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 <= 3e-40: tmp = math.pow(k, -0.5) / math.pow((n * (2.0 * math.pi)), -0.5) 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 <= 3e-40) tmp = Float64((k ^ -0.5) / (Float64(n * Float64(2.0 * pi)) ^ -0.5)); 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 <= 3e-40) tmp = (k ^ -0.5) / ((n * (2.0 * pi)) ^ -0.5); else tmp = sqrt((((pi * (n * 2.0)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3e-40], N[(N[Power[k, -0.5], $MachinePrecision] / N[Power[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision], -0.5], $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 3 \cdot 10^{-40}:\\
\;\;\;\;\frac{{k}^{-0.5}}{{\left(n \cdot \left(2 \cdot \pi\right)\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 3.0000000000000002e-40Initial program 99.3%
add-sqr-sqrt99.0%
sqrt-unprod69.2%
*-commutative69.2%
*-commutative69.2%
associate-*r*69.2%
div-sub69.2%
metadata-eval69.2%
div-inv69.2%
*-commutative69.2%
Applied egg-rr69.3%
Simplified69.5%
Taylor expanded in k around 0 69.5%
associate-/l*69.5%
Simplified69.5%
associate-/r/69.5%
Applied egg-rr69.5%
*-commutative69.5%
associate-*l/69.5%
associate-*l/69.5%
associate-*r*69.5%
sqrt-undiv99.3%
sqrt-prod98.9%
*-commutative98.9%
sqrt-prod99.3%
clear-num99.3%
div-inv99.2%
associate-/r*99.2%
pow1/299.2%
pow-flip99.2%
metadata-eval99.2%
pow1/299.2%
pow-flip99.4%
metadata-eval99.4%
Applied egg-rr99.4%
if 3.0000000000000002e-40 < k Initial program 99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r*99.8%
div-sub99.8%
metadata-eval99.8%
div-inv99.9%
*-commutative99.9%
Applied egg-rr99.9%
Simplified99.9%
Final simplification99.7%
(FPCore (k n) :precision binary64 (if (<= k 1.75e+39) (* (sqrt (/ 2.0 k)) (sqrt (* n PI))) (sqrt (+ -1.0 (fma n (/ PI (/ k 2.0)) 1.0)))))
double code(double k, double n) {
double tmp;
if (k <= 1.75e+39) {
tmp = sqrt((2.0 / k)) * sqrt((n * ((double) M_PI)));
} else {
tmp = sqrt((-1.0 + fma(n, (((double) M_PI) / (k / 2.0)), 1.0)));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 1.75e+39) tmp = Float64(sqrt(Float64(2.0 / k)) * sqrt(Float64(n * pi))); else tmp = sqrt(Float64(-1.0 + fma(n, Float64(pi / Float64(k / 2.0)), 1.0))); end return tmp end
code[k_, n_] := If[LessEqual[k, 1.75e+39], N[(N[Sqrt[N[(2.0 / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(n * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(-1.0 + N[(n * N[(Pi / N[(k / 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.75 \cdot 10^{+39}:\\
\;\;\;\;\sqrt{\frac{2}{k}} \cdot \sqrt{n \cdot \pi}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{-1 + \mathsf{fma}\left(n, \frac{\pi}{\frac{k}{2}}, 1\right)}\\
\end{array}
\end{array}
if k < 1.7500000000000001e39Initial program 99.3%
add-sqr-sqrt99.0%
sqrt-unprod76.7%
*-commutative76.7%
*-commutative76.7%
associate-*r*76.7%
div-sub76.7%
metadata-eval76.7%
div-inv76.8%
*-commutative76.8%
Applied egg-rr76.8%
Simplified77.0%
Taylor expanded in k around 0 64.4%
associate-/l*64.3%
Simplified64.3%
clear-num64.2%
un-div-inv64.2%
associate-/l/64.3%
*-commutative64.3%
associate-/l*64.4%
*-un-lft-identity64.4%
associate-*l/64.3%
associate-*r*64.3%
sqrt-prod86.7%
associate-*l/86.7%
metadata-eval86.7%
Applied egg-rr86.7%
if 1.7500000000000001e39 < k Initial program 100.0%
Taylor expanded in k around 0 2.7%
metadata-eval2.7%
sqrt-div2.7%
*-commutative2.7%
*-commutative2.7%
sqrt-prod2.7%
sqrt-unprod2.6%
Applied egg-rr2.6%
expm1-log1p-u2.6%
expm1-undefine29.8%
associate-*l/29.8%
*-un-lft-identity29.8%
*-un-lft-identity29.8%
times-frac29.8%
metadata-eval29.8%
*-commutative29.8%
associate-*l/29.8%
*-commutative29.8%
Applied egg-rr29.8%
sub-neg29.8%
metadata-eval29.8%
+-commutative29.8%
log1p-undefine29.8%
rem-exp-log29.8%
+-commutative29.8%
associate-*r*29.8%
associate-*r/29.8%
associate-*l/29.8%
*-commutative29.8%
fma-define29.8%
*-commutative29.8%
associate-/l*29.8%
Simplified29.8%
Final simplification60.9%
(FPCore (k n) :precision binary64 (if (<= k 2e+39) (/ (pow k -0.5) (pow (* n (* 2.0 PI)) -0.5)) (sqrt (+ -1.0 (fma n (/ PI (/ k 2.0)) 1.0)))))
double code(double k, double n) {
double tmp;
if (k <= 2e+39) {
tmp = pow(k, -0.5) / pow((n * (2.0 * ((double) M_PI))), -0.5);
} else {
tmp = sqrt((-1.0 + fma(n, (((double) M_PI) / (k / 2.0)), 1.0)));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 2e+39) tmp = Float64((k ^ -0.5) / (Float64(n * Float64(2.0 * pi)) ^ -0.5)); else tmp = sqrt(Float64(-1.0 + fma(n, Float64(pi / Float64(k / 2.0)), 1.0))); end return tmp end
code[k_, n_] := If[LessEqual[k, 2e+39], N[(N[Power[k, -0.5], $MachinePrecision] / N[Power[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(-1.0 + N[(n * N[(Pi / N[(k / 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2 \cdot 10^{+39}:\\
\;\;\;\;\frac{{k}^{-0.5}}{{\left(n \cdot \left(2 \cdot \pi\right)\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{-1 + \mathsf{fma}\left(n, \frac{\pi}{\frac{k}{2}}, 1\right)}\\
\end{array}
\end{array}
if k < 1.99999999999999988e39Initial program 99.3%
add-sqr-sqrt99.0%
sqrt-unprod76.7%
*-commutative76.7%
*-commutative76.7%
associate-*r*76.7%
div-sub76.7%
metadata-eval76.7%
div-inv76.8%
*-commutative76.8%
Applied egg-rr76.8%
Simplified77.0%
Taylor expanded in k around 0 64.4%
associate-/l*64.3%
Simplified64.3%
associate-/r/64.4%
Applied egg-rr64.4%
*-commutative64.4%
associate-*l/64.4%
associate-*l/64.4%
associate-*r*64.4%
sqrt-undiv86.7%
sqrt-prod86.3%
*-commutative86.3%
sqrt-prod86.7%
clear-num86.6%
div-inv86.5%
associate-/r*86.5%
pow1/286.5%
pow-flip86.6%
metadata-eval86.6%
pow1/286.6%
pow-flip86.8%
metadata-eval86.8%
Applied egg-rr86.8%
if 1.99999999999999988e39 < k Initial program 100.0%
Taylor expanded in k around 0 2.7%
metadata-eval2.7%
sqrt-div2.7%
*-commutative2.7%
*-commutative2.7%
sqrt-prod2.7%
sqrt-unprod2.6%
Applied egg-rr2.6%
expm1-log1p-u2.6%
expm1-undefine29.8%
associate-*l/29.8%
*-un-lft-identity29.8%
*-un-lft-identity29.8%
times-frac29.8%
metadata-eval29.8%
*-commutative29.8%
associate-*l/29.8%
*-commutative29.8%
Applied egg-rr29.8%
sub-neg29.8%
metadata-eval29.8%
+-commutative29.8%
log1p-undefine29.8%
rem-exp-log29.8%
+-commutative29.8%
associate-*r*29.8%
associate-*r/29.8%
associate-*l/29.8%
*-commutative29.8%
fma-define29.8%
*-commutative29.8%
associate-/l*29.8%
Simplified29.8%
Final simplification61.0%
(FPCore (k n) :precision binary64 (/ (pow k -0.5) (pow (* n (* 2.0 PI)) (+ -0.5 (* k 0.5)))))
double code(double k, double n) {
return pow(k, -0.5) / pow((n * (2.0 * ((double) M_PI))), (-0.5 + (k * 0.5)));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) / Math.pow((n * (2.0 * Math.PI)), (-0.5 + (k * 0.5)));
}
def code(k, n): return math.pow(k, -0.5) / math.pow((n * (2.0 * math.pi)), (-0.5 + (k * 0.5)))
function code(k, n) return Float64((k ^ -0.5) / (Float64(n * Float64(2.0 * pi)) ^ Float64(-0.5 + Float64(k * 0.5)))) end
function tmp = code(k, n) tmp = (k ^ -0.5) / ((n * (2.0 * pi)) ^ (-0.5 + (k * 0.5))); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] / N[Power[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision], N[(-0.5 + N[(k * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{k}^{-0.5}}{{\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(-0.5 + k \cdot 0.5\right)}}
\end{array}
Initial program 99.6%
associate-*l/99.7%
*-lft-identity99.7%
sqr-pow99.5%
pow-sqr99.7%
*-commutative99.7%
associate-*l*99.7%
associate-*r/99.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
div-sub99.7%
metadata-eval99.7%
Simplified99.7%
div-inv99.6%
associate-*r*99.6%
*-commutative99.6%
associate-*l*99.6%
div-inv99.6%
metadata-eval99.6%
inv-pow99.6%
sqrt-pow299.6%
metadata-eval99.6%
Applied egg-rr99.6%
metadata-eval99.6%
pow-flip99.6%
pow1/299.6%
div-inv99.7%
clear-num99.6%
div-inv99.6%
associate-/r*99.6%
inv-pow99.6%
sqrt-pow299.6%
metadata-eval99.6%
pow-flip99.7%
associate-*r*99.7%
*-commutative99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Applied egg-rr99.7%
+-commutative99.7%
distribute-neg-in99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (/ (pow (* PI (* n 2.0)) (- 0.5 (/ k 2.0))) (sqrt k)))
double code(double k, double n) {
return pow((((double) M_PI) * (n * 2.0)), (0.5 - (k / 2.0))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow((Math.PI * (n * 2.0)), (0.5 - (k / 2.0))) / Math.sqrt(k);
}
def code(k, n): return math.pow((math.pi * (n * 2.0)), (0.5 - (k / 2.0))) / math.sqrt(k)
function code(k, n) return Float64((Float64(pi * Float64(n * 2.0)) ^ Float64(0.5 - Float64(k / 2.0))) / sqrt(k)) end
function tmp = code(k, n) tmp = ((pi * (n * 2.0)) ^ (0.5 - (k / 2.0))) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 - N[(k / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.6%
associate-*l/99.7%
*-lft-identity99.7%
sqr-pow99.5%
pow-sqr99.7%
*-commutative99.7%
associate-*l*99.7%
associate-*r/99.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
div-sub99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (* (sqrt (/ 2.0 k)) (sqrt (* n PI))))
double code(double k, double n) {
return sqrt((2.0 / k)) * sqrt((n * ((double) M_PI)));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 / k)) * Math.sqrt((n * Math.PI));
}
def code(k, n): return math.sqrt((2.0 / k)) * math.sqrt((n * math.pi))
function code(k, n) return Float64(sqrt(Float64(2.0 / k)) * sqrt(Float64(n * pi))) end
function tmp = code(k, n) tmp = sqrt((2.0 / k)) * sqrt((n * pi)); end
code[k_, n_] := N[(N[Sqrt[N[(2.0 / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(n * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{2}{k}} \cdot \sqrt{n \cdot \pi}
\end{array}
Initial program 99.6%
add-sqr-sqrt99.5%
sqrt-unprod87.3%
*-commutative87.3%
*-commutative87.3%
associate-*r*87.3%
div-sub87.3%
metadata-eval87.3%
div-inv87.3%
*-commutative87.3%
Applied egg-rr87.3%
Simplified87.4%
Taylor expanded in k around 0 36.4%
associate-/l*36.3%
Simplified36.3%
clear-num36.3%
un-div-inv36.3%
associate-/l/36.3%
*-commutative36.3%
associate-/l*36.4%
*-un-lft-identity36.4%
associate-*l/36.3%
associate-*r*36.3%
sqrt-prod48.7%
associate-*l/48.7%
metadata-eval48.7%
Applied egg-rr48.7%
Final simplification48.7%
(FPCore (k n) :precision binary64 (pow (/ (/ k (* n 2.0)) PI) -0.5))
double code(double k, double n) {
return pow(((k / (n * 2.0)) / ((double) M_PI)), -0.5);
}
public static double code(double k, double n) {
return Math.pow(((k / (n * 2.0)) / Math.PI), -0.5);
}
def code(k, n): return math.pow(((k / (n * 2.0)) / math.pi), -0.5)
function code(k, n) return Float64(Float64(k / Float64(n * 2.0)) / pi) ^ -0.5 end
function tmp = code(k, n) tmp = ((k / (n * 2.0)) / pi) ^ -0.5; end
code[k_, n_] := N[Power[N[(N[(k / N[(n * 2.0), $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{\frac{k}{n \cdot 2}}{\pi}\right)}^{-0.5}
\end{array}
Initial program 99.6%
add-sqr-sqrt99.5%
sqrt-unprod87.3%
*-commutative87.3%
*-commutative87.3%
associate-*r*87.3%
div-sub87.3%
metadata-eval87.3%
div-inv87.3%
*-commutative87.3%
Applied egg-rr87.3%
Simplified87.4%
Taylor expanded in k around 0 36.4%
associate-/l*36.3%
Simplified36.3%
associate-/r/36.4%
Applied egg-rr36.4%
*-commutative36.4%
associate-*l/36.4%
associate-*l/36.4%
associate-*r*36.4%
sqrt-undiv48.6%
sqrt-prod48.4%
*-commutative48.4%
sqrt-prod48.6%
clear-num48.6%
inv-pow48.6%
sqrt-undiv36.9%
sqrt-pow236.9%
*-commutative36.9%
associate-/r*36.9%
metadata-eval36.9%
Applied egg-rr36.9%
associate-/l/36.9%
associate-*r*36.9%
associate-/r*36.9%
*-commutative36.9%
Simplified36.9%
Final simplification36.9%
(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.3%
*-commutative87.3%
*-commutative87.3%
associate-*r*87.3%
div-sub87.3%
metadata-eval87.3%
div-inv87.3%
*-commutative87.3%
Applied egg-rr87.3%
Simplified87.4%
Taylor expanded in k around 0 36.4%
associate-/l*36.3%
Simplified36.3%
associate-/r/36.4%
Applied egg-rr36.4%
Final simplification36.4%
herbie shell --seed 2024036
(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))))