
(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 (let* ((t_0 (* PI (* n 2.0)))) (/ (sqrt t_0) (sqrt (* k (pow t_0 k))))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (n * 2.0);
return sqrt(t_0) / sqrt((k * pow(t_0, k)));
}
public static double code(double k, double n) {
double t_0 = Math.PI * (n * 2.0);
return Math.sqrt(t_0) / Math.sqrt((k * Math.pow(t_0, k)));
}
def code(k, n): t_0 = math.pi * (n * 2.0) return math.sqrt(t_0) / math.sqrt((k * math.pow(t_0, k)))
function code(k, n) t_0 = Float64(pi * Float64(n * 2.0)) return Float64(sqrt(t_0) / sqrt(Float64(k * (t_0 ^ k)))) end
function tmp = code(k, n) t_0 = pi * (n * 2.0); tmp = sqrt(t_0) / sqrt((k * (t_0 ^ k))); end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(n * 2.0), $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 := \pi \cdot \left(n \cdot 2\right)\\
\frac{\sqrt{t\_0}}{\sqrt{k \cdot {t\_0}^{k}}}
\end{array}
\end{array}
Initial program 99.5%
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%
rem-square-sqrt99.7%
rem-sqrt-square99.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-sqrt20.9%
pow-sqr20.9%
metadata-eval20.9%
unpow1/220.9%
neg-mul-120.9%
associate-/r*20.9%
Simplified99.7%
div-inv99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
pow1/299.7%
pow-unpow99.7%
pow-prod-down99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
*-commutative99.7%
*-commutative99.7%
unpow1/299.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
(FPCore (k n) :precision binary64 (if (<= k 2.7e-20) (* (sqrt n) (sqrt (* 2.0 (/ PI k)))) (pow (* k (pow (* PI (* n 2.0)) (+ k -1.0))) -0.5)))
double code(double k, double n) {
double tmp;
if (k <= 2.7e-20) {
tmp = sqrt(n) * sqrt((2.0 * (((double) M_PI) / k)));
} else {
tmp = pow((k * pow((((double) M_PI) * (n * 2.0)), (k + -1.0))), -0.5);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.7e-20) {
tmp = Math.sqrt(n) * Math.sqrt((2.0 * (Math.PI / k)));
} else {
tmp = Math.pow((k * Math.pow((Math.PI * (n * 2.0)), (k + -1.0))), -0.5);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.7e-20: tmp = math.sqrt(n) * math.sqrt((2.0 * (math.pi / k))) else: tmp = math.pow((k * math.pow((math.pi * (n * 2.0)), (k + -1.0))), -0.5) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.7e-20) tmp = Float64(sqrt(n) * sqrt(Float64(2.0 * Float64(pi / k)))); else tmp = Float64(k * (Float64(pi * Float64(n * 2.0)) ^ Float64(k + -1.0))) ^ -0.5; end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.7e-20) tmp = sqrt(n) * sqrt((2.0 * (pi / k))); else tmp = (k * ((pi * (n * 2.0)) ^ (k + -1.0))) ^ -0.5; end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.7e-20], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(k * N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], N[(k + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.7 \cdot 10^{-20}:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{2 \cdot \frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;{\left(k \cdot {\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(k + -1\right)}\right)}^{-0.5}\\
\end{array}
\end{array}
if k < 2.7e-20Initial program 99.4%
Taylor expanded in k around 0 69.1%
*-commutative69.1%
associate-/l*69.1%
Simplified69.1%
sqrt-unprod69.3%
associate-*r/69.3%
Applied egg-rr69.3%
*-commutative69.3%
associate-/l*69.3%
Applied egg-rr69.3%
pow1/269.3%
associate-*r/69.3%
associate-*r/69.3%
*-commutative69.3%
associate-*l*69.3%
*-commutative69.3%
associate-*r/69.3%
associate-*l*69.3%
unpow-prod-down99.6%
pow1/299.6%
Applied egg-rr99.6%
unpow1/299.6%
Simplified99.6%
if 2.7e-20 < k Initial program 99.5%
associate-*l/99.5%
*-un-lft-identity99.5%
associate-*r*99.5%
div-sub99.5%
metadata-eval99.5%
pow-div100.0%
pow1/2100.0%
associate-/l/100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
associate-/l/100.0%
rem-square-sqrt100.0%
rem-sqrt-square100.0%
fabs-neg100.0%
neg-mul-1100.0%
rem-square-sqrt0.0%
unpow1/20.0%
metadata-eval0.0%
pow-sqr0.0%
unswap-sqr0.0%
fabs-sqr0.0%
unswap-sqr0.0%
rem-square-sqrt42.4%
pow-sqr42.4%
metadata-eval42.4%
unpow1/242.4%
neg-mul-142.4%
associate-/r*42.4%
Simplified100.0%
div-inv99.9%
*-commutative99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*r*99.9%
pow1/299.9%
pow-unpow99.9%
pow-prod-down99.9%
*-commutative99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*r*99.9%
Applied egg-rr99.9%
associate-*r/100.0%
*-rgt-identity100.0%
*-commutative100.0%
*-commutative100.0%
unpow1/2100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
clear-num100.0%
inv-pow100.0%
sqrt-undiv99.9%
Applied egg-rr99.9%
unpow-199.9%
associate-/l*99.9%
Simplified99.9%
inv-pow99.9%
sqrt-pow2100.0%
pow1100.0%
pow-div99.5%
metadata-eval99.5%
Applied egg-rr99.5%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 4.5e+19) (* (sqrt n) (sqrt (* 2.0 (/ PI k)))) (sqrt (+ 1.0 (fma n (/ 2.0 (/ k PI)) -1.0)))))
double code(double k, double n) {
double tmp;
if (k <= 4.5e+19) {
tmp = sqrt(n) * sqrt((2.0 * (((double) M_PI) / k)));
} else {
tmp = sqrt((1.0 + fma(n, (2.0 / (k / ((double) M_PI))), -1.0)));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 4.5e+19) tmp = Float64(sqrt(n) * sqrt(Float64(2.0 * Float64(pi / k)))); else tmp = sqrt(Float64(1.0 + fma(n, Float64(2.0 / Float64(k / pi)), -1.0))); end return tmp end
code[k_, n_] := If[LessEqual[k, 4.5e+19], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(1.0 + N[(n * N[(2.0 / N[(k / Pi), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 4.5 \cdot 10^{+19}:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{2 \cdot \frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 + \mathsf{fma}\left(n, \frac{2}{\frac{k}{\pi}}, -1\right)}\\
\end{array}
\end{array}
if k < 4.5e19Initial program 99.1%
Taylor expanded in k around 0 66.3%
*-commutative66.3%
associate-/l*66.3%
Simplified66.3%
sqrt-unprod66.5%
associate-*r/66.5%
Applied egg-rr66.5%
*-commutative66.5%
associate-/l*66.5%
Applied egg-rr66.5%
pow1/266.5%
associate-*r/66.5%
associate-*r/66.5%
*-commutative66.5%
associate-*l*66.5%
*-commutative66.5%
associate-*r/66.5%
associate-*l*66.5%
unpow-prod-down93.5%
pow1/293.5%
Applied egg-rr93.5%
unpow1/293.5%
Simplified93.5%
if 4.5e19 < k Initial program 100.0%
Taylor expanded in k around 0 2.6%
*-commutative2.6%
associate-/l*2.6%
Simplified2.6%
sqrt-unprod2.6%
associate-*r/2.6%
Applied egg-rr2.6%
*-commutative2.6%
associate-/l*2.6%
Applied egg-rr2.6%
associate-*r/2.6%
*-un-lft-identity2.6%
associate-*l/2.6%
expm1-log1p-u2.6%
expm1-undefine26.7%
*-commutative26.7%
associate-*l/26.7%
*-un-lft-identity26.7%
associate-*r/26.7%
associate-*l*26.7%
Applied egg-rr26.7%
log1p-undefine26.7%
rem-exp-log26.7%
associate-+r-26.7%
*-commutative26.7%
associate-*l/26.7%
associate-/r/26.7%
associate-/l*26.7%
fma-neg26.7%
metadata-eval26.7%
Simplified26.7%
(FPCore (k n) :precision binary64 (if (<= k 4.5e+19) (* (sqrt n) (sqrt (* 2.0 (/ PI k)))) (sqrt (+ -1.0 (fma PI (/ (* n 2.0) k) 1.0)))))
double code(double k, double n) {
double tmp;
if (k <= 4.5e+19) {
tmp = sqrt(n) * sqrt((2.0 * (((double) M_PI) / k)));
} else {
tmp = sqrt((-1.0 + fma(((double) M_PI), ((n * 2.0) / k), 1.0)));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 4.5e+19) tmp = Float64(sqrt(n) * sqrt(Float64(2.0 * Float64(pi / k)))); else tmp = sqrt(Float64(-1.0 + fma(pi, Float64(Float64(n * 2.0) / k), 1.0))); end return tmp end
code[k_, n_] := If[LessEqual[k, 4.5e+19], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(-1.0 + N[(Pi * N[(N[(n * 2.0), $MachinePrecision] / k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 4.5 \cdot 10^{+19}:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{2 \cdot \frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{-1 + \mathsf{fma}\left(\pi, \frac{n \cdot 2}{k}, 1\right)}\\
\end{array}
\end{array}
if k < 4.5e19Initial program 99.1%
Taylor expanded in k around 0 66.3%
*-commutative66.3%
associate-/l*66.3%
Simplified66.3%
sqrt-unprod66.5%
associate-*r/66.5%
Applied egg-rr66.5%
*-commutative66.5%
associate-/l*66.5%
Applied egg-rr66.5%
pow1/266.5%
associate-*r/66.5%
associate-*r/66.5%
*-commutative66.5%
associate-*l*66.5%
*-commutative66.5%
associate-*r/66.5%
associate-*l*66.5%
unpow-prod-down93.5%
pow1/293.5%
Applied egg-rr93.5%
unpow1/293.5%
Simplified93.5%
if 4.5e19 < k Initial program 100.0%
Taylor expanded in k around 0 2.6%
*-commutative2.6%
associate-/l*2.6%
Simplified2.6%
sqrt-unprod2.6%
associate-*r/2.6%
Applied egg-rr2.6%
expm1-log1p-u2.6%
expm1-undefine26.7%
associate-/l*26.7%
associate-*r*26.7%
*-commutative26.7%
Applied egg-rr26.7%
sub-neg26.7%
metadata-eval26.7%
+-commutative26.7%
log1p-undefine26.7%
rem-exp-log26.7%
+-commutative26.7%
associate-*r/26.7%
associate-*l/26.7%
associate-*r/26.7%
*-commutative26.7%
fma-define26.7%
associate-*r/26.7%
Simplified26.7%
(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.5%
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) (sqrt (* 2.0 (/ PI k)))))
double code(double k, double n) {
return sqrt(n) * sqrt((2.0 * (((double) M_PI) / k)));
}
public static double code(double k, double n) {
return Math.sqrt(n) * Math.sqrt((2.0 * (Math.PI / k)));
}
def code(k, n): return math.sqrt(n) * math.sqrt((2.0 * (math.pi / k)))
function code(k, n) return Float64(sqrt(n) * sqrt(Float64(2.0 * Float64(pi / k)))) end
function tmp = code(k, n) tmp = sqrt(n) * sqrt((2.0 * (pi / k))); end
code[k_, n_] := N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{n} \cdot \sqrt{2 \cdot \frac{\pi}{k}}
\end{array}
Initial program 99.5%
Taylor expanded in k around 0 39.6%
*-commutative39.6%
associate-/l*39.7%
Simplified39.7%
sqrt-unprod39.8%
associate-*r/39.8%
Applied egg-rr39.8%
*-commutative39.8%
associate-/l*39.8%
Applied egg-rr39.8%
pow1/239.8%
associate-*r/39.8%
associate-*r/39.8%
*-commutative39.8%
associate-*l*39.8%
*-commutative39.8%
associate-*r/39.8%
associate-*l*39.8%
unpow-prod-down55.5%
pow1/255.5%
Applied egg-rr55.5%
unpow1/255.5%
Simplified55.5%
(FPCore (k n) :precision binary64 (/ 1.0 (sqrt (/ k (* PI (* n 2.0))))))
double code(double k, double n) {
return 1.0 / sqrt((k / (((double) M_PI) * (n * 2.0))));
}
public static double code(double k, double n) {
return 1.0 / Math.sqrt((k / (Math.PI * (n * 2.0))));
}
def code(k, n): return 1.0 / math.sqrt((k / (math.pi * (n * 2.0))))
function code(k, n) return Float64(1.0 / sqrt(Float64(k / Float64(pi * Float64(n * 2.0))))) end
function tmp = code(k, n) tmp = 1.0 / sqrt((k / (pi * (n * 2.0)))); end
code[k_, n_] := N[(1.0 / N[Sqrt[N[(k / N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\frac{k}{\pi \cdot \left(n \cdot 2\right)}}}
\end{array}
Initial program 99.5%
Taylor expanded in k around 0 39.6%
*-commutative39.6%
associate-/l*39.7%
Simplified39.7%
sqrt-unprod39.8%
associate-*r/39.8%
Applied egg-rr39.8%
associate-*r/39.8%
div-inv39.7%
associate-*r*39.7%
*-commutative39.7%
*-commutative39.7%
div-inv39.8%
clear-num39.8%
sqrt-div40.7%
metadata-eval40.7%
Applied egg-rr40.7%
(FPCore (k n) :precision binary64 (/ 1.0 (sqrt (* k (/ 0.5 (* PI n))))))
double code(double k, double n) {
return 1.0 / sqrt((k * (0.5 / (((double) M_PI) * n))));
}
public static double code(double k, double n) {
return 1.0 / Math.sqrt((k * (0.5 / (Math.PI * n))));
}
def code(k, n): return 1.0 / math.sqrt((k * (0.5 / (math.pi * n))))
function code(k, n) return Float64(1.0 / sqrt(Float64(k * Float64(0.5 / Float64(pi * n))))) end
function tmp = code(k, n) tmp = 1.0 / sqrt((k * (0.5 / (pi * n)))); end
code[k_, n_] := N[(1.0 / N[Sqrt[N[(k * N[(0.5 / N[(Pi * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{k \cdot \frac{0.5}{\pi \cdot n}}}
\end{array}
Initial program 99.5%
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%
rem-square-sqrt99.7%
rem-sqrt-square99.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-sqrt20.9%
pow-sqr20.9%
metadata-eval20.9%
unpow1/220.9%
neg-mul-120.9%
associate-/r*20.9%
Simplified99.7%
div-inv99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
pow1/299.7%
pow-unpow99.7%
pow-prod-down99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
*-commutative99.7%
*-commutative99.7%
unpow1/299.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
clear-num99.7%
inv-pow99.7%
sqrt-undiv85.0%
Applied egg-rr85.0%
unpow-185.0%
associate-/l*85.0%
Simplified85.0%
Taylor expanded in k around 0 40.7%
Final simplification40.7%
(FPCore (k n) :precision binary64 (/ 1.0 (sqrt (* 0.5 (/ (/ k n) PI)))))
double code(double k, double n) {
return 1.0 / sqrt((0.5 * ((k / n) / ((double) M_PI))));
}
public static double code(double k, double n) {
return 1.0 / Math.sqrt((0.5 * ((k / n) / Math.PI)));
}
def code(k, n): return 1.0 / math.sqrt((0.5 * ((k / n) / math.pi)))
function code(k, n) return Float64(1.0 / sqrt(Float64(0.5 * Float64(Float64(k / n) / pi)))) end
function tmp = code(k, n) tmp = 1.0 / sqrt((0.5 * ((k / n) / pi))); end
code[k_, n_] := N[(1.0 / N[Sqrt[N[(0.5 * N[(N[(k / n), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{0.5 \cdot \frac{\frac{k}{n}}{\pi}}}
\end{array}
Initial program 99.5%
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%
rem-square-sqrt99.7%
rem-sqrt-square99.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-sqrt20.9%
pow-sqr20.9%
metadata-eval20.9%
unpow1/220.9%
neg-mul-120.9%
associate-/r*20.9%
Simplified99.7%
div-inv99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
pow1/299.7%
pow-unpow99.7%
pow-prod-down99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
*-commutative99.7%
*-commutative99.7%
unpow1/299.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
clear-num99.7%
inv-pow99.7%
sqrt-undiv85.0%
Applied egg-rr85.0%
unpow-185.0%
associate-/l*85.0%
Simplified85.0%
Taylor expanded in k around 0 40.7%
associate-/r*40.7%
Simplified40.7%
(FPCore (k n) :precision binary64 (sqrt (/ (* n 2.0) (/ k PI))))
double code(double k, double n) {
return sqrt(((n * 2.0) / (k / ((double) M_PI))));
}
public static double code(double k, double n) {
return Math.sqrt(((n * 2.0) / (k / Math.PI)));
}
def code(k, n): return math.sqrt(((n * 2.0) / (k / math.pi)))
function code(k, n) return sqrt(Float64(Float64(n * 2.0) / Float64(k / pi))) end
function tmp = code(k, n) tmp = sqrt(((n * 2.0) / (k / pi))); end
code[k_, n_] := N[Sqrt[N[(N[(n * 2.0), $MachinePrecision] / N[(k / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{n \cdot 2}{\frac{k}{\pi}}}
\end{array}
Initial program 99.5%
Taylor expanded in k around 0 39.6%
*-commutative39.6%
associate-/l*39.7%
Simplified39.7%
sqrt-unprod39.8%
associate-*r/39.8%
Applied egg-rr39.8%
*-commutative39.8%
associate-/l*39.8%
Applied egg-rr39.8%
associate-*r/39.8%
associate-*r/39.8%
*-commutative39.8%
associate-*l*39.8%
*-commutative39.8%
associate-*r/39.8%
clear-num39.7%
un-div-inv39.8%
Applied egg-rr39.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.5%
Taylor expanded in k around 0 39.6%
*-commutative39.6%
associate-/l*39.7%
Simplified39.7%
sqrt-unprod39.8%
associate-*r/39.8%
Applied egg-rr39.8%
*-commutative39.8%
associate-/l*39.8%
Applied egg-rr39.8%
herbie shell --seed 2024121
(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))))