
(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 (if (<= k 3e-44) (* (sqrt (* 2.0 n)) (sqrt (/ PI k))) (sqrt (/ (pow (* 2.0 (* PI n)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 3e-44) {
tmp = sqrt((2.0 * n)) * sqrt((((double) M_PI) / k));
} 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 <= 3e-44) {
tmp = Math.sqrt((2.0 * n)) * Math.sqrt((Math.PI / k));
} 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 <= 3e-44: tmp = math.sqrt((2.0 * n)) * math.sqrt((math.pi / k)) 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 <= 3e-44) tmp = Float64(sqrt(Float64(2.0 * n)) * sqrt(Float64(pi / k))); 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 <= 3e-44) tmp = sqrt((2.0 * n)) * sqrt((pi / k)); else tmp = sqrt((((2.0 * (pi * n)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3e-44], N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $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 3 \cdot 10^{-44}:\\
\;\;\;\;\sqrt{2 \cdot n} \cdot \sqrt{\frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 3.0000000000000002e-44Initial program 98.5%
Taylor expanded in k around 0 77.1%
*-commutative77.1%
associate-/l*77.1%
Simplified77.1%
sqrt-unprod76.4%
Applied egg-rr76.4%
associate-*r*76.4%
sqrt-prod99.5%
Applied egg-rr99.5%
*-commutative99.5%
Simplified99.5%
if 3.0000000000000002e-44 < k Initial program 99.6%
Applied egg-rr99.7%
*-commutative99.7%
distribute-lft-in99.7%
metadata-eval99.7%
*-commutative99.7%
associate-*r*99.7%
metadata-eval99.7%
neg-mul-199.7%
sub-neg99.7%
Simplified99.7%
Final simplification99.6%
(FPCore (k n) :precision binary64 (let* ((t_0 (* 2.0 (* PI n)))) (/ (* (pow k -0.5) (sqrt t_0)) (pow t_0 (* k 0.5)))))
double code(double k, double n) {
double t_0 = 2.0 * (((double) M_PI) * n);
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 = 2.0 * (Math.PI * n);
return (Math.pow(k, -0.5) * Math.sqrt(t_0)) / Math.pow(t_0, (k * 0.5));
}
def code(k, n): t_0 = 2.0 * (math.pi * n) return (math.pow(k, -0.5) * math.sqrt(t_0)) / math.pow(t_0, (k * 0.5))
function code(k, n) t_0 = Float64(2.0 * Float64(pi * n)) return Float64(Float64((k ^ -0.5) * sqrt(t_0)) / (t_0 ^ Float64(k * 0.5))) end
function tmp = code(k, n) t_0 = 2.0 * (pi * n); tmp = ((k ^ -0.5) * sqrt(t_0)) / (t_0 ^ (k * 0.5)); end
code[k_, n_] := Block[{t$95$0 = N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Power[k, -0.5], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision] / N[Power[t$95$0, N[(k * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \left(\pi \cdot n\right)\\
\frac{{k}^{-0.5} \cdot \sqrt{t\_0}}{{t\_0}^{\left(k \cdot 0.5\right)}}
\end{array}
\end{array}
Initial program 99.1%
associate-*r*99.1%
div-sub99.1%
metadata-eval99.1%
pow-div99.3%
pow1/299.3%
associate-*r/99.3%
pow1/299.3%
pow-flip99.3%
metadata-eval99.3%
div-inv99.3%
metadata-eval99.3%
Applied egg-rr99.3%
(FPCore (k n) :precision binary64 (let* ((t_0 (* PI (* 2.0 n)))) (/ (sqrt t_0) (* (sqrt k) (pow t_0 (* k 0.5))))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (2.0 * n);
return sqrt(t_0) / (sqrt(k) * pow(t_0, (k * 0.5)));
}
public static double code(double k, double n) {
double t_0 = Math.PI * (2.0 * n);
return Math.sqrt(t_0) / (Math.sqrt(k) * Math.pow(t_0, (k * 0.5)));
}
def code(k, n): t_0 = math.pi * (2.0 * n) return math.sqrt(t_0) / (math.sqrt(k) * math.pow(t_0, (k * 0.5)))
function code(k, n) t_0 = Float64(pi * Float64(2.0 * n)) return Float64(sqrt(t_0) / Float64(sqrt(k) * (t_0 ^ Float64(k * 0.5)))) end
function tmp = code(k, n) t_0 = pi * (2.0 * n); tmp = sqrt(t_0) / (sqrt(k) * (t_0 ^ (k * 0.5))); end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]}, N[(N[Sqrt[t$95$0], $MachinePrecision] / N[(N[Sqrt[k], $MachinePrecision] * N[Power[t$95$0, N[(k * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(2 \cdot n\right)\\
\frac{\sqrt{t\_0}}{\sqrt{k} \cdot {t\_0}^{\left(k \cdot 0.5\right)}}
\end{array}
\end{array}
Initial program 99.1%
associate-*l/99.2%
*-un-lft-identity99.2%
associate-*r*99.2%
div-sub99.2%
metadata-eval99.2%
pow-div99.3%
pow1/299.3%
associate-/l/99.3%
div-inv99.3%
metadata-eval99.3%
Applied egg-rr99.3%
associate-/l/99.3%
unpow1/299.3%
metadata-eval99.3%
pow-sqr99.1%
fabs-sqr99.1%
pow-sqr99.3%
metadata-eval99.3%
unpow1/299.3%
fabs-neg99.3%
neg-mul-199.3%
rem-square-sqrt0.0%
unpow1/20.0%
metadata-eval0.0%
pow-sqr0.0%
unswap-sqr0.0%
fabs-sqr0.0%
unswap-sqr0.0%
rem-square-sqrt27.9%
pow-sqr27.9%
metadata-eval27.9%
unpow1/227.9%
neg-mul-127.9%
Simplified99.3%
(FPCore (k n) :precision binary64 (/ (pow k -0.5) (pow (* PI (* 2.0 n)) (- (* k 0.5) 0.5))))
double code(double k, double n) {
return pow(k, -0.5) / pow((((double) M_PI) * (2.0 * n)), ((k * 0.5) - 0.5));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) / Math.pow((Math.PI * (2.0 * n)), ((k * 0.5) - 0.5));
}
def code(k, n): return math.pow(k, -0.5) / math.pow((math.pi * (2.0 * n)), ((k * 0.5) - 0.5))
function code(k, n) return Float64((k ^ -0.5) / (Float64(pi * Float64(2.0 * n)) ^ Float64(Float64(k * 0.5) - 0.5))) end
function tmp = code(k, n) tmp = (k ^ -0.5) / ((pi * (2.0 * n)) ^ ((k * 0.5) - 0.5)); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] / N[Power[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision], N[(N[(k * 0.5), $MachinePrecision] - 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{k}^{-0.5}}{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(k \cdot 0.5 - 0.5\right)}}
\end{array}
Initial program 99.1%
Taylor expanded in k around 0 99.2%
associate-*r*99.2%
div-sub99.2%
metadata-eval99.2%
pow-sub99.3%
*-commutative99.3%
pow1/299.3%
*-commutative99.3%
div-inv99.3%
metadata-eval99.3%
clear-num99.2%
un-div-inv99.3%
inv-pow99.3%
sqrt-pow199.3%
metadata-eval99.3%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (k n) :precision binary64 (if (<= k 3.1) (* (sqrt (* 2.0 n)) (sqrt (/ PI k))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 3.1) {
tmp = sqrt((2.0 * n)) * sqrt((((double) M_PI) / k));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 3.1) {
tmp = Math.sqrt((2.0 * n)) * Math.sqrt((Math.PI / k));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 3.1: tmp = math.sqrt((2.0 * n)) * math.sqrt((math.pi / k)) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 3.1) tmp = Float64(sqrt(Float64(2.0 * n)) * sqrt(Float64(pi / k))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 3.1) tmp = sqrt((2.0 * n)) * sqrt((pi / k)); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.1], N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.1:\\
\;\;\;\;\sqrt{2 \cdot n} \cdot \sqrt{\frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 3.10000000000000009Initial program 98.3%
Taylor expanded in k around 0 76.2%
*-commutative76.2%
associate-/l*76.2%
Simplified76.2%
sqrt-unprod75.6%
Applied egg-rr75.6%
associate-*r*75.6%
sqrt-prod95.4%
Applied egg-rr95.4%
*-commutative95.4%
Simplified95.4%
if 3.10000000000000009 < k Initial program 100.0%
Taylor expanded in k around 0 2.6%
*-commutative2.6%
associate-/l*2.6%
Simplified2.6%
sqrt-unprod2.6%
Applied egg-rr2.6%
expm1-log1p-u2.6%
expm1-undefine24.1%
Applied egg-rr24.1%
sub-neg24.1%
metadata-eval24.1%
+-commutative24.1%
log1p-undefine24.1%
rem-exp-log24.1%
+-commutative24.1%
associate-*r*24.1%
associate-*r/24.1%
*-commutative24.1%
associate-/l*24.1%
fma-define24.1%
associate-/l*24.1%
Simplified24.1%
Taylor expanded in n around 0 55.0%
Final simplification75.0%
(FPCore (k n) :precision binary64 (if (<= k 2.6) (* (sqrt 2.0) (sqrt (* n (/ PI k)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2.6) {
tmp = sqrt(2.0) * sqrt((n * (((double) M_PI) / k)));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.6) {
tmp = Math.sqrt(2.0) * Math.sqrt((n * (Math.PI / k)));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.6: tmp = math.sqrt(2.0) * math.sqrt((n * (math.pi / k))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.6) tmp = Float64(sqrt(2.0) * sqrt(Float64(n * Float64(pi / k)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.6) tmp = sqrt(2.0) * sqrt((n * (pi / k))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.6], N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[N[(n * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.6:\\
\;\;\;\;\sqrt{2} \cdot \sqrt{n \cdot \frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.60000000000000009Initial program 98.3%
Taylor expanded in k around 0 76.2%
*-commutative76.2%
associate-/l*76.2%
Simplified76.2%
if 2.60000000000000009 < k Initial program 100.0%
Taylor expanded in k around 0 2.6%
*-commutative2.6%
associate-/l*2.6%
Simplified2.6%
sqrt-unprod2.6%
Applied egg-rr2.6%
expm1-log1p-u2.6%
expm1-undefine24.1%
Applied egg-rr24.1%
sub-neg24.1%
metadata-eval24.1%
+-commutative24.1%
log1p-undefine24.1%
rem-exp-log24.1%
+-commutative24.1%
associate-*r*24.1%
associate-*r/24.1%
*-commutative24.1%
associate-/l*24.1%
fma-define24.1%
associate-/l*24.1%
Simplified24.1%
Taylor expanded in n around 0 55.0%
Final simplification65.5%
(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.1%
associate-*l/99.2%
*-lft-identity99.2%
associate-*l*99.2%
div-sub99.2%
metadata-eval99.2%
Simplified99.2%
(FPCore (k n) :precision binary64 (if (<= k 4.0) (sqrt (* (* PI (* 2.0 n)) (/ 1.0 k))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 4.0) {
tmp = sqrt(((((double) M_PI) * (2.0 * n)) * (1.0 / k)));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 4.0) {
tmp = Math.sqrt(((Math.PI * (2.0 * n)) * (1.0 / k)));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 4.0: tmp = math.sqrt(((math.pi * (2.0 * n)) * (1.0 / k))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 4.0) tmp = sqrt(Float64(Float64(pi * Float64(2.0 * n)) * Float64(1.0 / k))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 4.0) tmp = sqrt(((pi * (2.0 * n)) * (1.0 / k))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 4.0], N[Sqrt[N[(N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision] * N[(1.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 4:\\
\;\;\;\;\sqrt{\left(\pi \cdot \left(2 \cdot n\right)\right) \cdot \frac{1}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 4Initial program 98.3%
associate-*r*98.3%
div-sub98.3%
metadata-eval98.3%
pow-div98.5%
pow1/298.5%
associate-*r/98.5%
pow1/298.5%
pow-flip98.6%
metadata-eval98.6%
div-inv98.6%
metadata-eval98.6%
Applied egg-rr98.6%
Taylor expanded in k around 0 94.6%
add-sqr-sqrt94.3%
sqrt-unprod75.4%
*-commutative75.4%
*-commutative75.4%
metadata-eval75.4%
sqrt-pow175.4%
inv-pow75.4%
*-commutative75.4%
*-commutative75.4%
metadata-eval75.4%
sqrt-pow175.4%
inv-pow75.4%
Applied egg-rr75.7%
if 4 < k Initial program 100.0%
Taylor expanded in k around 0 2.6%
*-commutative2.6%
associate-/l*2.6%
Simplified2.6%
sqrt-unprod2.6%
Applied egg-rr2.6%
expm1-log1p-u2.6%
expm1-undefine24.1%
Applied egg-rr24.1%
sub-neg24.1%
metadata-eval24.1%
+-commutative24.1%
log1p-undefine24.1%
rem-exp-log24.1%
+-commutative24.1%
associate-*r*24.1%
associate-*r/24.1%
*-commutative24.1%
associate-/l*24.1%
fma-define24.1%
associate-/l*24.1%
Simplified24.1%
Taylor expanded in n around 0 55.0%
Final simplification65.2%
(FPCore (k n) :precision binary64 (if (<= k 3.0) (sqrt (/ (* 2.0 n) (/ k PI))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 3.0) {
tmp = sqrt(((2.0 * n) / (k / ((double) M_PI))));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 3.0) {
tmp = Math.sqrt(((2.0 * n) / (k / Math.PI)));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 3.0: tmp = math.sqrt(((2.0 * n) / (k / math.pi))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 3.0) tmp = sqrt(Float64(Float64(2.0 * n) / Float64(k / pi))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 3.0) tmp = sqrt(((2.0 * n) / (k / pi))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.0], N[Sqrt[N[(N[(2.0 * n), $MachinePrecision] / N[(k / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3:\\
\;\;\;\;\sqrt{\frac{2 \cdot n}{\frac{k}{\pi}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 3Initial program 98.3%
Taylor expanded in k around 0 76.2%
*-commutative76.2%
associate-/l*76.2%
Simplified76.2%
sqrt-unprod75.6%
Applied egg-rr75.6%
associate-*r*75.6%
clear-num75.6%
un-div-inv75.7%
Applied egg-rr75.7%
if 3 < k Initial program 100.0%
Taylor expanded in k around 0 2.6%
*-commutative2.6%
associate-/l*2.6%
Simplified2.6%
sqrt-unprod2.6%
Applied egg-rr2.6%
expm1-log1p-u2.6%
expm1-undefine24.1%
Applied egg-rr24.1%
sub-neg24.1%
metadata-eval24.1%
+-commutative24.1%
log1p-undefine24.1%
rem-exp-log24.1%
+-commutative24.1%
associate-*r*24.1%
associate-*r/24.1%
*-commutative24.1%
associate-/l*24.1%
fma-define24.1%
associate-/l*24.1%
Simplified24.1%
Taylor expanded in n around 0 55.0%
Final simplification65.2%
(FPCore (k n) :precision binary64 (if (<= k 3.5) (sqrt (* 2.0 (/ PI (/ k n)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 3.5) {
tmp = sqrt((2.0 * (((double) M_PI) / (k / n))));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 3.5) {
tmp = Math.sqrt((2.0 * (Math.PI / (k / n))));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 3.5: tmp = math.sqrt((2.0 * (math.pi / (k / n)))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 3.5) tmp = sqrt(Float64(2.0 * Float64(pi / Float64(k / n)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 3.5) tmp = sqrt((2.0 * (pi / (k / n)))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.5], N[Sqrt[N[(2.0 * N[(Pi / N[(k / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.5:\\
\;\;\;\;\sqrt{2 \cdot \frac{\pi}{\frac{k}{n}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 3.5Initial program 98.3%
Taylor expanded in k around 0 76.2%
*-commutative76.2%
associate-/l*76.2%
Simplified76.2%
sqrt-unprod75.6%
Applied egg-rr75.6%
div-inv75.6%
Applied egg-rr75.6%
associate-*r*75.7%
*-commutative75.7%
div-inv75.6%
associate-/l*75.6%
clear-num75.5%
un-div-inv75.7%
Applied egg-rr75.7%
if 3.5 < k Initial program 100.0%
Taylor expanded in k around 0 2.6%
*-commutative2.6%
associate-/l*2.6%
Simplified2.6%
sqrt-unprod2.6%
Applied egg-rr2.6%
expm1-log1p-u2.6%
expm1-undefine24.1%
Applied egg-rr24.1%
sub-neg24.1%
metadata-eval24.1%
+-commutative24.1%
log1p-undefine24.1%
rem-exp-log24.1%
+-commutative24.1%
associate-*r*24.1%
associate-*r/24.1%
*-commutative24.1%
associate-/l*24.1%
fma-define24.1%
associate-/l*24.1%
Simplified24.1%
Taylor expanded in n around 0 55.0%
Final simplification65.2%
(FPCore (k n) :precision binary64 (if (<= k 3.0) (sqrt (* 2.0 (* n (/ PI k)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 3.0) {
tmp = sqrt((2.0 * (n * (((double) M_PI) / k))));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 3.0) {
tmp = Math.sqrt((2.0 * (n * (Math.PI / k))));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 3.0: tmp = math.sqrt((2.0 * (n * (math.pi / k)))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 3.0) tmp = sqrt(Float64(2.0 * Float64(n * Float64(pi / k)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 3.0) tmp = sqrt((2.0 * (n * (pi / k)))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.0], N[Sqrt[N[(2.0 * N[(n * N[(Pi / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3:\\
\;\;\;\;\sqrt{2 \cdot \left(n \cdot \frac{\pi}{k}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 3Initial program 98.3%
Taylor expanded in k around 0 76.2%
*-commutative76.2%
associate-/l*76.2%
Simplified76.2%
sqrt-unprod75.6%
Applied egg-rr75.6%
if 3 < k Initial program 100.0%
Taylor expanded in k around 0 2.6%
*-commutative2.6%
associate-/l*2.6%
Simplified2.6%
sqrt-unprod2.6%
Applied egg-rr2.6%
expm1-log1p-u2.6%
expm1-undefine24.1%
Applied egg-rr24.1%
sub-neg24.1%
metadata-eval24.1%
+-commutative24.1%
log1p-undefine24.1%
rem-exp-log24.1%
+-commutative24.1%
associate-*r*24.1%
associate-*r/24.1%
*-commutative24.1%
associate-/l*24.1%
fma-define24.1%
associate-/l*24.1%
Simplified24.1%
Taylor expanded in n around 0 55.0%
Final simplification65.2%
(FPCore (k n) :precision binary64 (sqrt 0.0))
double code(double k, double n) {
return sqrt(0.0);
}
real(8) function code(k, n)
real(8), intent (in) :: k
real(8), intent (in) :: n
code = sqrt(0.0d0)
end function
public static double code(double k, double n) {
return Math.sqrt(0.0);
}
def code(k, n): return math.sqrt(0.0)
function code(k, n) return sqrt(0.0) end
function tmp = code(k, n) tmp = sqrt(0.0); end
code[k_, n_] := N[Sqrt[0.0], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0}
\end{array}
Initial program 99.1%
Taylor expanded in k around 0 39.1%
*-commutative39.1%
associate-/l*39.1%
Simplified39.1%
sqrt-unprod38.8%
Applied egg-rr38.8%
expm1-log1p-u37.2%
expm1-undefine36.5%
Applied egg-rr36.5%
sub-neg36.5%
metadata-eval36.5%
+-commutative36.5%
log1p-undefine36.5%
rem-exp-log38.1%
+-commutative38.1%
associate-*r*38.1%
associate-*r/38.1%
*-commutative38.1%
associate-/l*38.1%
fma-define38.1%
associate-/l*38.1%
Simplified38.1%
Taylor expanded in n around 0 29.1%
Final simplification29.1%
herbie shell --seed 2024139
(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))))