
(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 12 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 (* (* n 2.0) PI))) (* (pow k -0.5) (/ (sqrt t_0) (pow t_0 (* k 0.5))))))
double code(double k, double n) {
double t_0 = (n * 2.0) * ((double) M_PI);
return pow(k, -0.5) * (sqrt(t_0) / pow(t_0, (k * 0.5)));
}
public static double code(double k, double n) {
double t_0 = (n * 2.0) * Math.PI;
return Math.pow(k, -0.5) * (Math.sqrt(t_0) / Math.pow(t_0, (k * 0.5)));
}
def code(k, n): t_0 = (n * 2.0) * math.pi return math.pow(k, -0.5) * (math.sqrt(t_0) / math.pow(t_0, (k * 0.5)))
function code(k, n) t_0 = Float64(Float64(n * 2.0) * pi) return Float64((k ^ -0.5) * Float64(sqrt(t_0) / (t_0 ^ Float64(k * 0.5)))) end
function tmp = code(k, n) t_0 = (n * 2.0) * pi; tmp = (k ^ -0.5) * (sqrt(t_0) / (t_0 ^ (k * 0.5))); end
code[k_, n_] := Block[{t$95$0 = N[(N[(n * 2.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[k, -0.5], $MachinePrecision] * N[(N[Sqrt[t$95$0], $MachinePrecision] / N[Power[t$95$0, N[(k * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(n \cdot 2\right) \cdot \pi\\
{k}^{-0.5} \cdot \frac{\sqrt{t_0}}{{t_0}^{\left(k \cdot 0.5\right)}}
\end{array}
\end{array}
Initial program 99.1%
expm1-log1p-u95.5%
expm1-udef77.9%
pow1/277.9%
pow-flip77.9%
metadata-eval77.9%
Applied egg-rr77.9%
expm1-def95.5%
expm1-log1p99.2%
Simplified99.2%
div-sub99.2%
metadata-eval99.2%
pow-sub99.3%
pow1/299.3%
associate-*l*99.3%
associate-*l*99.3%
div-inv99.3%
metadata-eval99.3%
Applied egg-rr99.3%
*-commutative99.3%
associate-*r*99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
*-commutative99.3%
*-commutative99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (k n) :precision binary64 (/ (/ 1.0 (sqrt k)) (pow (* (* n 2.0) PI) (fma k 0.5 -0.5))))
double code(double k, double n) {
return (1.0 / sqrt(k)) / pow(((n * 2.0) * ((double) M_PI)), fma(k, 0.5, -0.5));
}
function code(k, n) return Float64(Float64(1.0 / sqrt(k)) / (Float64(Float64(n * 2.0) * pi) ^ fma(k, 0.5, -0.5))) end
code[k_, n_] := N[(N[(1.0 / N[Sqrt[k], $MachinePrecision]), $MachinePrecision] / N[Power[N[(N[(n * 2.0), $MachinePrecision] * Pi), $MachinePrecision], N[(k * 0.5 + -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\sqrt{k}}}{{\left(\left(n \cdot 2\right) \cdot \pi\right)}^{\left(\mathsf{fma}\left(k, 0.5, -0.5\right)\right)}}
\end{array}
Initial program 99.1%
*-commutative99.1%
associate-*r*99.1%
associate-/r/99.1%
add-sqr-sqrt99.0%
sqrt-unprod99.1%
associate-*r*99.1%
*-commutative99.1%
associate-*r*99.1%
*-commutative99.1%
pow-prod-up99.1%
Applied egg-rr99.1%
div-inv99.1%
Applied egg-rr99.1%
*-commutative99.1%
associate-*r*99.1%
*-commutative99.1%
*-commutative99.1%
sqr-pow99.1%
sqr-pow99.1%
Simplified99.1%
inv-pow99.1%
sqrt-pow199.1%
pow-pow99.2%
*-commutative99.2%
associate-*l*99.2%
*-commutative99.2%
associate-*l*99.2%
div-sub99.2%
metadata-eval99.2%
div-inv99.2%
metadata-eval99.2%
Applied egg-rr99.2%
*-commutative99.2%
neg-mul-199.2%
associate-*r*99.2%
*-commutative99.2%
associate-*l*99.2%
neg-sub099.2%
metadata-eval99.2%
associate--r-99.2%
metadata-eval99.2%
metadata-eval99.2%
Simplified99.2%
expm1-log1p-u96.2%
expm1-udef83.9%
associate-/r*83.9%
*-commutative83.9%
+-commutative83.9%
fma-def83.9%
Applied egg-rr83.9%
expm1-def96.2%
expm1-log1p99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (* n 2.0) PI)))
(if (<= k 3.05e-33)
(* (pow k -0.5) (sqrt t_0))
(sqrt (* (/ 1.0 k) (pow t_0 (- 1.0 k)))))))
double code(double k, double n) {
double t_0 = (n * 2.0) * ((double) M_PI);
double tmp;
if (k <= 3.05e-33) {
tmp = pow(k, -0.5) * sqrt(t_0);
} else {
tmp = sqrt(((1.0 / k) * pow(t_0, (1.0 - k))));
}
return tmp;
}
public static double code(double k, double n) {
double t_0 = (n * 2.0) * Math.PI;
double tmp;
if (k <= 3.05e-33) {
tmp = Math.pow(k, -0.5) * Math.sqrt(t_0);
} else {
tmp = Math.sqrt(((1.0 / k) * Math.pow(t_0, (1.0 - k))));
}
return tmp;
}
def code(k, n): t_0 = (n * 2.0) * math.pi tmp = 0 if k <= 3.05e-33: tmp = math.pow(k, -0.5) * math.sqrt(t_0) else: tmp = math.sqrt(((1.0 / k) * math.pow(t_0, (1.0 - k)))) return tmp
function code(k, n) t_0 = Float64(Float64(n * 2.0) * pi) tmp = 0.0 if (k <= 3.05e-33) tmp = Float64((k ^ -0.5) * sqrt(t_0)); else tmp = sqrt(Float64(Float64(1.0 / k) * (t_0 ^ Float64(1.0 - k)))); end return tmp end
function tmp_2 = code(k, n) t_0 = (n * 2.0) * pi; tmp = 0.0; if (k <= 3.05e-33) tmp = (k ^ -0.5) * sqrt(t_0); else tmp = sqrt(((1.0 / k) * (t_0 ^ (1.0 - k)))); end tmp_2 = tmp; end
code[k_, n_] := Block[{t$95$0 = N[(N[(n * 2.0), $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[k, 3.05e-33], N[(N[Power[k, -0.5], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(1.0 / k), $MachinePrecision] * N[Power[t$95$0, N[(1.0 - k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(n \cdot 2\right) \cdot \pi\\
\mathbf{if}\;k \leq 3.05 \cdot 10^{-33}:\\
\;\;\;\;{k}^{-0.5} \cdot \sqrt{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{k} \cdot {t_0}^{\left(1 - k\right)}}\\
\end{array}
\end{array}
if k < 3.0500000000000001e-33Initial program 98.5%
expm1-log1p-u91.3%
expm1-udef91.3%
pow1/291.3%
pow-flip91.3%
metadata-eval91.3%
Applied egg-rr91.3%
expm1-def91.3%
expm1-log1p98.6%
Simplified98.6%
div-sub98.6%
metadata-eval98.6%
pow-sub98.6%
pow1/298.6%
associate-*l*98.6%
associate-*l*98.6%
div-inv98.6%
metadata-eval98.6%
Applied egg-rr98.6%
*-commutative98.6%
associate-*r*98.6%
*-commutative98.6%
*-commutative98.6%
associate-*r*98.6%
*-commutative98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in k around 0 98.6%
if 3.0500000000000001e-33 < k Initial program 99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r*99.7%
div-inv99.7%
expm1-log1p-u99.5%
expm1-udef95.9%
Applied egg-rr95.9%
expm1-def99.5%
expm1-log1p99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
div-inv99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.2%
(FPCore (k n) :precision binary64 (* (sqrt (/ 1.0 k)) (pow (* n (* 2.0 PI)) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return sqrt((1.0 / k)) * pow((n * (2.0 * ((double) M_PI))), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return Math.sqrt((1.0 / k)) * Math.pow((n * (2.0 * Math.PI)), ((1.0 - k) / 2.0));
}
def code(k, n): return math.sqrt((1.0 / k)) * math.pow((n * (2.0 * math.pi)), ((1.0 - k) / 2.0))
function code(k, n) return Float64(sqrt(Float64(1.0 / k)) * (Float64(n * Float64(2.0 * pi)) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = sqrt((1.0 / k)) * ((n * (2.0 * pi)) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[Sqrt[N[(1.0 / k), $MachinePrecision]], $MachinePrecision] * N[Power[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{k}} \cdot {\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Initial program 99.1%
add-sqr-sqrt99.0%
sqrt-unprod99.1%
frac-times99.1%
metadata-eval99.1%
add-sqr-sqrt99.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (k n) :precision binary64 (* (pow k -0.5) (pow (* n (* 2.0 PI)) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return pow(k, -0.5) * pow((n * (2.0 * ((double) M_PI))), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) * Math.pow((n * (2.0 * Math.PI)), ((1.0 - k) / 2.0));
}
def code(k, n): return math.pow(k, -0.5) * math.pow((n * (2.0 * math.pi)), ((1.0 - k) / 2.0))
function code(k, n) return Float64((k ^ -0.5) * (Float64(n * Float64(2.0 * pi)) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = (k ^ -0.5) * ((n * (2.0 * pi)) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{k}^{-0.5} \cdot {\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Initial program 99.1%
expm1-log1p-u95.5%
expm1-udef77.9%
pow1/277.9%
pow-flip77.9%
metadata-eval77.9%
Applied egg-rr77.9%
expm1-def95.5%
expm1-log1p99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (* n 2.0) PI)))
(if (<= k 9e-34)
(* (pow k -0.5) (sqrt t_0))
(sqrt (/ (pow t_0 (- 1.0 k)) k)))))
double code(double k, double n) {
double t_0 = (n * 2.0) * ((double) M_PI);
double tmp;
if (k <= 9e-34) {
tmp = pow(k, -0.5) * sqrt(t_0);
} else {
tmp = sqrt((pow(t_0, (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double t_0 = (n * 2.0) * Math.PI;
double tmp;
if (k <= 9e-34) {
tmp = Math.pow(k, -0.5) * Math.sqrt(t_0);
} else {
tmp = Math.sqrt((Math.pow(t_0, (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): t_0 = (n * 2.0) * math.pi tmp = 0 if k <= 9e-34: tmp = math.pow(k, -0.5) * math.sqrt(t_0) else: tmp = math.sqrt((math.pow(t_0, (1.0 - k)) / k)) return tmp
function code(k, n) t_0 = Float64(Float64(n * 2.0) * pi) tmp = 0.0 if (k <= 9e-34) tmp = Float64((k ^ -0.5) * sqrt(t_0)); else tmp = sqrt(Float64((t_0 ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) t_0 = (n * 2.0) * pi; tmp = 0.0; if (k <= 9e-34) tmp = (k ^ -0.5) * sqrt(t_0); else tmp = sqrt(((t_0 ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := Block[{t$95$0 = N[(N[(n * 2.0), $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[k, 9e-34], N[(N[Power[k, -0.5], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[t$95$0, N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(n \cdot 2\right) \cdot \pi\\
\mathbf{if}\;k \leq 9 \cdot 10^{-34}:\\
\;\;\;\;{k}^{-0.5} \cdot \sqrt{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{t_0}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 9.00000000000000085e-34Initial program 98.5%
expm1-log1p-u91.3%
expm1-udef91.3%
pow1/291.3%
pow-flip91.3%
metadata-eval91.3%
Applied egg-rr91.3%
expm1-def91.3%
expm1-log1p98.6%
Simplified98.6%
div-sub98.6%
metadata-eval98.6%
pow-sub98.6%
pow1/298.6%
associate-*l*98.6%
associate-*l*98.6%
div-inv98.6%
metadata-eval98.6%
Applied egg-rr98.6%
*-commutative98.6%
associate-*r*98.6%
*-commutative98.6%
*-commutative98.6%
associate-*r*98.6%
*-commutative98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in k around 0 98.6%
if 9.00000000000000085e-34 < k Initial program 99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r*99.7%
div-inv99.7%
expm1-log1p-u99.5%
expm1-udef95.9%
Applied egg-rr95.9%
expm1-def99.5%
expm1-log1p99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
Final simplification99.2%
(FPCore (k n) :precision binary64 (/ (pow (* (* n 2.0) PI) (/ (- 1.0 k) 2.0)) (sqrt k)))
double code(double k, double n) {
return pow(((n * 2.0) * ((double) M_PI)), ((1.0 - k) / 2.0)) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow(((n * 2.0) * Math.PI), ((1.0 - k) / 2.0)) / Math.sqrt(k);
}
def code(k, n): return math.pow(((n * 2.0) * math.pi), ((1.0 - k) / 2.0)) / math.sqrt(k)
function code(k, n) return Float64((Float64(Float64(n * 2.0) * pi) ^ Float64(Float64(1.0 - k) / 2.0)) / sqrt(k)) end
function tmp = code(k, n) tmp = (((n * 2.0) * pi) ^ ((1.0 - k) / 2.0)) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(N[(n * 2.0), $MachinePrecision] * Pi), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\left(n \cdot 2\right) \cdot \pi\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.1%
associate-*l/99.1%
*-lft-identity99.1%
*-commutative99.1%
associate-*l*99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (k n) :precision binary64 (sqrt (/ (pow (* (* n 2.0) PI) (- 1.0 k)) k)))
double code(double k, double n) {
return sqrt((pow(((n * 2.0) * ((double) M_PI)), (1.0 - k)) / k));
}
public static double code(double k, double n) {
return Math.sqrt((Math.pow(((n * 2.0) * Math.PI), (1.0 - k)) / k));
}
def code(k, n): return math.sqrt((math.pow(((n * 2.0) * math.pi), (1.0 - k)) / k))
function code(k, n) return sqrt(Float64((Float64(Float64(n * 2.0) * pi) ^ Float64(1.0 - k)) / k)) end
function tmp = code(k, n) tmp = sqrt(((((n * 2.0) * pi) ^ (1.0 - k)) / k)); end
code[k_, n_] := N[Sqrt[N[(N[Power[N[(N[(n * 2.0), $MachinePrecision] * Pi), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{{\left(\left(n \cdot 2\right) \cdot \pi\right)}^{\left(1 - k\right)}}{k}}
\end{array}
Initial program 99.1%
*-commutative99.1%
*-commutative99.1%
associate-*r*99.1%
div-inv99.1%
expm1-log1p-u96.2%
expm1-udef83.9%
Applied egg-rr73.0%
expm1-def85.4%
expm1-log1p87.2%
*-commutative87.2%
associate-*r*87.2%
*-commutative87.2%
Simplified87.2%
Final simplification87.2%
(FPCore (k n) :precision binary64 (* (sqrt (* 2.0 (/ n k))) (sqrt PI)))
double code(double k, double n) {
return sqrt((2.0 * (n / k))) * sqrt(((double) M_PI));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (n / k))) * Math.sqrt(Math.PI);
}
def code(k, n): return math.sqrt((2.0 * (n / k))) * math.sqrt(math.pi)
function code(k, n) return Float64(sqrt(Float64(2.0 * Float64(n / k))) * sqrt(pi)) end
function tmp = code(k, n) tmp = sqrt((2.0 * (n / k))) * sqrt(pi); end
code[k_, n_] := N[(N[Sqrt[N[(2.0 * N[(n / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \frac{n}{k}} \cdot \sqrt{\pi}
\end{array}
Initial program 99.1%
*-commutative99.1%
*-commutative99.1%
associate-*r*99.1%
div-inv99.1%
expm1-log1p-u96.2%
expm1-udef83.9%
Applied egg-rr73.0%
expm1-def85.4%
expm1-log1p87.2%
*-commutative87.2%
associate-*r*87.2%
*-commutative87.2%
Simplified87.2%
Taylor expanded in k around 0 40.7%
associate-/l*40.7%
associate-/r/40.7%
Simplified40.7%
associate-*r*40.7%
sqrt-prod40.9%
Applied egg-rr40.9%
Final simplification40.9%
(FPCore (k n) :precision binary64 (* (sqrt (* PI (/ n k))) (sqrt 2.0)))
double code(double k, double n) {
return sqrt((((double) M_PI) * (n / k))) * sqrt(2.0);
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI * (n / k))) * Math.sqrt(2.0);
}
def code(k, n): return math.sqrt((math.pi * (n / k))) * math.sqrt(2.0)
function code(k, n) return Float64(sqrt(Float64(pi * Float64(n / k))) * sqrt(2.0)) end
function tmp = code(k, n) tmp = sqrt((pi * (n / k))) * sqrt(2.0); end
code[k_, n_] := N[(N[Sqrt[N[(Pi * N[(n / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\pi \cdot \frac{n}{k}} \cdot \sqrt{2}
\end{array}
Initial program 99.1%
*-commutative99.1%
*-commutative99.1%
associate-*r*99.1%
div-inv99.1%
expm1-log1p-u96.2%
expm1-udef83.9%
Applied egg-rr73.0%
expm1-def85.4%
expm1-log1p87.2%
*-commutative87.2%
associate-*r*87.2%
*-commutative87.2%
Simplified87.2%
Taylor expanded in k around 0 40.7%
associate-/l*40.7%
associate-/r/40.7%
Simplified40.7%
*-commutative40.7%
sqrt-prod41.0%
*-commutative41.0%
Applied egg-rr41.0%
Final simplification41.0%
(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.1%
*-commutative99.1%
*-commutative99.1%
associate-*r*99.1%
div-inv99.1%
expm1-log1p-u96.2%
expm1-udef83.9%
Applied egg-rr73.0%
expm1-def85.4%
expm1-log1p87.2%
*-commutative87.2%
associate-*r*87.2%
*-commutative87.2%
Simplified87.2%
Taylor expanded in k around 0 40.7%
associate-/l*40.7%
associate-/r/40.7%
Simplified40.7%
Final simplification40.7%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (/ PI (/ k n)))))
double code(double k, double n) {
return sqrt((2.0 * (((double) M_PI) / (k / n))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (Math.PI / (k / n))));
}
def code(k, n): return math.sqrt((2.0 * (math.pi / (k / n))))
function code(k, n) return sqrt(Float64(2.0 * Float64(pi / Float64(k / n)))) end
function tmp = code(k, n) tmp = sqrt((2.0 * (pi / (k / n)))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(Pi / N[(k / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \frac{\pi}{\frac{k}{n}}}
\end{array}
Initial program 99.1%
*-commutative99.1%
*-commutative99.1%
associate-*r*99.1%
div-inv99.1%
expm1-log1p-u96.2%
expm1-udef83.9%
Applied egg-rr73.0%
expm1-def85.4%
expm1-log1p87.2%
*-commutative87.2%
associate-*r*87.2%
*-commutative87.2%
Simplified87.2%
Taylor expanded in k around 0 40.7%
associate-/l*40.7%
associate-/r/40.7%
Simplified40.7%
*-commutative40.7%
clear-num40.7%
un-div-inv40.8%
Applied egg-rr40.8%
Final simplification40.8%
herbie shell --seed 2023216
(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))))