
(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 (if (<= k 5e-23) (* (sqrt (* 2.0 (/ PI k))) (sqrt n)) (sqrt (/ (/ 1.0 k) (pow (* n (* 2.0 PI)) (+ k -1.0))))))
double code(double k, double n) {
double tmp;
if (k <= 5e-23) {
tmp = sqrt((2.0 * (((double) M_PI) / k))) * sqrt(n);
} else {
tmp = sqrt(((1.0 / k) / pow((n * (2.0 * ((double) M_PI))), (k + -1.0))));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 5e-23) {
tmp = Math.sqrt((2.0 * (Math.PI / k))) * Math.sqrt(n);
} else {
tmp = Math.sqrt(((1.0 / k) / Math.pow((n * (2.0 * Math.PI)), (k + -1.0))));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 5e-23: tmp = math.sqrt((2.0 * (math.pi / k))) * math.sqrt(n) else: tmp = math.sqrt(((1.0 / k) / math.pow((n * (2.0 * math.pi)), (k + -1.0)))) return tmp
function code(k, n) tmp = 0.0 if (k <= 5e-23) tmp = Float64(sqrt(Float64(2.0 * Float64(pi / k))) * sqrt(n)); else tmp = sqrt(Float64(Float64(1.0 / k) / (Float64(n * Float64(2.0 * pi)) ^ Float64(k + -1.0)))); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 5e-23) tmp = sqrt((2.0 * (pi / k))) * sqrt(n); else tmp = sqrt(((1.0 / k) / ((n * (2.0 * pi)) ^ (k + -1.0)))); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 5e-23], N[(N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(1.0 / k), $MachinePrecision] / N[Power[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision], N[(k + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 5 \cdot 10^{-23}:\\
\;\;\;\;\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{k}}{{\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(k + -1\right)}}}\\
\end{array}
\end{array}
if k < 5.0000000000000002e-23Initial program 99.3%
Taylor expanded in k around 0 99.2%
pow199.2%
associate-*l/99.2%
*-un-lft-identity99.2%
sqrt-unprod99.4%
*-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
sqrt-undiv73.8%
*-commutative73.8%
associate-*r*73.8%
Applied egg-rr73.8%
unpow173.8%
associate-/l*73.8%
*-commutative73.8%
Simplified73.8%
clear-num73.8%
un-div-inv73.8%
*-un-lft-identity73.8%
*-commutative73.8%
times-frac73.8%
metadata-eval73.8%
Applied egg-rr73.8%
associate-*r/73.8%
*-commutative73.8%
associate-/r/73.8%
Simplified73.8%
sqrt-prod99.4%
metadata-eval99.4%
div-inv99.4%
div-inv99.4%
clear-num99.4%
Applied egg-rr99.4%
associate-*r/99.4%
associate-*l/99.4%
*-commutative99.4%
Simplified99.4%
if 5.0000000000000002e-23 < k Initial program 99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
*-commutative99.8%
div-sub99.8%
metadata-eval99.8%
div-inv99.8%
*-commutative99.8%
div-sub99.8%
metadata-eval99.8%
div-inv99.8%
Applied egg-rr99.8%
distribute-lft-in99.8%
metadata-eval99.8%
*-commutative99.8%
associate-*r*99.8%
metadata-eval99.8%
mul-1-neg99.8%
sub-neg99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
pow-sub100.0%
pow1100.0%
Applied egg-rr100.0%
clear-num100.0%
inv-pow100.0%
div-inv100.0%
clear-num100.0%
pow1100.0%
pow-div99.8%
Applied egg-rr99.8%
unpow-199.8%
associate-/r*99.8%
*-commutative99.8%
*-commutative99.8%
associate-*l*99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 2.2e-24) (* (sqrt (* 2.0 (/ PI k))) (sqrt n)) (sqrt (/ (pow (* PI (* 2.0 n)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 2.2e-24) {
tmp = sqrt((2.0 * (((double) M_PI) / k))) * sqrt(n);
} else {
tmp = sqrt((pow((((double) M_PI) * (2.0 * n)), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.2e-24) {
tmp = Math.sqrt((2.0 * (Math.PI / k))) * Math.sqrt(n);
} else {
tmp = Math.sqrt((Math.pow((Math.PI * (2.0 * n)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.2e-24: tmp = math.sqrt((2.0 * (math.pi / k))) * math.sqrt(n) else: tmp = math.sqrt((math.pow((math.pi * (2.0 * n)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.2e-24) tmp = Float64(sqrt(Float64(2.0 * Float64(pi / k))) * sqrt(n)); else tmp = sqrt(Float64((Float64(pi * Float64(2.0 * n)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.2e-24) tmp = sqrt((2.0 * (pi / k))) * sqrt(n); else tmp = sqrt((((pi * (2.0 * n)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.2e-24], N[(N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.2 \cdot 10^{-24}:\\
\;\;\;\;\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 2.20000000000000002e-24Initial program 99.3%
Taylor expanded in k around 0 99.2%
pow199.2%
associate-*l/99.2%
*-un-lft-identity99.2%
sqrt-unprod99.4%
*-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
sqrt-undiv73.8%
*-commutative73.8%
associate-*r*73.8%
Applied egg-rr73.8%
unpow173.8%
associate-/l*73.8%
*-commutative73.8%
Simplified73.8%
clear-num73.8%
un-div-inv73.8%
*-un-lft-identity73.8%
*-commutative73.8%
times-frac73.8%
metadata-eval73.8%
Applied egg-rr73.8%
associate-*r/73.8%
*-commutative73.8%
associate-/r/73.8%
Simplified73.8%
sqrt-prod99.4%
metadata-eval99.4%
div-inv99.4%
div-inv99.4%
clear-num99.4%
Applied egg-rr99.4%
associate-*r/99.4%
associate-*l/99.4%
*-commutative99.4%
Simplified99.4%
if 2.20000000000000002e-24 < k Initial program 99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
*-commutative99.8%
div-sub99.8%
metadata-eval99.8%
div-inv99.8%
*-commutative99.8%
div-sub99.8%
metadata-eval99.8%
div-inv99.8%
Applied egg-rr99.8%
distribute-lft-in99.8%
metadata-eval99.8%
*-commutative99.8%
associate-*r*99.8%
metadata-eval99.8%
mul-1-neg99.8%
sub-neg99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 5e+71) (* (sqrt (* 2.0 (/ PI k))) (sqrt n)) (sqrt (+ -1.0 (fma 2.0 (* n (/ PI k)) 1.0)))))
double code(double k, double n) {
double tmp;
if (k <= 5e+71) {
tmp = sqrt((2.0 * (((double) M_PI) / k))) * sqrt(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 <= 5e+71) tmp = Float64(sqrt(Float64(2.0 * Float64(pi / k))) * sqrt(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, 5e+71], N[(N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $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 \cdot 10^{+71}:\\
\;\;\;\;\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{-1 + \mathsf{fma}\left(2, n \cdot \frac{\pi}{k}, 1\right)}\\
\end{array}
\end{array}
if k < 4.99999999999999972e71Initial program 99.3%
Taylor expanded in k around 0 80.1%
pow180.1%
associate-*l/80.2%
*-un-lft-identity80.2%
sqrt-unprod80.3%
*-commutative80.3%
*-commutative80.3%
associate-*r*80.3%
sqrt-undiv60.4%
*-commutative60.4%
associate-*r*60.4%
Applied egg-rr60.4%
unpow160.4%
associate-/l*60.4%
*-commutative60.4%
Simplified60.4%
clear-num60.3%
un-div-inv60.4%
*-un-lft-identity60.4%
*-commutative60.4%
times-frac60.4%
metadata-eval60.4%
Applied egg-rr60.4%
associate-*r/60.4%
*-commutative60.4%
associate-/r/60.4%
Simplified60.4%
sqrt-prod80.3%
metadata-eval80.3%
div-inv80.3%
div-inv80.3%
clear-num80.3%
Applied egg-rr80.3%
associate-*r/80.3%
associate-*l/80.3%
*-commutative80.3%
Simplified80.3%
if 4.99999999999999972e71 < k Initial program 100.0%
Taylor expanded in k around 0 2.6%
pow12.6%
associate-*l/2.6%
*-un-lft-identity2.6%
sqrt-unprod2.6%
*-commutative2.6%
*-commutative2.6%
associate-*r*2.6%
sqrt-undiv2.5%
*-commutative2.5%
associate-*r*2.5%
Applied egg-rr2.5%
unpow12.5%
associate-/l*2.5%
*-commutative2.5%
Simplified2.5%
expm1-log1p-u2.5%
expm1-undefine26.0%
associate-*r/26.0%
*-commutative26.0%
*-commutative26.0%
associate-*r*26.0%
*-un-lft-identity26.0%
times-frac26.0%
metadata-eval26.0%
*-commutative26.0%
Applied egg-rr26.0%
sub-neg26.0%
metadata-eval26.0%
+-commutative26.0%
log1p-undefine26.0%
rem-exp-log26.0%
+-commutative26.0%
fma-define26.0%
*-commutative26.0%
associate-/l*26.0%
Simplified26.0%
Final simplification59.5%
(FPCore (k n) :precision binary64 (* (pow (* 2.0 (* PI n)) (+ 0.5 (* k -0.5))) (pow k -0.5)))
double code(double k, double n) {
return pow((2.0 * (((double) M_PI) * n)), (0.5 + (k * -0.5))) * pow(k, -0.5);
}
public static double code(double k, double n) {
return Math.pow((2.0 * (Math.PI * n)), (0.5 + (k * -0.5))) * Math.pow(k, -0.5);
}
def code(k, n): return math.pow((2.0 * (math.pi * n)), (0.5 + (k * -0.5))) * math.pow(k, -0.5)
function code(k, n) return Float64((Float64(2.0 * Float64(pi * n)) ^ Float64(0.5 + Float64(k * -0.5))) * (k ^ -0.5)) end
function tmp = code(k, n) tmp = ((2.0 * (pi * n)) ^ (0.5 + (k * -0.5))) * (k ^ -0.5); end
code[k_, n_] := N[(N[Power[N[(2.0 * N[(Pi * n), $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(\pi \cdot n\right)\right)}^{\left(0.5 + k \cdot -0.5\right)} \cdot {k}^{-0.5}
\end{array}
Initial program 99.5%
associate-*l/99.6%
*-lft-identity99.6%
div-sub99.6%
metadata-eval99.6%
Simplified99.6%
div-inv99.5%
metadata-eval99.5%
div-sub99.5%
unpow-prod-down72.8%
unpow-prod-down99.5%
associate-*l*99.5%
div-sub99.5%
metadata-eval99.5%
sub-neg99.5%
div-inv99.5%
metadata-eval99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
pow1/299.5%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (k n) :precision binary64 (/ (pow (* n (* 2.0 PI)) (- 0.5 (/ k 2.0))) (sqrt k)))
double code(double k, double n) {
return pow((n * (2.0 * ((double) M_PI))), (0.5 - (k / 2.0))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow((n * (2.0 * Math.PI)), (0.5 - (k / 2.0))) / Math.sqrt(k);
}
def code(k, n): return math.pow((n * (2.0 * math.pi)), (0.5 - (k / 2.0))) / math.sqrt(k)
function code(k, n) return Float64((Float64(n * Float64(2.0 * pi)) ^ Float64(0.5 - Float64(k / 2.0))) / sqrt(k)) end
function tmp = code(k, n) tmp = ((n * (2.0 * pi)) ^ (0.5 - (k / 2.0))) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision], N[(0.5 - N[(k / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.5%
associate-*l/99.6%
*-lft-identity99.6%
div-sub99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.6%
(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.5%
Taylor expanded in k around 0 50.4%
pow150.4%
associate-*l/50.5%
*-un-lft-identity50.5%
sqrt-unprod50.6%
*-commutative50.6%
*-commutative50.6%
associate-*r*50.6%
sqrt-undiv38.2%
*-commutative38.2%
associate-*r*38.2%
Applied egg-rr38.2%
unpow138.2%
associate-/l*38.2%
*-commutative38.2%
Simplified38.2%
clear-num38.2%
un-div-inv38.2%
*-un-lft-identity38.2%
*-commutative38.2%
times-frac38.2%
metadata-eval38.2%
Applied egg-rr38.2%
associate-*r/38.2%
*-commutative38.2%
associate-/r/38.2%
Simplified38.2%
sqrt-prod50.6%
metadata-eval50.6%
div-inv50.6%
div-inv50.5%
clear-num50.5%
Applied egg-rr50.5%
associate-*r/50.6%
associate-*l/50.6%
*-commutative50.6%
Simplified50.6%
Final simplification50.6%
(FPCore (k n) :precision binary64 (pow (* 0.5 (/ k (* PI n))) -0.5))
double code(double k, double n) {
return pow((0.5 * (k / (((double) M_PI) * n))), -0.5);
}
public static double code(double k, double n) {
return Math.pow((0.5 * (k / (Math.PI * n))), -0.5);
}
def code(k, n): return math.pow((0.5 * (k / (math.pi * n))), -0.5)
function code(k, n) return Float64(0.5 * Float64(k / Float64(pi * n))) ^ -0.5 end
function tmp = code(k, n) tmp = (0.5 * (k / (pi * n))) ^ -0.5; end
code[k_, n_] := N[Power[N[(0.5 * N[(k / N[(Pi * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(0.5 \cdot \frac{k}{\pi \cdot n}\right)}^{-0.5}
\end{array}
Initial program 99.5%
Taylor expanded in k around 0 50.4%
pow150.4%
associate-*l/50.5%
*-un-lft-identity50.5%
sqrt-unprod50.6%
*-commutative50.6%
*-commutative50.6%
associate-*r*50.6%
sqrt-undiv38.2%
*-commutative38.2%
associate-*r*38.2%
Applied egg-rr38.2%
unpow138.2%
associate-/l*38.2%
*-commutative38.2%
Simplified38.2%
clear-num38.2%
un-div-inv38.2%
*-un-lft-identity38.2%
*-commutative38.2%
times-frac38.2%
metadata-eval38.2%
Applied egg-rr38.2%
associate-*r/38.2%
*-commutative38.2%
associate-/r/38.2%
Simplified38.2%
metadata-eval38.2%
div-inv38.2%
associate-*l/38.2%
clear-num38.2%
metadata-eval38.2%
*-commutative38.2%
add-sqr-sqrt38.1%
frac-times38.1%
sqrt-unprod38.7%
add-sqr-sqrt38.8%
inv-pow38.8%
sqrt-pow238.9%
Applied egg-rr38.8%
associate-/l*38.8%
associate-/l/38.9%
Simplified38.9%
Final simplification38.9%
(FPCore (k n) :precision binary64 (sqrt (* PI (* n (/ 2.0 k)))))
double code(double k, double n) {
return sqrt((((double) M_PI) * (n * (2.0 / k))));
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI * (n * (2.0 / k))));
}
def code(k, n): return math.sqrt((math.pi * (n * (2.0 / k))))
function code(k, n) return sqrt(Float64(pi * Float64(n * Float64(2.0 / k)))) end
function tmp = code(k, n) tmp = sqrt((pi * (n * (2.0 / k)))); end
code[k_, n_] := N[Sqrt[N[(Pi * N[(n * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\pi \cdot \left(n \cdot \frac{2}{k}\right)}
\end{array}
Initial program 99.5%
Taylor expanded in k around 0 50.4%
pow150.4%
associate-*l/50.5%
*-un-lft-identity50.5%
sqrt-unprod50.6%
*-commutative50.6%
*-commutative50.6%
associate-*r*50.6%
sqrt-undiv38.2%
*-commutative38.2%
associate-*r*38.2%
Applied egg-rr38.2%
unpow138.2%
associate-/l*38.2%
*-commutative38.2%
Simplified38.2%
associate-*r/38.2%
*-commutative38.2%
sqrt-undiv50.6%
clear-num50.5%
sqrt-undiv38.8%
associate-*r*38.8%
*-commutative38.8%
associate-*l*38.8%
Applied egg-rr38.8%
associate-/r*38.8%
*-commutative38.8%
Simplified38.8%
add-sqr-sqrt38.7%
sqrt-unprod38.1%
frac-times38.1%
metadata-eval38.1%
add-sqr-sqrt38.2%
*-commutative38.2%
clear-num38.2%
associate-*l/38.2%
div-inv38.2%
clear-num38.2%
associate-*l*38.2%
Applied egg-rr38.2%
Final simplification38.2%
(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(n * Float64(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 / N[(k / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{n \cdot \frac{2}{\frac{k}{\pi}}}
\end{array}
Initial program 99.5%
Taylor expanded in k around 0 50.4%
pow150.4%
associate-*l/50.5%
*-un-lft-identity50.5%
sqrt-unprod50.6%
*-commutative50.6%
*-commutative50.6%
associate-*r*50.6%
sqrt-undiv38.2%
*-commutative38.2%
associate-*r*38.2%
Applied egg-rr38.2%
unpow138.2%
associate-/l*38.2%
*-commutative38.2%
Simplified38.2%
clear-num38.2%
un-div-inv38.2%
*-un-lft-identity38.2%
*-commutative38.2%
times-frac38.2%
metadata-eval38.2%
Applied egg-rr38.2%
associate-*r/38.2%
*-commutative38.2%
associate-/r/38.2%
Simplified38.2%
Taylor expanded in k around 0 38.2%
associate-*r/38.2%
associate-*l/38.2%
associate-/r/38.2%
Simplified38.2%
Final simplification38.2%
herbie shell --seed 2024042
(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))))