
(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 (/ (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.6%
associate-*l/99.6%
*-lft-identity99.6%
associate-*l*99.6%
div-sub99.6%
metadata-eval99.6%
Simplified99.6%
(FPCore (k n) :precision binary64 (if (<= k 3.2e-77) (* (sqrt (/ PI k)) (sqrt (* 2.0 n))) (sqrt (/ (pow (* PI (* 2.0 n)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 3.2e-77) {
tmp = sqrt((((double) M_PI) / k)) * sqrt((2.0 * 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 <= 3.2e-77) {
tmp = Math.sqrt((Math.PI / k)) * Math.sqrt((2.0 * 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 <= 3.2e-77: tmp = math.sqrt((math.pi / k)) * math.sqrt((2.0 * 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 <= 3.2e-77) tmp = Float64(sqrt(Float64(pi / k)) * sqrt(Float64(2.0 * 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 <= 3.2e-77) tmp = sqrt((pi / k)) * sqrt((2.0 * n)); else tmp = sqrt((((pi * (2.0 * n)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.2e-77], N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 * n), $MachinePrecision]], $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 3.2 \cdot 10^{-77}:\\
\;\;\;\;\sqrt{\frac{\pi}{k}} \cdot \sqrt{2 \cdot 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 < 3.2e-77Initial program 99.3%
Taylor expanded in k around 0 72.1%
associate-/l*72.2%
Simplified72.2%
pow172.2%
*-commutative72.2%
sqrt-unprod72.3%
associate-*r/72.2%
*-commutative72.2%
Applied egg-rr72.2%
unpow172.2%
*-commutative72.2%
associate-/l*72.4%
associate-*l*72.4%
Simplified72.4%
associate-*r*72.4%
sqrt-prod72.2%
div-inv72.2%
associate-*r*72.2%
*-commutative72.2%
associate-*r*72.2%
div-inv72.2%
*-commutative72.2%
sqrt-unprod99.1%
associate-*l*99.1%
sqrt-unprod99.4%
Applied egg-rr99.4%
if 3.2e-77 < k Initial program 99.7%
Taylor expanded in k around 0 99.7%
Applied egg-rr99.2%
distribute-lft-in99.2%
metadata-eval99.2%
*-commutative99.2%
associate-*r*99.2%
metadata-eval99.2%
neg-mul-199.2%
sub-neg99.2%
*-commutative99.2%
associate-*l*99.2%
Simplified99.2%
Final simplification99.3%
(FPCore (k n) :precision binary64 (if (<= k 1.85e+87) (* (sqrt (/ PI k)) (sqrt (* 2.0 n))) (sqrt (+ 1.0 (fma PI (/ (* 2.0 n) k) -1.0)))))
double code(double k, double n) {
double tmp;
if (k <= 1.85e+87) {
tmp = sqrt((((double) M_PI) / k)) * sqrt((2.0 * n));
} else {
tmp = sqrt((1.0 + fma(((double) M_PI), ((2.0 * n) / k), -1.0)));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 1.85e+87) tmp = Float64(sqrt(Float64(pi / k)) * sqrt(Float64(2.0 * n))); else tmp = sqrt(Float64(1.0 + fma(pi, Float64(Float64(2.0 * n) / k), -1.0))); end return tmp end
code[k_, n_] := If[LessEqual[k, 1.85e+87], N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(1.0 + N[(Pi * N[(N[(2.0 * n), $MachinePrecision] / k), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.85 \cdot 10^{+87}:\\
\;\;\;\;\sqrt{\frac{\pi}{k}} \cdot \sqrt{2 \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 + \mathsf{fma}\left(\pi, \frac{2 \cdot n}{k}, -1\right)}\\
\end{array}
\end{array}
if k < 1.85000000000000001e87Initial program 99.3%
Taylor expanded in k around 0 56.5%
associate-/l*56.5%
Simplified56.5%
pow156.5%
*-commutative56.5%
sqrt-unprod56.7%
associate-*r/56.6%
*-commutative56.6%
Applied egg-rr56.6%
unpow156.6%
*-commutative56.6%
associate-/l*56.7%
associate-*l*56.7%
Simplified56.7%
associate-*r*56.7%
sqrt-prod56.5%
div-inv56.6%
associate-*r*56.6%
*-commutative56.6%
associate-*r*56.5%
div-inv56.5%
*-commutative56.5%
sqrt-unprod72.3%
associate-*l*72.3%
sqrt-unprod72.5%
Applied egg-rr72.5%
if 1.85000000000000001e87 < k Initial program 100.0%
Taylor expanded in k around 0 2.8%
associate-/l*2.8%
Simplified2.8%
pow12.8%
*-commutative2.8%
sqrt-unprod2.8%
associate-*r/2.8%
*-commutative2.8%
Applied egg-rr2.8%
unpow12.8%
*-commutative2.8%
associate-/l*2.8%
associate-*l*2.8%
Simplified2.8%
*-commutative2.8%
clear-num2.8%
un-div-inv2.8%
Applied egg-rr2.8%
expm1-log1p-u2.8%
expm1-undefine42.4%
*-commutative42.4%
div-inv42.4%
clear-num42.4%
associate-*r*42.4%
associate-/r/42.4%
*-commutative42.4%
div-inv42.4%
clear-num42.4%
associate-*l*42.4%
Applied egg-rr42.4%
log1p-undefine42.4%
rem-exp-log42.4%
associate-+r-42.4%
associate-*r*42.4%
*-commutative42.4%
associate-*r/42.4%
associate-*r/42.4%
associate-*r*42.4%
*-commutative42.4%
associate-/l*42.4%
associate-*l/42.4%
*-commutative42.4%
fma-neg42.4%
metadata-eval42.4%
associate-*r/42.4%
Simplified42.4%
Final simplification61.7%
(FPCore (k n) :precision binary64 (if (<= k 1.85e+87) (* (sqrt (/ PI k)) (sqrt (* 2.0 n))) (sqrt (+ -1.0 (fma n (* 2.0 (/ PI k)) 1.0)))))
double code(double k, double n) {
double tmp;
if (k <= 1.85e+87) {
tmp = sqrt((((double) M_PI) / k)) * sqrt((2.0 * n));
} else {
tmp = sqrt((-1.0 + fma(n, (2.0 * (((double) M_PI) / k)), 1.0)));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 1.85e+87) tmp = Float64(sqrt(Float64(pi / k)) * sqrt(Float64(2.0 * n))); else tmp = sqrt(Float64(-1.0 + fma(n, Float64(2.0 * Float64(pi / k)), 1.0))); end return tmp end
code[k_, n_] := If[LessEqual[k, 1.85e+87], N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(-1.0 + N[(n * N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.85 \cdot 10^{+87}:\\
\;\;\;\;\sqrt{\frac{\pi}{k}} \cdot \sqrt{2 \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{-1 + \mathsf{fma}\left(n, 2 \cdot \frac{\pi}{k}, 1\right)}\\
\end{array}
\end{array}
if k < 1.85000000000000001e87Initial program 99.3%
Taylor expanded in k around 0 56.5%
associate-/l*56.5%
Simplified56.5%
pow156.5%
*-commutative56.5%
sqrt-unprod56.7%
associate-*r/56.6%
*-commutative56.6%
Applied egg-rr56.6%
unpow156.6%
*-commutative56.6%
associate-/l*56.7%
associate-*l*56.7%
Simplified56.7%
associate-*r*56.7%
sqrt-prod56.5%
div-inv56.6%
associate-*r*56.6%
*-commutative56.6%
associate-*r*56.5%
div-inv56.5%
*-commutative56.5%
sqrt-unprod72.3%
associate-*l*72.3%
sqrt-unprod72.5%
Applied egg-rr72.5%
if 1.85000000000000001e87 < k Initial program 100.0%
Taylor expanded in k around 0 2.8%
associate-/l*2.8%
Simplified2.8%
pow12.8%
*-commutative2.8%
sqrt-unprod2.8%
associate-*r/2.8%
*-commutative2.8%
Applied egg-rr2.8%
unpow12.8%
*-commutative2.8%
associate-/l*2.8%
associate-*l*2.8%
Simplified2.8%
expm1-log1p-u2.8%
expm1-undefine42.4%
*-commutative42.4%
*-commutative42.4%
associate-*l*42.4%
div-inv42.4%
associate-*r*42.4%
*-commutative42.4%
div-inv42.4%
Applied egg-rr42.4%
sub-neg42.4%
metadata-eval42.4%
+-commutative42.4%
log1p-undefine42.4%
rem-exp-log42.4%
+-commutative42.4%
*-commutative42.4%
associate-*l*42.4%
fma-define42.4%
Simplified42.4%
Final simplification61.7%
(FPCore (k n) :precision binary64 (if (<= k 1.85e+87) (* (sqrt (/ PI k)) (sqrt (* 2.0 n))) (sqrt (* PI (+ -1.0 (fma 2.0 (/ n k) 1.0))))))
double code(double k, double n) {
double tmp;
if (k <= 1.85e+87) {
tmp = sqrt((((double) M_PI) / k)) * sqrt((2.0 * n));
} else {
tmp = sqrt((((double) M_PI) * (-1.0 + fma(2.0, (n / k), 1.0))));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 1.85e+87) tmp = Float64(sqrt(Float64(pi / k)) * sqrt(Float64(2.0 * n))); else tmp = sqrt(Float64(pi * Float64(-1.0 + fma(2.0, Float64(n / k), 1.0)))); end return tmp end
code[k_, n_] := If[LessEqual[k, 1.85e+87], N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(Pi * N[(-1.0 + N[(2.0 * N[(n / k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.85 \cdot 10^{+87}:\\
\;\;\;\;\sqrt{\frac{\pi}{k}} \cdot \sqrt{2 \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\pi \cdot \left(-1 + \mathsf{fma}\left(2, \frac{n}{k}, 1\right)\right)}\\
\end{array}
\end{array}
if k < 1.85000000000000001e87Initial program 99.3%
Taylor expanded in k around 0 56.5%
associate-/l*56.5%
Simplified56.5%
pow156.5%
*-commutative56.5%
sqrt-unprod56.7%
associate-*r/56.6%
*-commutative56.6%
Applied egg-rr56.6%
unpow156.6%
*-commutative56.6%
associate-/l*56.7%
associate-*l*56.7%
Simplified56.7%
associate-*r*56.7%
sqrt-prod56.5%
div-inv56.6%
associate-*r*56.6%
*-commutative56.6%
associate-*r*56.5%
div-inv56.5%
*-commutative56.5%
sqrt-unprod72.3%
associate-*l*72.3%
sqrt-unprod72.5%
Applied egg-rr72.5%
if 1.85000000000000001e87 < k Initial program 100.0%
Taylor expanded in k around 0 2.8%
associate-/l*2.8%
Simplified2.8%
pow12.8%
*-commutative2.8%
sqrt-unprod2.8%
associate-*r/2.8%
*-commutative2.8%
Applied egg-rr2.8%
unpow12.8%
*-commutative2.8%
associate-/l*2.8%
associate-*l*2.8%
Simplified2.8%
expm1-log1p-u2.8%
expm1-undefine42.4%
associate-*l/42.4%
Applied egg-rr42.4%
sub-neg42.4%
metadata-eval42.4%
+-commutative42.4%
log1p-undefine42.4%
rem-exp-log42.4%
+-commutative42.4%
*-commutative42.4%
associate-*r/42.4%
fma-define42.4%
Simplified42.4%
Final simplification61.7%
(FPCore (k n) :precision binary64 (if (<= k 6.5e+256) (* (sqrt (/ PI k)) (sqrt (* 2.0 n))) (cbrt (pow (* (/ PI k) (* 2.0 n)) 1.5))))
double code(double k, double n) {
double tmp;
if (k <= 6.5e+256) {
tmp = sqrt((((double) M_PI) / k)) * sqrt((2.0 * n));
} else {
tmp = cbrt(pow(((((double) M_PI) / k) * (2.0 * n)), 1.5));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 6.5e+256) {
tmp = Math.sqrt((Math.PI / k)) * Math.sqrt((2.0 * n));
} else {
tmp = Math.cbrt(Math.pow(((Math.PI / k) * (2.0 * n)), 1.5));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 6.5e+256) tmp = Float64(sqrt(Float64(pi / k)) * sqrt(Float64(2.0 * n))); else tmp = cbrt((Float64(Float64(pi / k) * Float64(2.0 * n)) ^ 1.5)); end return tmp end
code[k_, n_] := If[LessEqual[k, 6.5e+256], N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(N[(Pi / k), $MachinePrecision] * N[(2.0 * n), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 6.5 \cdot 10^{+256}:\\
\;\;\;\;\sqrt{\frac{\pi}{k}} \cdot \sqrt{2 \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{\pi}{k} \cdot \left(2 \cdot n\right)\right)}^{1.5}}\\
\end{array}
\end{array}
if k < 6.50000000000000053e256Initial program 99.5%
Taylor expanded in k around 0 42.5%
associate-/l*42.5%
Simplified42.5%
pow142.5%
*-commutative42.5%
sqrt-unprod42.6%
associate-*r/42.5%
*-commutative42.5%
Applied egg-rr42.5%
unpow142.5%
*-commutative42.5%
associate-/l*42.6%
associate-*l*42.6%
Simplified42.6%
associate-*r*42.6%
sqrt-prod42.5%
div-inv42.5%
associate-*r*42.5%
*-commutative42.5%
associate-*r*42.5%
div-inv42.5%
*-commutative42.5%
sqrt-unprod54.1%
associate-*l*54.1%
sqrt-unprod54.3%
Applied egg-rr54.3%
if 6.50000000000000053e256 < k Initial program 100.0%
Taylor expanded in k around 0 2.9%
associate-/l*2.9%
Simplified2.9%
pow12.9%
*-commutative2.9%
sqrt-unprod2.9%
associate-*r/2.9%
*-commutative2.9%
Applied egg-rr2.9%
unpow12.9%
*-commutative2.9%
associate-/l*2.9%
associate-*l*2.9%
Simplified2.9%
add-cbrt-cube31.1%
pow1/331.1%
Applied egg-rr31.1%
unpow1/331.1%
associate-*r*31.1%
*-commutative31.1%
Simplified31.1%
Final simplification51.2%
(FPCore (k n) :precision binary64 (* (sqrt (/ PI k)) (sqrt (* 2.0 n))))
double code(double k, double n) {
return sqrt((((double) M_PI) / k)) * sqrt((2.0 * n));
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI / k)) * Math.sqrt((2.0 * n));
}
def code(k, n): return math.sqrt((math.pi / k)) * math.sqrt((2.0 * n))
function code(k, n) return Float64(sqrt(Float64(pi / k)) * sqrt(Float64(2.0 * n))) end
function tmp = code(k, n) tmp = sqrt((pi / k)) * sqrt((2.0 * n)); end
code[k_, n_] := N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{\pi}{k}} \cdot \sqrt{2 \cdot n}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0 37.2%
associate-/l*37.2%
Simplified37.2%
pow137.2%
*-commutative37.2%
sqrt-unprod37.3%
associate-*r/37.3%
*-commutative37.3%
Applied egg-rr37.3%
unpow137.3%
*-commutative37.3%
associate-/l*37.3%
associate-*l*37.3%
Simplified37.3%
associate-*r*37.3%
sqrt-prod37.2%
div-inv37.2%
associate-*r*37.2%
*-commutative37.2%
associate-*r*37.2%
div-inv37.2%
*-commutative37.2%
sqrt-unprod47.4%
associate-*l*47.3%
sqrt-unprod47.5%
Applied egg-rr47.5%
Final simplification47.5%
(FPCore (k n) :precision binary64 (sqrt (* PI (* 2.0 (/ n k)))))
double code(double k, double n) {
return sqrt((((double) M_PI) * (2.0 * (n / k))));
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI * (2.0 * (n / k))));
}
def code(k, n): return math.sqrt((math.pi * (2.0 * (n / k))))
function code(k, n) return sqrt(Float64(pi * Float64(2.0 * Float64(n / k)))) end
function tmp = code(k, n) tmp = sqrt((pi * (2.0 * (n / k)))); end
code[k_, n_] := N[Sqrt[N[(Pi * N[(2.0 * N[(n / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\pi \cdot \left(2 \cdot \frac{n}{k}\right)}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0 37.2%
associate-/l*37.2%
Simplified37.2%
pow137.2%
*-commutative37.2%
sqrt-unprod37.3%
associate-*r/37.3%
*-commutative37.3%
Applied egg-rr37.3%
unpow137.3%
*-commutative37.3%
associate-/l*37.3%
associate-*l*37.3%
Simplified37.3%
Final simplification37.3%
(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.6%
Taylor expanded in k around 0 37.2%
associate-/l*37.2%
Simplified37.2%
pow137.2%
*-commutative37.2%
sqrt-unprod37.3%
associate-*r/37.3%
*-commutative37.3%
Applied egg-rr37.3%
unpow137.3%
*-commutative37.3%
associate-/l*37.3%
associate-*l*37.3%
Simplified37.3%
*-commutative37.3%
clear-num37.3%
un-div-inv37.3%
Applied egg-rr37.3%
associate-/r/37.3%
Applied egg-rr37.3%
Final simplification37.3%
herbie shell --seed 2024113
(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))))