
(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 18 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 (* PI n)))) (/ (* (sqrt (/ 1.0 k)) (sqrt t_0)) (pow t_0 (* k 0.5)))))
double code(double k, double n) {
double t_0 = 2.0 * (((double) M_PI) * n);
return (sqrt((1.0 / k)) * sqrt(t_0)) / pow(t_0, (k * 0.5));
}
public static double code(double k, double n) {
double t_0 = 2.0 * (Math.PI * n);
return (Math.sqrt((1.0 / k)) * Math.sqrt(t_0)) / Math.pow(t_0, (k * 0.5));
}
def code(k, n): t_0 = 2.0 * (math.pi * n) return (math.sqrt((1.0 / k)) * math.sqrt(t_0)) / math.pow(t_0, (k * 0.5))
function code(k, n) t_0 = Float64(2.0 * Float64(pi * n)) return Float64(Float64(sqrt(Float64(1.0 / k)) * sqrt(t_0)) / (t_0 ^ Float64(k * 0.5))) end
function tmp = code(k, n) t_0 = 2.0 * (pi * n); tmp = (sqrt((1.0 / k)) * sqrt(t_0)) / (t_0 ^ (k * 0.5)); end
code[k_, n_] := Block[{t$95$0 = N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Sqrt[N[(1.0 / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision] / N[Power[t$95$0, N[(k * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \left(\pi \cdot n\right)\\
\frac{\sqrt{\frac{1}{k}} \cdot \sqrt{t\_0}}{{t\_0}^{\left(k \cdot 0.5\right)}}
\end{array}
\end{array}
Initial program 99.4%
associate-*r*99.4%
div-sub99.4%
metadata-eval99.4%
pow-div99.6%
pow1/299.6%
associate-*r/99.6%
pow1/299.6%
pow-flip99.7%
metadata-eval99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in k around 0 99.7%
(FPCore (k n) :precision binary64 (let* ((t_0 (* 2.0 (* PI n)))) (/ (* (sqrt t_0) (pow k -0.5)) (pow t_0 (* k 0.5)))))
double code(double k, double n) {
double t_0 = 2.0 * (((double) M_PI) * n);
return (sqrt(t_0) * pow(k, -0.5)) / pow(t_0, (k * 0.5));
}
public static double code(double k, double n) {
double t_0 = 2.0 * (Math.PI * n);
return (Math.sqrt(t_0) * Math.pow(k, -0.5)) / Math.pow(t_0, (k * 0.5));
}
def code(k, n): t_0 = 2.0 * (math.pi * n) return (math.sqrt(t_0) * math.pow(k, -0.5)) / math.pow(t_0, (k * 0.5))
function code(k, n) t_0 = Float64(2.0 * Float64(pi * n)) return Float64(Float64(sqrt(t_0) * (k ^ -0.5)) / (t_0 ^ Float64(k * 0.5))) end
function tmp = code(k, n) t_0 = 2.0 * (pi * n); tmp = (sqrt(t_0) * (k ^ -0.5)) / (t_0 ^ (k * 0.5)); end
code[k_, n_] := Block[{t$95$0 = N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Sqrt[t$95$0], $MachinePrecision] * N[Power[k, -0.5], $MachinePrecision]), $MachinePrecision] / N[Power[t$95$0, N[(k * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \left(\pi \cdot n\right)\\
\frac{\sqrt{t\_0} \cdot {k}^{-0.5}}{{t\_0}^{\left(k \cdot 0.5\right)}}
\end{array}
\end{array}
Initial program 99.4%
associate-*r*99.4%
div-sub99.4%
metadata-eval99.4%
pow-div99.6%
pow1/299.6%
associate-*r/99.6%
pow1/299.6%
pow-flip99.7%
metadata-eval99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (let* ((t_0 (* n (* 2.0 PI)))) (/ (* (sqrt t_0) (pow t_0 (* k -0.5))) (sqrt k))))
double code(double k, double n) {
double t_0 = n * (2.0 * ((double) M_PI));
return (sqrt(t_0) * pow(t_0, (k * -0.5))) / sqrt(k);
}
public static double code(double k, double n) {
double t_0 = n * (2.0 * Math.PI);
return (Math.sqrt(t_0) * Math.pow(t_0, (k * -0.5))) / Math.sqrt(k);
}
def code(k, n): t_0 = n * (2.0 * math.pi) return (math.sqrt(t_0) * math.pow(t_0, (k * -0.5))) / math.sqrt(k)
function code(k, n) t_0 = Float64(n * Float64(2.0 * pi)) return Float64(Float64(sqrt(t_0) * (t_0 ^ Float64(k * -0.5))) / sqrt(k)) end
function tmp = code(k, n) t_0 = n * (2.0 * pi); tmp = (sqrt(t_0) * (t_0 ^ (k * -0.5))) / sqrt(k); end
code[k_, n_] := Block[{t$95$0 = N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Sqrt[t$95$0], $MachinePrecision] * N[Power[t$95$0, N[(k * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(2 \cdot \pi\right)\\
\frac{\sqrt{t\_0} \cdot {t\_0}^{\left(k \cdot -0.5\right)}}{\sqrt{k}}
\end{array}
\end{array}
Initial program 99.4%
associate-*l/99.5%
*-lft-identity99.5%
associate-*l*99.5%
div-sub99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in k around inf 96.8%
exp-to-pow99.5%
*-commutative99.5%
cancel-sign-sub-inv99.5%
unpow-prod-up99.7%
pow1/299.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (let* ((t_0 (* PI (* 2.0 n)))) (/ (sqrt t_0) (* (sqrt k) (pow t_0 (* k 0.5))))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (2.0 * n);
return sqrt(t_0) / (sqrt(k) * pow(t_0, (k * 0.5)));
}
public static double code(double k, double n) {
double t_0 = Math.PI * (2.0 * n);
return Math.sqrt(t_0) / (Math.sqrt(k) * Math.pow(t_0, (k * 0.5)));
}
def code(k, n): t_0 = math.pi * (2.0 * n) return math.sqrt(t_0) / (math.sqrt(k) * math.pow(t_0, (k * 0.5)))
function code(k, n) t_0 = Float64(pi * Float64(2.0 * n)) return Float64(sqrt(t_0) / Float64(sqrt(k) * (t_0 ^ Float64(k * 0.5)))) end
function tmp = code(k, n) t_0 = pi * (2.0 * n); tmp = sqrt(t_0) / (sqrt(k) * (t_0 ^ (k * 0.5))); end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]}, N[(N[Sqrt[t$95$0], $MachinePrecision] / N[(N[Sqrt[k], $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)\\
\frac{\sqrt{t\_0}}{\sqrt{k} \cdot {t\_0}^{\left(k \cdot 0.5\right)}}
\end{array}
\end{array}
Initial program 99.4%
associate-*l/99.5%
*-un-lft-identity99.5%
associate-*r*99.5%
div-sub99.5%
metadata-eval99.5%
pow-div99.7%
pow1/299.7%
associate-/l/99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
associate-/l/99.7%
unpow1/299.7%
metadata-eval99.7%
pow-sqr99.5%
fabs-sqr99.5%
pow-sqr99.7%
metadata-eval99.7%
unpow1/299.7%
fabs-neg99.7%
neg-mul-199.7%
rem-square-sqrt0.0%
unpow1/20.0%
metadata-eval0.0%
pow-sqr0.0%
unswap-sqr0.0%
fabs-sqr0.0%
unswap-sqr0.0%
rem-square-sqrt31.3%
pow-sqr31.3%
metadata-eval31.3%
unpow1/231.3%
Simplified99.7%
(FPCore (k n) :precision binary64 (if (<= k 2.7e-63) (* (/ 1.0 (sqrt (/ k PI))) (sqrt (* 2.0 n))) (pow (/ k (pow (* n (* 2.0 PI)) (- 1.0 k))) -0.5)))
double code(double k, double n) {
double tmp;
if (k <= 2.7e-63) {
tmp = (1.0 / sqrt((k / ((double) M_PI)))) * sqrt((2.0 * n));
} else {
tmp = pow((k / pow((n * (2.0 * ((double) M_PI))), (1.0 - k))), -0.5);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.7e-63) {
tmp = (1.0 / Math.sqrt((k / Math.PI))) * Math.sqrt((2.0 * n));
} else {
tmp = Math.pow((k / Math.pow((n * (2.0 * Math.PI)), (1.0 - k))), -0.5);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.7e-63: tmp = (1.0 / math.sqrt((k / math.pi))) * math.sqrt((2.0 * n)) else: tmp = math.pow((k / math.pow((n * (2.0 * math.pi)), (1.0 - k))), -0.5) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.7e-63) tmp = Float64(Float64(1.0 / sqrt(Float64(k / pi))) * sqrt(Float64(2.0 * n))); else tmp = Float64(k / (Float64(n * Float64(2.0 * pi)) ^ Float64(1.0 - k))) ^ -0.5; end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.7e-63) tmp = (1.0 / sqrt((k / pi))) * sqrt((2.0 * n)); else tmp = (k / ((n * (2.0 * pi)) ^ (1.0 - k))) ^ -0.5; end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.7e-63], N[(N[(1.0 / N[Sqrt[N[(k / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(k / N[Power[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.7 \cdot 10^{-63}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{k}{\pi}}} \cdot \sqrt{2 \cdot n}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{k}{{\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(1 - k\right)}}\right)}^{-0.5}\\
\end{array}
\end{array}
if k < 2.7000000000000002e-63Initial program 99.3%
Taylor expanded in k around 0 66.5%
*-commutative66.5%
associate-/l*66.6%
Simplified66.6%
sqrt-unprod65.7%
Applied egg-rr65.7%
pow1/265.7%
associate-*r*65.7%
unpow-prod-down98.4%
pow1/298.4%
Applied egg-rr98.4%
*-commutative98.4%
unpow1/298.4%
*-commutative98.4%
Simplified98.4%
clear-num98.4%
sqrt-div99.3%
metadata-eval99.3%
Applied egg-rr99.3%
if 2.7000000000000002e-63 < k Initial program 99.5%
Applied egg-rr99.6%
distribute-rgt-in99.6%
metadata-eval99.6%
associate-*l*99.6%
metadata-eval99.6%
*-commutative99.6%
neg-mul-199.6%
sub-neg99.6%
*-commutative99.6%
Simplified99.6%
clear-num99.6%
sqrt-div99.6%
metadata-eval99.6%
associate-*r*99.6%
Applied egg-rr99.6%
pow1/299.6%
pow-flip99.6%
*-commutative99.6%
associate-*r*99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.5%
(FPCore (k n) :precision binary64 (if (<= k 2.3e-36) (* (/ 1.0 (sqrt (/ k PI))) (sqrt (* 2.0 n))) (sqrt (/ (pow (* 2.0 (* PI n)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 2.3e-36) {
tmp = (1.0 / sqrt((k / ((double) M_PI)))) * sqrt((2.0 * n));
} else {
tmp = sqrt((pow((2.0 * (((double) M_PI) * n)), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.3e-36) {
tmp = (1.0 / Math.sqrt((k / Math.PI))) * Math.sqrt((2.0 * n));
} else {
tmp = Math.sqrt((Math.pow((2.0 * (Math.PI * n)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.3e-36: tmp = (1.0 / math.sqrt((k / math.pi))) * math.sqrt((2.0 * n)) else: tmp = math.sqrt((math.pow((2.0 * (math.pi * n)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.3e-36) tmp = Float64(Float64(1.0 / sqrt(Float64(k / pi))) * sqrt(Float64(2.0 * n))); else tmp = sqrt(Float64((Float64(2.0 * Float64(pi * n)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.3e-36) tmp = (1.0 / sqrt((k / pi))) * sqrt((2.0 * n)); else tmp = sqrt((((2.0 * (pi * n)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.3e-36], N[(N[(1.0 / N[Sqrt[N[(k / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.3 \cdot 10^{-36}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{k}{\pi}}} \cdot \sqrt{2 \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 2.29999999999999996e-36Initial program 99.2%
Taylor expanded in k around 0 70.0%
*-commutative70.0%
associate-/l*70.0%
Simplified70.0%
sqrt-unprod69.2%
Applied egg-rr69.2%
pow1/269.2%
associate-*r*69.2%
unpow-prod-down98.5%
pow1/298.5%
Applied egg-rr98.5%
*-commutative98.5%
unpow1/298.5%
*-commutative98.5%
Simplified98.5%
clear-num98.6%
sqrt-div99.3%
metadata-eval99.3%
Applied egg-rr99.3%
if 2.29999999999999996e-36 < k Initial program 99.6%
Applied egg-rr99.6%
distribute-rgt-in99.6%
metadata-eval99.6%
associate-*l*99.6%
metadata-eval99.6%
*-commutative99.6%
neg-mul-199.6%
sub-neg99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.5%
(FPCore (k n) :precision binary64 (if (<= k 5.6e+32) (* (/ 1.0 (sqrt (/ k PI))) (sqrt (* 2.0 n))) (sqrt (+ 1.0 (fma 2.0 (* n (/ PI k)) -1.0)))))
double code(double k, double n) {
double tmp;
if (k <= 5.6e+32) {
tmp = (1.0 / sqrt((k / ((double) M_PI)))) * sqrt((2.0 * n));
} else {
tmp = sqrt((1.0 + fma(2.0, (n * (((double) M_PI) / k)), -1.0)));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 5.6e+32) tmp = Float64(Float64(1.0 / sqrt(Float64(k / pi))) * sqrt(Float64(2.0 * n))); else tmp = sqrt(Float64(1.0 + fma(2.0, Float64(n * Float64(pi / k)), -1.0))); end return tmp end
code[k_, n_] := If[LessEqual[k, 5.6e+32], N[(N[(1.0 / N[Sqrt[N[(k / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(1.0 + N[(2.0 * N[(n * N[(Pi / k), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 5.6 \cdot 10^{+32}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{k}{\pi}}} \cdot \sqrt{2 \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 + \mathsf{fma}\left(2, n \cdot \frac{\pi}{k}, -1\right)}\\
\end{array}
\end{array}
if k < 5.6e32Initial program 98.9%
Taylor expanded in k around 0 61.6%
*-commutative61.6%
associate-/l*61.6%
Simplified61.6%
sqrt-unprod61.0%
Applied egg-rr61.0%
pow1/261.0%
associate-*r*61.0%
unpow-prod-down84.3%
pow1/284.3%
Applied egg-rr84.3%
*-commutative84.3%
unpow1/284.3%
*-commutative84.3%
Simplified84.3%
clear-num84.3%
sqrt-div84.9%
metadata-eval84.9%
Applied egg-rr84.9%
if 5.6e32 < k Initial program 100.0%
Taylor expanded in k around 0 2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
sqrt-unprod2.7%
Applied egg-rr2.7%
associate-*r/2.7%
*-commutative2.7%
Applied egg-rr2.7%
associate-*r/2.7%
*-commutative2.7%
associate-*l*2.7%
associate-*r/2.7%
expm1-log1p-u2.7%
expm1-undefine26.6%
*-commutative26.6%
associate-*l*26.6%
Applied egg-rr26.6%
log1p-undefine26.6%
rem-exp-log26.6%
associate-+r-26.6%
associate-*r*26.6%
associate-*r/26.6%
*-commutative26.6%
associate-*r*26.6%
associate-*r/26.6%
associate-*r/26.6%
fmm-def26.6%
metadata-eval26.6%
Simplified26.6%
Final simplification56.7%
(FPCore (k n) :precision binary64 (if (<= k 2.5e+30) (/ (sqrt (* n (* 2.0 PI))) (sqrt k)) (sqrt (+ 1.0 (fma 2.0 (* n (/ PI k)) -1.0)))))
double code(double k, double n) {
double tmp;
if (k <= 2.5e+30) {
tmp = sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
} else {
tmp = sqrt((1.0 + fma(2.0, (n * (((double) M_PI) / k)), -1.0)));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 2.5e+30) tmp = Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k)); else tmp = sqrt(Float64(1.0 + fma(2.0, Float64(n * Float64(pi / k)), -1.0))); end return tmp end
code[k_, n_] := If[LessEqual[k, 2.5e+30], N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(1.0 + N[(2.0 * N[(n * N[(Pi / k), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.5 \cdot 10^{+30}:\\
\;\;\;\;\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 + \mathsf{fma}\left(2, n \cdot \frac{\pi}{k}, -1\right)}\\
\end{array}
\end{array}
if k < 2.4999999999999999e30Initial program 98.9%
Taylor expanded in k around 0 62.0%
*-commutative62.0%
associate-/l*62.1%
Simplified62.1%
sqrt-unprod61.5%
Applied egg-rr61.5%
associate-*r/61.5%
*-commutative61.5%
Applied egg-rr61.5%
associate-*r/61.5%
*-commutative61.5%
associate-*l*61.5%
sqrt-div85.5%
*-commutative85.5%
associate-*r*85.5%
Applied egg-rr85.5%
if 2.4999999999999999e30 < k Initial program 100.0%
Taylor expanded in k around 0 2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
sqrt-unprod2.7%
Applied egg-rr2.7%
associate-*r/2.7%
*-commutative2.7%
Applied egg-rr2.7%
associate-*r/2.7%
*-commutative2.7%
associate-*l*2.7%
associate-*r/2.7%
expm1-log1p-u2.7%
expm1-undefine26.4%
*-commutative26.4%
associate-*l*26.4%
Applied egg-rr26.4%
log1p-undefine26.4%
rem-exp-log26.4%
associate-+r-26.4%
associate-*r*26.4%
associate-*r/26.4%
*-commutative26.4%
associate-*r*26.4%
associate-*r/26.4%
associate-*r/26.4%
fmm-def26.4%
metadata-eval26.4%
Simplified26.4%
(FPCore (k n) :precision binary64 (* (sqrt (/ 1.0 k)) (pow (* n (* 2.0 PI)) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return sqrt((1.0 / k)) * pow((n * (2.0 * ((double) M_PI))), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return Math.sqrt((1.0 / k)) * Math.pow((n * (2.0 * Math.PI)), ((1.0 - k) / 2.0));
}
def code(k, n): return math.sqrt((1.0 / k)) * math.pow((n * (2.0 * math.pi)), ((1.0 - k) / 2.0))
function code(k, n) return Float64(sqrt(Float64(1.0 / k)) * (Float64(n * Float64(2.0 * pi)) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = sqrt((1.0 / k)) * ((n * (2.0 * pi)) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[Sqrt[N[(1.0 / k), $MachinePrecision]], $MachinePrecision] * N[Power[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{k}} \cdot {\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0 99.5%
Final simplification99.5%
(FPCore (k n) :precision binary64 (* (pow k -0.5) (pow (* 2.0 (* PI n)) (+ 0.5 (* k -0.5)))))
double code(double k, double n) {
return pow(k, -0.5) * pow((2.0 * (((double) M_PI) * n)), (0.5 + (k * -0.5)));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) * Math.pow((2.0 * (Math.PI * n)), (0.5 + (k * -0.5)));
}
def code(k, n): return math.pow(k, -0.5) * math.pow((2.0 * (math.pi * n)), (0.5 + (k * -0.5)))
function code(k, n) return Float64((k ^ -0.5) * (Float64(2.0 * Float64(pi * n)) ^ Float64(0.5 + Float64(k * -0.5)))) end
function tmp = code(k, n) tmp = (k ^ -0.5) * ((2.0 * (pi * n)) ^ (0.5 + (k * -0.5))); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision], N[(0.5 + N[(k * -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{k}^{-0.5} \cdot {\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(0.5 + k \cdot -0.5\right)}
\end{array}
Initial program 99.4%
associate-*l/99.5%
*-lft-identity99.5%
associate-*l*99.5%
div-sub99.5%
metadata-eval99.5%
Simplified99.5%
metadata-eval99.5%
div-sub99.5%
associate-*r*99.5%
div-inv99.4%
associate-*r*99.4%
div-sub99.4%
metadata-eval99.4%
sub-neg99.4%
div-inv99.4%
metadata-eval99.4%
distribute-rgt-neg-in99.4%
metadata-eval99.4%
pow1/299.4%
pow-flip99.5%
metadata-eval99.5%
Applied egg-rr99.5%
Final simplification99.5%
(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.4%
associate-*l/99.5%
*-lft-identity99.5%
associate-*l*99.5%
div-sub99.5%
metadata-eval99.5%
Simplified99.5%
(FPCore (k n) :precision binary64 (/ (sqrt (* n (* 2.0 PI))) (sqrt k)))
double code(double k, double n) {
return sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.sqrt((n * (2.0 * Math.PI))) / Math.sqrt(k);
}
def code(k, n): return math.sqrt((n * (2.0 * math.pi))) / math.sqrt(k)
function code(k, n) return Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k)) end
function tmp = code(k, n) tmp = sqrt((n * (2.0 * pi))) / sqrt(k); end
code[k_, n_] := N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0 33.0%
*-commutative33.0%
associate-/l*33.1%
Simplified33.1%
sqrt-unprod32.7%
Applied egg-rr32.7%
associate-*r/32.8%
*-commutative32.8%
Applied egg-rr32.8%
associate-*r/32.8%
*-commutative32.8%
associate-*l*32.8%
sqrt-div45.1%
*-commutative45.1%
associate-*r*45.1%
Applied egg-rr45.1%
(FPCore (k n) :precision binary64 (* (sqrt (* 2.0 n)) (sqrt (/ PI k))))
double code(double k, double n) {
return sqrt((2.0 * n)) * sqrt((((double) M_PI) / k));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * n)) * Math.sqrt((Math.PI / k));
}
def code(k, n): return math.sqrt((2.0 * n)) * math.sqrt((math.pi / k))
function code(k, n) return Float64(sqrt(Float64(2.0 * n)) * sqrt(Float64(pi / k))) end
function tmp = code(k, n) tmp = sqrt((2.0 * n)) * sqrt((pi / k)); end
code[k_, n_] := N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot n} \cdot \sqrt{\frac{\pi}{k}}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0 33.0%
*-commutative33.0%
associate-/l*33.1%
Simplified33.1%
sqrt-unprod32.7%
Applied egg-rr32.7%
pow1/232.7%
associate-*r*32.7%
unpow-prod-down44.8%
pow1/244.8%
Applied egg-rr44.8%
*-commutative44.8%
unpow1/244.8%
*-commutative44.8%
Simplified44.8%
Final simplification44.8%
(FPCore (k n) :precision binary64 (* (sqrt (* 2.0 (/ PI k))) (sqrt n)))
double code(double k, double n) {
return sqrt((2.0 * (((double) M_PI) / k))) * sqrt(n);
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (Math.PI / k))) * Math.sqrt(n);
}
def code(k, n): return math.sqrt((2.0 * (math.pi / k))) * math.sqrt(n)
function code(k, n) return Float64(sqrt(Float64(2.0 * Float64(pi / k))) * sqrt(n)) end
function tmp = code(k, n) tmp = sqrt((2.0 * (pi / k))) * sqrt(n); end
code[k_, n_] := N[(N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0 33.0%
*-commutative33.0%
associate-/l*33.1%
Simplified33.1%
sqrt-unprod32.7%
Applied egg-rr32.7%
sqrt-prod33.1%
*-commutative33.1%
sqrt-unprod44.8%
associate-*r*44.7%
sqrt-unprod44.8%
Applied egg-rr44.8%
(FPCore (k n) :precision binary64 (/ 1.0 (sqrt (* k (/ (/ 0.5 n) PI)))))
double code(double k, double n) {
return 1.0 / sqrt((k * ((0.5 / n) / ((double) M_PI))));
}
public static double code(double k, double n) {
return 1.0 / Math.sqrt((k * ((0.5 / n) / Math.PI)));
}
def code(k, n): return 1.0 / math.sqrt((k * ((0.5 / n) / math.pi)))
function code(k, n) return Float64(1.0 / sqrt(Float64(k * Float64(Float64(0.5 / n) / pi)))) end
function tmp = code(k, n) tmp = 1.0 / sqrt((k * ((0.5 / n) / pi))); end
code[k_, n_] := N[(1.0 / N[Sqrt[N[(k * N[(N[(0.5 / n), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{k \cdot \frac{\frac{0.5}{n}}{\pi}}}
\end{array}
Initial program 99.4%
Applied egg-rr87.2%
distribute-rgt-in87.2%
metadata-eval87.2%
associate-*l*87.2%
metadata-eval87.2%
*-commutative87.2%
neg-mul-187.2%
sub-neg87.2%
*-commutative87.2%
Simplified87.2%
clear-num87.2%
sqrt-div88.5%
metadata-eval88.5%
associate-*r*88.5%
Applied egg-rr88.5%
Taylor expanded in k around 0 34.1%
*-commutative34.1%
associate-*l/34.1%
associate-*r/34.1%
associate-/r*34.1%
Simplified34.1%
(FPCore (k n) :precision binary64 (sqrt (/ 2.0 (/ k (* PI n)))))
double code(double k, double n) {
return sqrt((2.0 / (k / (((double) M_PI) * n))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 / (k / (Math.PI * n))));
}
def code(k, n): return math.sqrt((2.0 / (k / (math.pi * n))))
function code(k, n) return sqrt(Float64(2.0 / Float64(k / Float64(pi * n)))) end
function tmp = code(k, n) tmp = sqrt((2.0 / (k / (pi * n)))); end
code[k_, n_] := N[Sqrt[N[(2.0 / N[(k / N[(Pi * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{2}{\frac{k}{\pi \cdot n}}}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0 33.0%
*-commutative33.0%
associate-/l*33.1%
Simplified33.1%
sqrt-unprod32.7%
Applied egg-rr32.7%
associate-*r/32.8%
*-commutative32.8%
Applied egg-rr32.8%
clear-num32.8%
un-div-inv32.8%
*-commutative32.8%
Applied egg-rr32.8%
Final simplification32.8%
(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.4%
Taylor expanded in k around 0 33.0%
*-commutative33.0%
associate-/l*33.1%
Simplified33.1%
sqrt-unprod32.7%
Applied egg-rr32.7%
associate-*r/32.8%
*-commutative32.8%
Applied egg-rr32.8%
Taylor expanded in n around 0 32.8%
*-commutative32.8%
associate-*r/32.8%
Simplified32.8%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (* n (/ PI k)))))
double code(double k, double n) {
return sqrt((2.0 * (n * (((double) M_PI) / k))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (n * (Math.PI / k))));
}
def code(k, n): return math.sqrt((2.0 * (n * (math.pi / k))))
function code(k, n) return sqrt(Float64(2.0 * Float64(n * Float64(pi / k)))) end
function tmp = code(k, n) tmp = sqrt((2.0 * (n * (pi / k)))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(n * N[(Pi / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \left(n \cdot \frac{\pi}{k}\right)}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0 33.0%
*-commutative33.0%
associate-/l*33.1%
Simplified33.1%
sqrt-unprod32.7%
Applied egg-rr32.7%
herbie shell --seed 2024146
(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))))