
(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}
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 (* (/ 1.0 (sqrt k)) (/ (sqrt (* (+ PI PI) n)) (pow (sqrt (* (+ n n) PI)) k))))
double code(double k, double n) {
return (1.0 / sqrt(k)) * (sqrt(((((double) M_PI) + ((double) M_PI)) * n)) / pow(sqrt(((n + n) * ((double) M_PI))), k));
}
public static double code(double k, double n) {
return (1.0 / Math.sqrt(k)) * (Math.sqrt(((Math.PI + Math.PI) * n)) / Math.pow(Math.sqrt(((n + n) * Math.PI)), k));
}
def code(k, n): return (1.0 / math.sqrt(k)) * (math.sqrt(((math.pi + math.pi) * n)) / math.pow(math.sqrt(((n + n) * math.pi)), k))
function code(k, n) return Float64(Float64(1.0 / sqrt(k)) * Float64(sqrt(Float64(Float64(pi + pi) * n)) / (sqrt(Float64(Float64(n + n) * pi)) ^ k))) end
function tmp = code(k, n) tmp = (1.0 / sqrt(k)) * (sqrt(((pi + pi) * n)) / (sqrt(((n + n) * pi)) ^ k)); end
code[k_, n_] := N[(N[(1.0 / N[Sqrt[k], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(N[(Pi + Pi), $MachinePrecision] * n), $MachinePrecision]], $MachinePrecision] / N[Power[N[Sqrt[N[(N[(n + n), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision], k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{k}} \cdot \frac{\sqrt{\left(\pi + \pi\right) \cdot n}}{{\left(\sqrt{\left(n + n\right) \cdot \pi}\right)}^{k}}
\end{array}
Initial program 99.4%
lift-pow.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
metadata-evalN/A
pow-subN/A
pow1/2N/A
associate-*l*N/A
*-commutativeN/A
sqrt-prodN/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites99.5%
lift-/.f64N/A
frac-2negN/A
mul-1-negN/A
*-commutativeN/A
metadata-evalN/A
associate-/l*N/A
metadata-evalN/A
lower-*.f6499.5
Applied rewrites99.5%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
count-2-revN/A
associate-*l*N/A
*-commutativeN/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
mul-1-negN/A
metadata-evalN/A
frac-2negN/A
sqrt-pow2N/A
*-commutativeN/A
sqrt-unprodN/A
lower-pow.f64N/A
Applied rewrites99.5%
(FPCore (k n) :precision binary64 (* (sqrt (/ 1.0 k)) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return sqrt((1.0 / k)) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return Math.sqrt((1.0 / k)) * Math.pow(((2.0 * Math.PI) * n), ((1.0 - k) / 2.0));
}
def code(k, n): return math.sqrt((1.0 / k)) * math.pow(((2.0 * math.pi) * n), ((1.0 - k) / 2.0))
function code(k, n) return Float64(sqrt(Float64(1.0 / k)) * (Float64(Float64(2.0 * pi) * n) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = sqrt((1.0 / k)) * (((2.0 * pi) * n) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[Sqrt[N[(1.0 / 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}
\\
\sqrt{\frac{1}{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Initial program 99.4%
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-sqrt.f64N/A
lower-/.f6499.4
Applied rewrites99.4%
(FPCore (k n) :precision binary64 (/ (pow (* (+ PI PI) n) (fma k -0.5 0.5)) (sqrt k)))
double code(double k, double n) {
return pow(((((double) M_PI) + ((double) M_PI)) * n), fma(k, -0.5, 0.5)) / sqrt(k);
}
function code(k, n) return Float64((Float64(Float64(pi + pi) * n) ^ fma(k, -0.5, 0.5)) / sqrt(k)) end
code[k_, n_] := N[(N[Power[N[(N[(Pi + Pi), $MachinePrecision] * n), $MachinePrecision], N[(k * -0.5 + 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\left(\pi + \pi\right) \cdot n\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}
\end{array}
Initial program 99.4%
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
Applied rewrites99.5%
lift--.f64N/A
lift-/.f64N/A
div-subN/A
metadata-evalN/A
frac-2negN/A
mul-1-negN/A
*-commutativeN/A
metadata-evalN/A
associate-/l*N/A
metadata-evalN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6499.5
Applied rewrites99.5%
(FPCore (k n) :precision binary64 (/ (pow (sqrt (* (+ n n) PI)) (- 1.0 k)) (sqrt k)))
double code(double k, double n) {
return pow(sqrt(((n + n) * ((double) M_PI))), (1.0 - k)) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow(Math.sqrt(((n + n) * Math.PI)), (1.0 - k)) / Math.sqrt(k);
}
def code(k, n): return math.pow(math.sqrt(((n + n) * math.pi)), (1.0 - k)) / math.sqrt(k)
function code(k, n) return Float64((sqrt(Float64(Float64(n + n) * pi)) ^ Float64(1.0 - k)) / sqrt(k)) end
function tmp = code(k, n) tmp = (sqrt(((n + n) * pi)) ^ (1.0 - k)) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[Sqrt[N[(N[(n + n), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\sqrt{\left(n + n\right) \cdot \pi}\right)}^{\left(1 - k\right)}}{\sqrt{k}}
\end{array}
Initial program 99.4%
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
Applied rewrites99.5%
Taylor expanded in k around inf
Applied rewrites99.4%
(FPCore (k n) :precision binary64 (if (<= k 1.0) (* (sqrt (/ PI k)) (sqrt (+ n n))) (/ (pow (sqrt (* (+ n n) PI)) (- k)) (sqrt k))))
double code(double k, double n) {
double tmp;
if (k <= 1.0) {
tmp = sqrt((((double) M_PI) / k)) * sqrt((n + n));
} else {
tmp = pow(sqrt(((n + n) * ((double) M_PI))), -k) / sqrt(k);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1.0) {
tmp = Math.sqrt((Math.PI / k)) * Math.sqrt((n + n));
} else {
tmp = Math.pow(Math.sqrt(((n + n) * Math.PI)), -k) / Math.sqrt(k);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 1.0: tmp = math.sqrt((math.pi / k)) * math.sqrt((n + n)) else: tmp = math.pow(math.sqrt(((n + n) * math.pi)), -k) / math.sqrt(k) return tmp
function code(k, n) tmp = 0.0 if (k <= 1.0) tmp = Float64(sqrt(Float64(pi / k)) * sqrt(Float64(n + n))); else tmp = Float64((sqrt(Float64(Float64(n + n) * pi)) ^ Float64(-k)) / sqrt(k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 1.0) tmp = sqrt((pi / k)) * sqrt((n + n)); else tmp = (sqrt(((n + n) * pi)) ^ -k) / sqrt(k); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.0], N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(n + n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Sqrt[N[(N[(n + n), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision], (-k)], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;\sqrt{\frac{\pi}{k}} \cdot \sqrt{n + n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\sqrt{\left(n + n\right) \cdot \pi}\right)}^{\left(-k\right)}}{\sqrt{k}}\\
\end{array}
\end{array}
if k < 1Initial program 98.9%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-/.f64N/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-PI.f6473.6
Applied rewrites73.6%
lift-/.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
count-2-revN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lift-+.f64N/A
lift-PI.f64N/A
lift-PI.f6473.6
Applied rewrites73.6%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
distribute-lft-inN/A
associate-*l/N/A
associate-*l/N/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-outN/A
lift-+.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f6496.5
Applied rewrites96.5%
if 1 < k Initial program 100.0%
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
Applied rewrites100.0%
Taylor expanded in k around inf
Applied rewrites99.9%
Taylor expanded in k around inf
mul-1-negN/A
lower-neg.f6499.7
Applied rewrites99.7%
(FPCore (k n) :precision binary64 (if (<= (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))) 0.0) (sqrt (* PI (/ (fma n k (* n k)) (* k k)))) (* (sqrt (/ PI k)) (sqrt (+ n n)))))
double code(double k, double n) {
double tmp;
if (((1.0 / sqrt(k)) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0))) <= 0.0) {
tmp = sqrt((((double) M_PI) * (fma(n, k, (n * k)) / (k * k))));
} else {
tmp = sqrt((((double) M_PI) / k)) * sqrt((n + n));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(k)) * (Float64(Float64(2.0 * pi) * n) ^ Float64(Float64(1.0 - k) / 2.0))) <= 0.0) tmp = sqrt(Float64(pi * Float64(fma(n, k, Float64(n * k)) / Float64(k * k)))); else tmp = Float64(sqrt(Float64(pi / k)) * sqrt(Float64(n + n))); end return tmp end
code[k_, n_] := If[LessEqual[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], 0.0], N[Sqrt[N[(Pi * N[(N[(n * k + N[(n * k), $MachinePrecision]), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(n + n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \leq 0:\\
\;\;\;\;\sqrt{\pi \cdot \frac{\mathsf{fma}\left(n, k, n \cdot k\right)}{k \cdot k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\pi}{k}} \cdot \sqrt{n + n}\\
\end{array}
\end{array}
if (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) < 0.0Initial program 100.0%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-/.f64N/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-PI.f643.2
Applied rewrites3.2%
lift-/.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
count-2-revN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lift-+.f64N/A
lift-PI.f64N/A
lift-PI.f643.2
Applied rewrites3.2%
lift-*.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
distribute-lft-inN/A
count-2N/A
associate-*l/N/A
associate-*r/N/A
count-2-revN/A
distribute-rgt-outN/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-/.f643.2
Applied rewrites3.2%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
frac-addN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6414.2
Applied rewrites14.2%
if 0.0 < (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) Initial program 99.3%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-/.f64N/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-PI.f6449.5
Applied rewrites49.5%
lift-/.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
count-2-revN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lift-+.f64N/A
lift-PI.f64N/A
lift-PI.f6449.5
Applied rewrites49.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
distribute-lft-inN/A
associate-*l/N/A
associate-*l/N/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-outN/A
lift-+.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f6464.7
Applied rewrites64.7%
(FPCore (k n) :precision binary64 (* (sqrt (/ PI k)) (sqrt (+ n n))))
double code(double k, double n) {
return sqrt((((double) M_PI) / k)) * sqrt((n + n));
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI / k)) * Math.sqrt((n + n));
}
def code(k, n): return math.sqrt((math.pi / k)) * math.sqrt((n + n))
function code(k, n) return Float64(sqrt(Float64(pi / k)) * sqrt(Float64(n + n))) end
function tmp = code(k, n) tmp = sqrt((pi / k)) * sqrt((n + n)); end
code[k_, n_] := N[(N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(n + n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{\pi}{k}} \cdot \sqrt{n + n}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-/.f64N/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-PI.f6438.1
Applied rewrites38.1%
lift-/.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
count-2-revN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lift-+.f64N/A
lift-PI.f64N/A
lift-PI.f6438.1
Applied rewrites38.1%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
distribute-lft-inN/A
associate-*l/N/A
associate-*l/N/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-outN/A
lift-+.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f6449.6
Applied rewrites49.6%
(FPCore (k n) :precision binary64 (sqrt (* (/ PI k) (+ n n))))
double code(double k, double n) {
return sqrt(((((double) M_PI) / k) * (n + n)));
}
public static double code(double k, double n) {
return Math.sqrt(((Math.PI / k) * (n + n)));
}
def code(k, n): return math.sqrt(((math.pi / k) * (n + n)))
function code(k, n) return sqrt(Float64(Float64(pi / k) * Float64(n + n))) end
function tmp = code(k, n) tmp = sqrt(((pi / k) * (n + n))); end
code[k_, n_] := N[Sqrt[N[(N[(Pi / k), $MachinePrecision] * N[(n + n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{\pi}{k} \cdot \left(n + n\right)}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-/.f64N/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-PI.f6438.1
Applied rewrites38.1%
lift-/.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
count-2-revN/A
associate-*l*N/A
*-commutativeN/A
associate-*r/N/A
count-2-revN/A
associate-/l*N/A
associate-/l*N/A
distribute-rgt-outN/A
count-2-revN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
count-2-revN/A
lower-+.f6438.0
Applied rewrites38.0%
(FPCore (k n) :precision binary64 (sqrt (* PI (/ (+ n n) k))))
double code(double k, double n) {
return sqrt((((double) M_PI) * ((n + n) / k)));
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI * ((n + n) / k)));
}
def code(k, n): return math.sqrt((math.pi * ((n + n) / k)))
function code(k, n) return sqrt(Float64(pi * Float64(Float64(n + n) / k))) end
function tmp = code(k, n) tmp = sqrt((pi * ((n + n) / k))); end
code[k_, n_] := N[Sqrt[N[(Pi * N[(N[(n + n), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\pi \cdot \frac{n + n}{k}}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-/.f64N/A
lower-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-PI.f6438.1
Applied rewrites38.1%
lift-/.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
count-2-revN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lift-+.f64N/A
lift-PI.f64N/A
lift-PI.f6438.1
Applied rewrites38.1%
lift-*.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
distribute-lft-inN/A
count-2N/A
associate-*l/N/A
associate-*r/N/A
count-2-revN/A
distribute-rgt-outN/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-/.f6438.1
Applied rewrites38.1%
herbie shell --seed 2025130
(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))))