
(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 (if (<= k 2.55e-17) (/ (sqrt (* 2.0 n)) (sqrt (/ k PI))) (pow (/ k (pow (* (* 2.0 PI) n) (- 1.0 k))) -0.5)))
double code(double k, double n) {
double tmp;
if (k <= 2.55e-17) {
tmp = sqrt((2.0 * n)) / sqrt((k / ((double) M_PI)));
} else {
tmp = pow((k / pow(((2.0 * ((double) M_PI)) * n), (1.0 - k))), -0.5);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.55e-17) {
tmp = Math.sqrt((2.0 * n)) / Math.sqrt((k / Math.PI));
} else {
tmp = Math.pow((k / Math.pow(((2.0 * Math.PI) * n), (1.0 - k))), -0.5);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.55e-17: tmp = math.sqrt((2.0 * n)) / math.sqrt((k / math.pi)) else: tmp = math.pow((k / math.pow(((2.0 * math.pi) * n), (1.0 - k))), -0.5) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.55e-17) tmp = Float64(sqrt(Float64(2.0 * n)) / sqrt(Float64(k / pi))); else tmp = Float64(k / (Float64(Float64(2.0 * pi) * n) ^ Float64(1.0 - k))) ^ -0.5; end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.55e-17) tmp = sqrt((2.0 * n)) / sqrt((k / pi)); else tmp = (k / (((2.0 * pi) * n) ^ (1.0 - k))) ^ -0.5; end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.55e-17], N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(k / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(k / N[Power[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.55 \cdot 10^{-17}:\\
\;\;\;\;\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{k}{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(1 - k\right)}}\right)}^{-0.5}\\
\end{array}
\end{array}
if k < 2.5500000000000001e-17Initial program 99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
div-inv99.3%
add-sqr-sqrt98.9%
sqrt-unprod75.6%
frac-times75.4%
Applied egg-rr75.8%
Taylor expanded in k around 0 75.8%
associate-*r*75.8%
Simplified75.8%
associate-/l*75.7%
sqrt-div99.4%
Applied egg-rr99.4%
*-commutative99.4%
Simplified99.4%
if 2.5500000000000001e-17 < k Initial program 99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r*99.6%
div-inv99.6%
add-sqr-sqrt99.6%
sqrt-unprod99.6%
frac-times99.6%
Applied egg-rr99.6%
clear-num99.6%
sqrt-div99.6%
metadata-eval99.6%
Applied egg-rr99.6%
*-commutative99.6%
associate-*r*99.6%
Simplified99.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 5.8e-17) (/ (sqrt (* 2.0 n)) (sqrt (/ k PI))) (pow (* k (pow (* (* 2.0 PI) n) (+ k -1.0))) -0.5)))
double code(double k, double n) {
double tmp;
if (k <= 5.8e-17) {
tmp = sqrt((2.0 * n)) / sqrt((k / ((double) M_PI)));
} else {
tmp = pow((k * pow(((2.0 * ((double) M_PI)) * n), (k + -1.0))), -0.5);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 5.8e-17) {
tmp = Math.sqrt((2.0 * n)) / Math.sqrt((k / Math.PI));
} else {
tmp = Math.pow((k * Math.pow(((2.0 * Math.PI) * n), (k + -1.0))), -0.5);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 5.8e-17: tmp = math.sqrt((2.0 * n)) / math.sqrt((k / math.pi)) else: tmp = math.pow((k * math.pow(((2.0 * math.pi) * n), (k + -1.0))), -0.5) return tmp
function code(k, n) tmp = 0.0 if (k <= 5.8e-17) tmp = Float64(sqrt(Float64(2.0 * n)) / sqrt(Float64(k / pi))); else tmp = Float64(k * (Float64(Float64(2.0 * pi) * n) ^ Float64(k + -1.0))) ^ -0.5; end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 5.8e-17) tmp = sqrt((2.0 * n)) / sqrt((k / pi)); else tmp = (k * (((2.0 * pi) * n) ^ (k + -1.0))) ^ -0.5; end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 5.8e-17], N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(k / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(k * N[Power[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], N[(k + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 5.8 \cdot 10^{-17}:\\
\;\;\;\;\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}\\
\mathbf{else}:\\
\;\;\;\;{\left(k \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(k + -1\right)}\right)}^{-0.5}\\
\end{array}
\end{array}
if k < 5.8000000000000006e-17Initial program 99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
div-inv99.3%
add-sqr-sqrt98.9%
sqrt-unprod75.6%
frac-times75.4%
Applied egg-rr75.8%
Taylor expanded in k around 0 75.8%
associate-*r*75.8%
Simplified75.8%
associate-/l*75.7%
sqrt-div99.4%
Applied egg-rr99.4%
*-commutative99.4%
Simplified99.4%
if 5.8000000000000006e-17 < k Initial program 99.6%
*-commutative99.6%
associate-*r*99.6%
associate-/r/99.6%
add-sqr-sqrt99.6%
sqrt-unprod99.6%
associate-*r*99.6%
*-commutative99.6%
associate-*r*99.6%
*-commutative99.6%
pow-prod-up99.6%
Applied egg-rr99.6%
inv-pow99.6%
sqrt-undiv99.6%
sqrt-pow299.6%
div-inv99.6%
pow-sub99.3%
pow199.3%
clear-num99.3%
pow199.3%
pow-div99.6%
metadata-eval99.6%
Applied egg-rr99.6%
*-commutative99.6%
*-commutative99.6%
associate-*l*99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.5%
(FPCore (k n) :precision binary64 (* (pow k -0.5) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return pow(k, -0.5) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) * Math.pow(((2.0 * Math.PI) * n), ((1.0 - k) / 2.0));
}
def code(k, n): return math.pow(k, -0.5) * math.pow(((2.0 * math.pi) * n), ((1.0 - k) / 2.0))
function code(k, n) return Float64((k ^ -0.5) * (Float64(Float64(2.0 * pi) * n) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = (k ^ -0.5) * (((2.0 * pi) * n) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[Power[k, -0.5], $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}
\\
{k}^{-0.5} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Initial program 99.5%
expm1-log1p-u96.2%
expm1-udef73.6%
inv-pow73.6%
sqrt-pow273.6%
metadata-eval73.6%
Applied egg-rr73.6%
expm1-def96.2%
expm1-log1p99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (k n) :precision binary64 (if (<= k 4.5e-17) (/ (sqrt (* 2.0 n)) (sqrt (/ k PI))) (sqrt (/ (pow (* 2.0 (* PI n)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 4.5e-17) {
tmp = sqrt((2.0 * n)) / sqrt((k / ((double) M_PI)));
} 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 <= 4.5e-17) {
tmp = Math.sqrt((2.0 * n)) / Math.sqrt((k / Math.PI));
} 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 <= 4.5e-17: tmp = math.sqrt((2.0 * n)) / math.sqrt((k / math.pi)) 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 <= 4.5e-17) tmp = Float64(sqrt(Float64(2.0 * n)) / sqrt(Float64(k / pi))); 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 <= 4.5e-17) tmp = sqrt((2.0 * n)) / sqrt((k / pi)); else tmp = sqrt((((2.0 * (pi * n)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 4.5e-17], N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(k / Pi), $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 4.5 \cdot 10^{-17}:\\
\;\;\;\;\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 4.49999999999999978e-17Initial program 99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
div-inv99.3%
add-sqr-sqrt98.9%
sqrt-unprod75.6%
frac-times75.4%
Applied egg-rr75.8%
Taylor expanded in k around 0 75.8%
associate-*r*75.8%
Simplified75.8%
associate-/l*75.7%
sqrt-div99.4%
Applied egg-rr99.4%
*-commutative99.4%
Simplified99.4%
if 4.49999999999999978e-17 < k Initial program 99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r*99.6%
div-inv99.6%
add-sqr-sqrt99.6%
sqrt-unprod99.6%
frac-times99.6%
Applied egg-rr99.6%
Final simplification99.5%
(FPCore (k n) :precision binary64 (/ (pow (* PI (* 2.0 n)) (/ (- 1.0 k) 2.0)) (sqrt k)))
double code(double k, double n) {
return pow((((double) M_PI) * (2.0 * n)), ((1.0 - k) / 2.0)) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow((Math.PI * (2.0 * n)), ((1.0 - k) / 2.0)) / Math.sqrt(k);
}
def code(k, n): return math.pow((math.pi * (2.0 * n)), ((1.0 - k) / 2.0)) / math.sqrt(k)
function code(k, n) return Float64((Float64(pi * Float64(2.0 * n)) ^ Float64(Float64(1.0 - k) / 2.0)) / sqrt(k)) end
function tmp = code(k, n) tmp = ((pi * (2.0 * n)) ^ ((1.0 - k) / 2.0)) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.5%
associate-*l/99.5%
*-lft-identity99.5%
*-commutative99.5%
associate-*l*99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (k n) :precision binary64 (/ (sqrt (* 2.0 n)) (sqrt (/ k PI))))
double code(double k, double n) {
return sqrt((2.0 * n)) / sqrt((k / ((double) M_PI)));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * n)) / Math.sqrt((k / Math.PI));
}
def code(k, n): return math.sqrt((2.0 * n)) / math.sqrt((k / math.pi))
function code(k, n) return Float64(sqrt(Float64(2.0 * n)) / sqrt(Float64(k / pi))) end
function tmp = code(k, n) tmp = sqrt((2.0 * n)) / sqrt((k / pi)); end
code[k_, n_] := N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(k / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\pi}}}
\end{array}
Initial program 99.5%
*-commutative99.5%
*-commutative99.5%
associate-*r*99.5%
div-inv99.5%
add-sqr-sqrt99.3%
sqrt-unprod88.9%
frac-times88.8%
Applied egg-rr89.0%
Taylor expanded in k around 0 36.5%
associate-*r*36.5%
Simplified36.5%
associate-/l*36.5%
sqrt-div47.1%
Applied egg-rr47.1%
*-commutative47.1%
Simplified47.1%
Final simplification47.1%
(FPCore (k n) :precision binary64 (pow (* 0.5 (/ (/ k n) PI)) -0.5))
double code(double k, double n) {
return pow((0.5 * ((k / n) / ((double) M_PI))), -0.5);
}
public static double code(double k, double n) {
return Math.pow((0.5 * ((k / n) / Math.PI)), -0.5);
}
def code(k, n): return math.pow((0.5 * ((k / n) / math.pi)), -0.5)
function code(k, n) return Float64(0.5 * Float64(Float64(k / n) / pi)) ^ -0.5 end
function tmp = code(k, n) tmp = (0.5 * ((k / n) / pi)) ^ -0.5; end
code[k_, n_] := N[Power[N[(0.5 * N[(N[(k / n), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(0.5 \cdot \frac{\frac{k}{n}}{\pi}\right)}^{-0.5}
\end{array}
Initial program 99.5%
*-commutative99.5%
associate-*r*99.5%
associate-/r/99.5%
add-sqr-sqrt99.3%
sqrt-unprod99.5%
associate-*r*99.5%
*-commutative99.5%
associate-*r*99.5%
*-commutative99.5%
pow-prod-up99.5%
Applied egg-rr99.5%
inv-pow99.5%
sqrt-undiv89.4%
sqrt-pow289.5%
div-inv89.5%
pow-sub89.3%
pow189.3%
clear-num89.3%
pow189.3%
pow-div89.5%
metadata-eval89.5%
Applied egg-rr89.5%
*-commutative89.5%
*-commutative89.5%
associate-*l*89.5%
*-commutative89.5%
sub-neg89.5%
metadata-eval89.5%
Simplified89.5%
Taylor expanded in k around 0 43.2%
*-commutative43.2%
log-div43.0%
associate-+r-42.9%
log-prod43.1%
*-commutative43.1%
log-div34.8%
associate-*r/34.7%
exp-to-pow37.0%
associate-/r*37.0%
Simplified37.0%
Final simplification37.0%
(FPCore (k n) :precision binary64 (pow (* k (/ 0.5 (* PI n))) -0.5))
double code(double k, double n) {
return pow((k * (0.5 / (((double) M_PI) * n))), -0.5);
}
public static double code(double k, double n) {
return Math.pow((k * (0.5 / (Math.PI * n))), -0.5);
}
def code(k, n): return math.pow((k * (0.5 / (math.pi * n))), -0.5)
function code(k, n) return Float64(k * Float64(0.5 / Float64(pi * n))) ^ -0.5 end
function tmp = code(k, n) tmp = (k * (0.5 / (pi * n))) ^ -0.5; end
code[k_, n_] := N[Power[N[(k * N[(0.5 / N[(Pi * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(k \cdot \frac{0.5}{\pi \cdot n}\right)}^{-0.5}
\end{array}
Initial program 99.5%
*-commutative99.5%
associate-*r*99.5%
associate-/r/99.5%
add-sqr-sqrt99.3%
sqrt-unprod99.5%
associate-*r*99.5%
*-commutative99.5%
associate-*r*99.5%
*-commutative99.5%
pow-prod-up99.5%
Applied egg-rr99.5%
inv-pow99.5%
sqrt-undiv89.4%
sqrt-pow289.5%
div-inv89.5%
pow-sub89.3%
pow189.3%
clear-num89.3%
pow189.3%
pow-div89.5%
metadata-eval89.5%
Applied egg-rr89.5%
*-commutative89.5%
*-commutative89.5%
associate-*l*89.5%
*-commutative89.5%
sub-neg89.5%
metadata-eval89.5%
Simplified89.5%
Taylor expanded in k around 0 37.0%
Final simplification37.0%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (/ n (/ k PI)))))
double code(double k, double n) {
return sqrt((2.0 * (n / (k / ((double) M_PI)))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (n / (k / Math.PI))));
}
def code(k, n): return math.sqrt((2.0 * (n / (k / math.pi))))
function code(k, n) return sqrt(Float64(2.0 * Float64(n / Float64(k / pi)))) end
function tmp = code(k, n) tmp = sqrt((2.0 * (n / (k / pi)))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(n / N[(k / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \frac{n}{\frac{k}{\pi}}}
\end{array}
Initial program 99.5%
*-commutative99.5%
*-commutative99.5%
associate-*r*99.5%
div-inv99.5%
add-sqr-sqrt99.3%
sqrt-unprod88.9%
frac-times88.8%
Applied egg-rr89.0%
Taylor expanded in k around 0 36.5%
associate-*r*36.5%
Simplified36.5%
Taylor expanded in n around 0 36.5%
associate-/l*36.5%
Simplified36.5%
Final simplification36.5%
(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(Float64(pi * 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[(N[(Pi * n), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \frac{\pi \cdot n}{k}}
\end{array}
Initial program 99.5%
*-commutative99.5%
*-commutative99.5%
associate-*r*99.5%
div-inv99.5%
add-sqr-sqrt99.3%
sqrt-unprod88.9%
frac-times88.8%
Applied egg-rr89.0%
Taylor expanded in k around 0 36.5%
associate-*r*36.5%
Simplified36.5%
associate-*l*36.5%
*-commutative36.5%
*-un-lft-identity36.5%
times-frac36.5%
metadata-eval36.5%
Applied egg-rr36.5%
Final simplification36.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.5%
*-commutative99.5%
*-commutative99.5%
associate-*r*99.5%
div-inv99.5%
add-sqr-sqrt99.3%
sqrt-unprod88.9%
frac-times88.8%
Applied egg-rr89.0%
Taylor expanded in k around 0 36.5%
associate-*r*36.5%
Simplified36.5%
Taylor expanded in n around 0 36.5%
associate-/l*36.5%
Simplified36.5%
expm1-log1p-u34.9%
expm1-udef38.8%
Applied egg-rr38.8%
expm1-def34.9%
expm1-log1p36.5%
*-commutative36.5%
associate-/r/36.6%
*-commutative36.6%
associate-*l*36.6%
Simplified36.6%
Final simplification36.6%
herbie shell --seed 2023242
(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))))