
(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 13 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 (* 2.0 (* PI n)))) (/ (sqrt t_0) (* (sqrt k) (pow t_0 (* k 0.5))))))
double code(double k, double n) {
double t_0 = 2.0 * (((double) M_PI) * n);
return sqrt(t_0) / (sqrt(k) * pow(t_0, (k * 0.5)));
}
public static double code(double k, double n) {
double t_0 = 2.0 * (Math.PI * n);
return Math.sqrt(t_0) / (Math.sqrt(k) * Math.pow(t_0, (k * 0.5)));
}
def code(k, n): t_0 = 2.0 * (math.pi * n) return math.sqrt(t_0) / (math.sqrt(k) * math.pow(t_0, (k * 0.5)))
function code(k, n) t_0 = Float64(2.0 * Float64(pi * n)) return Float64(sqrt(t_0) / Float64(sqrt(k) * (t_0 ^ Float64(k * 0.5)))) end
function tmp = code(k, n) t_0 = 2.0 * (pi * n); tmp = sqrt(t_0) / (sqrt(k) * (t_0 ^ (k * 0.5))); end
code[k_, n_] := Block[{t$95$0 = N[(2.0 * N[(Pi * 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 := 2 \cdot \left(\pi \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.5%
associate-*l/99.6%
*-un-lft-identity99.6%
associate-*r*99.6%
div-sub99.6%
metadata-eval99.6%
pow-div99.7%
pow1/299.7%
associate-/l/99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
(FPCore (k n) :precision binary64 (if (<= k 4.9e-104) (* (sqrt (* PI n)) (sqrt (/ 2.0 k))) (sqrt (/ (pow (* 2.0 (* PI n)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 4.9e-104) {
tmp = sqrt((((double) M_PI) * n)) * sqrt((2.0 / 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 <= 4.9e-104) {
tmp = Math.sqrt((Math.PI * n)) * Math.sqrt((2.0 / 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 <= 4.9e-104: tmp = math.sqrt((math.pi * n)) * math.sqrt((2.0 / 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 <= 4.9e-104) tmp = Float64(sqrt(Float64(pi * n)) * sqrt(Float64(2.0 / 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 <= 4.9e-104) tmp = sqrt((pi * n)) * sqrt((2.0 / k)); else tmp = sqrt((((2.0 * (pi * n)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 4.9e-104], N[(N[Sqrt[N[(Pi * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 / 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 4.9 \cdot 10^{-104}:\\
\;\;\;\;\sqrt{\pi \cdot n} \cdot \sqrt{\frac{2}{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 < 4.9000000000000003e-104Initial program 99.2%
Applied egg-rr67.6%
distribute-lft-in67.6%
metadata-eval67.6%
*-commutative67.6%
associate-*r*67.6%
metadata-eval67.6%
neg-mul-167.6%
sub-neg67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in k around 0 67.6%
associate-*r/67.6%
associate-*r*67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in n around 0 67.6%
associate-*r/67.6%
associate-*r*67.6%
*-commutative67.6%
associate-*r*67.6%
associate-/l*66.5%
*-commutative66.5%
associate-/l*66.4%
Simplified66.4%
associate-*r*67.5%
sqrt-prod99.5%
*-commutative99.5%
Applied egg-rr99.5%
if 4.9000000000000003e-104 < k Initial program 99.7%
Applied egg-rr99.8%
distribute-lft-in99.8%
metadata-eval99.8%
*-commutative99.8%
associate-*r*99.8%
metadata-eval99.8%
neg-mul-199.8%
sub-neg99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (k n) :precision binary64 (if (<= k 2150000.0) (* (sqrt (* PI n)) (sqrt (/ 2.0 k))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = sqrt((((double) M_PI) * n)) * sqrt((2.0 / k));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = Math.sqrt((Math.PI * n)) * Math.sqrt((2.0 / k));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2150000.0: tmp = math.sqrt((math.pi * n)) * math.sqrt((2.0 / k)) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2150000.0) tmp = Float64(sqrt(Float64(pi * n)) * sqrt(Float64(2.0 / k))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2150000.0) tmp = sqrt((pi * n)) * sqrt((2.0 / k)); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2150000.0], N[(N[Sqrt[N[(Pi * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2150000:\\
\;\;\;\;\sqrt{\pi \cdot n} \cdot \sqrt{\frac{2}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.15e6Initial program 99.0%
Applied egg-rr77.3%
distribute-lft-in77.3%
metadata-eval77.3%
*-commutative77.3%
associate-*r*77.3%
metadata-eval77.3%
neg-mul-177.3%
sub-neg77.3%
*-commutative77.3%
Simplified77.3%
Taylor expanded in k around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
Simplified75.2%
Taylor expanded in n around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
associate-*r*75.2%
associate-/l*74.4%
*-commutative74.4%
associate-/l*74.4%
Simplified74.4%
associate-*r*75.1%
sqrt-prod97.2%
*-commutative97.2%
Applied egg-rr97.2%
if 2.15e6 < k Initial program 100.0%
Applied egg-rr100.0%
distribute-lft-in100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 2.6%
associate-*r/2.6%
associate-*r*2.6%
*-commutative2.6%
Simplified2.6%
expm1-log1p-u2.6%
expm1-undefine23.3%
*-commutative23.3%
associate-*l/23.3%
*-commutative23.3%
associate-*l*23.3%
Applied egg-rr23.3%
sub-neg23.3%
metadata-eval23.3%
+-commutative23.3%
log1p-undefine23.3%
rem-exp-log23.3%
+-commutative23.3%
associate-/l*23.3%
fma-define23.3%
*-commutative23.3%
associate-/l*23.3%
Simplified23.3%
Taylor expanded in n around 0 50.4%
Final simplification73.6%
(FPCore (k n) :precision binary64 (if (<= k 2150000.0) (* (sqrt n) (sqrt (/ 2.0 (/ k PI)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = sqrt(n) * sqrt((2.0 / (k / ((double) M_PI))));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = Math.sqrt(n) * Math.sqrt((2.0 / (k / Math.PI)));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2150000.0: tmp = math.sqrt(n) * math.sqrt((2.0 / (k / math.pi))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2150000.0) tmp = Float64(sqrt(n) * sqrt(Float64(2.0 / Float64(k / pi)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2150000.0) tmp = sqrt(n) * sqrt((2.0 / (k / pi))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2150000.0], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(2.0 / N[(k / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2150000:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{\frac{2}{\frac{k}{\pi}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.15e6Initial program 99.0%
Applied egg-rr77.3%
distribute-lft-in77.3%
metadata-eval77.3%
*-commutative77.3%
associate-*r*77.3%
metadata-eval77.3%
neg-mul-177.3%
sub-neg77.3%
*-commutative77.3%
Simplified77.3%
Taylor expanded in k around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
Simplified75.2%
associate-*l*74.4%
sqrt-prod96.3%
clear-num96.3%
un-div-inv96.3%
Applied egg-rr96.3%
if 2.15e6 < k Initial program 100.0%
Applied egg-rr100.0%
distribute-lft-in100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 2.6%
associate-*r/2.6%
associate-*r*2.6%
*-commutative2.6%
Simplified2.6%
expm1-log1p-u2.6%
expm1-undefine23.3%
*-commutative23.3%
associate-*l/23.3%
*-commutative23.3%
associate-*l*23.3%
Applied egg-rr23.3%
sub-neg23.3%
metadata-eval23.3%
+-commutative23.3%
log1p-undefine23.3%
rem-exp-log23.3%
+-commutative23.3%
associate-/l*23.3%
fma-define23.3%
*-commutative23.3%
associate-/l*23.3%
Simplified23.3%
Taylor expanded in n around 0 50.4%
Final simplification73.2%
(FPCore (k n) :precision binary64 (if (<= k 2150000.0) (* (sqrt n) (sqrt (* PI (/ 2.0 k)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = sqrt(n) * sqrt((((double) M_PI) * (2.0 / k)));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = Math.sqrt(n) * Math.sqrt((Math.PI * (2.0 / k)));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2150000.0: tmp = math.sqrt(n) * math.sqrt((math.pi * (2.0 / k))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2150000.0) tmp = Float64(sqrt(n) * sqrt(Float64(pi * Float64(2.0 / k)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2150000.0) tmp = sqrt(n) * sqrt((pi * (2.0 / k))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2150000.0], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2150000:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{\pi \cdot \frac{2}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.15e6Initial program 99.0%
Applied egg-rr77.3%
distribute-lft-in77.3%
metadata-eval77.3%
*-commutative77.3%
associate-*r*77.3%
metadata-eval77.3%
neg-mul-177.3%
sub-neg77.3%
*-commutative77.3%
Simplified77.3%
Taylor expanded in k around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
Simplified75.2%
pow1/275.2%
associate-*l*74.4%
unpow-prod-down96.3%
pow1/296.3%
clear-num96.3%
un-div-inv96.3%
Applied egg-rr96.3%
unpow1/296.3%
associate-/r/96.3%
Simplified96.3%
if 2.15e6 < k Initial program 100.0%
Applied egg-rr100.0%
distribute-lft-in100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 2.6%
associate-*r/2.6%
associate-*r*2.6%
*-commutative2.6%
Simplified2.6%
expm1-log1p-u2.6%
expm1-undefine23.3%
*-commutative23.3%
associate-*l/23.3%
*-commutative23.3%
associate-*l*23.3%
Applied egg-rr23.3%
sub-neg23.3%
metadata-eval23.3%
+-commutative23.3%
log1p-undefine23.3%
rem-exp-log23.3%
+-commutative23.3%
associate-/l*23.3%
fma-define23.3%
*-commutative23.3%
associate-/l*23.3%
Simplified23.3%
Taylor expanded in n around 0 50.4%
Final simplification73.2%
(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.5%
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 2150000.0) (pow (* (/ k n) (/ 0.5 PI)) -0.5) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = pow(((k / n) * (0.5 / ((double) M_PI))), -0.5);
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = Math.pow(((k / n) * (0.5 / Math.PI)), -0.5);
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2150000.0: tmp = math.pow(((k / n) * (0.5 / math.pi)), -0.5) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2150000.0) tmp = Float64(Float64(k / n) * Float64(0.5 / pi)) ^ -0.5; else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2150000.0) tmp = ((k / n) * (0.5 / pi)) ^ -0.5; else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2150000.0], N[Power[N[(N[(k / n), $MachinePrecision] * N[(0.5 / Pi), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2150000:\\
\;\;\;\;{\left(\frac{k}{n} \cdot \frac{0.5}{\pi}\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.15e6Initial program 99.0%
Applied egg-rr77.3%
distribute-lft-in77.3%
metadata-eval77.3%
*-commutative77.3%
associate-*r*77.3%
metadata-eval77.3%
neg-mul-177.3%
sub-neg77.3%
*-commutative77.3%
Simplified77.3%
Taylor expanded in k around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
Simplified75.2%
Taylor expanded in n around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
associate-*r*75.2%
associate-/l*74.4%
*-commutative74.4%
associate-/l*74.4%
Simplified74.4%
associate-*r*75.1%
clear-num75.1%
div-inv75.2%
clear-num75.1%
metadata-eval75.1%
add-sqr-sqrt74.9%
frac-times75.1%
sqrt-unprod75.2%
add-sqr-sqrt75.6%
inv-pow75.6%
sqrt-pow275.7%
div-inv75.7%
metadata-eval75.7%
times-frac75.7%
metadata-eval75.7%
Applied egg-rr75.7%
if 2.15e6 < k Initial program 100.0%
Applied egg-rr100.0%
distribute-lft-in100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 2.6%
associate-*r/2.6%
associate-*r*2.6%
*-commutative2.6%
Simplified2.6%
expm1-log1p-u2.6%
expm1-undefine23.3%
*-commutative23.3%
associate-*l/23.3%
*-commutative23.3%
associate-*l*23.3%
Applied egg-rr23.3%
sub-neg23.3%
metadata-eval23.3%
+-commutative23.3%
log1p-undefine23.3%
rem-exp-log23.3%
+-commutative23.3%
associate-/l*23.3%
fma-define23.3%
*-commutative23.3%
associate-/l*23.3%
Simplified23.3%
Taylor expanded in n around 0 50.4%
Final simplification62.9%
(FPCore (k n) :precision binary64 (if (<= k 2150000.0) (sqrt (/ (* 2.0 n) (/ k PI))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2150000.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 <= 2150000.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 <= 2150000.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 <= 2150000.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 <= 2150000.0) tmp = sqrt(((2.0 * n) / (k / pi))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2150000.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 2150000:\\
\;\;\;\;\sqrt{\frac{2 \cdot n}{\frac{k}{\pi}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.15e6Initial program 99.0%
Applied egg-rr77.3%
distribute-lft-in77.3%
metadata-eval77.3%
*-commutative77.3%
associate-*r*77.3%
metadata-eval77.3%
neg-mul-177.3%
sub-neg77.3%
*-commutative77.3%
Simplified77.3%
Taylor expanded in k around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
Simplified75.2%
clear-num75.2%
un-div-inv75.2%
Applied egg-rr75.2%
if 2.15e6 < k Initial program 100.0%
Applied egg-rr100.0%
distribute-lft-in100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 2.6%
associate-*r/2.6%
associate-*r*2.6%
*-commutative2.6%
Simplified2.6%
expm1-log1p-u2.6%
expm1-undefine23.3%
*-commutative23.3%
associate-*l/23.3%
*-commutative23.3%
associate-*l*23.3%
Applied egg-rr23.3%
sub-neg23.3%
metadata-eval23.3%
+-commutative23.3%
log1p-undefine23.3%
rem-exp-log23.3%
+-commutative23.3%
associate-/l*23.3%
fma-define23.3%
*-commutative23.3%
associate-/l*23.3%
Simplified23.3%
Taylor expanded in n around 0 50.4%
Final simplification62.7%
(FPCore (k n) :precision binary64 (if (<= k 2150000.0) (sqrt (* (* 2.0 n) (/ PI k))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2150000.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 <= 2150000.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 <= 2150000.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 <= 2150000.0) tmp = sqrt(Float64(Float64(2.0 * n) * Float64(pi / k))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2150000.0) tmp = sqrt(((2.0 * n) * (pi / k))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2150000.0], N[Sqrt[N[(N[(2.0 * n), $MachinePrecision] * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2150000:\\
\;\;\;\;\sqrt{\left(2 \cdot n\right) \cdot \frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.15e6Initial program 99.0%
Applied egg-rr77.3%
distribute-lft-in77.3%
metadata-eval77.3%
*-commutative77.3%
associate-*r*77.3%
metadata-eval77.3%
neg-mul-177.3%
sub-neg77.3%
*-commutative77.3%
Simplified77.3%
Taylor expanded in k around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
Simplified75.2%
if 2.15e6 < k Initial program 100.0%
Applied egg-rr100.0%
distribute-lft-in100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 2.6%
associate-*r/2.6%
associate-*r*2.6%
*-commutative2.6%
Simplified2.6%
expm1-log1p-u2.6%
expm1-undefine23.3%
*-commutative23.3%
associate-*l/23.3%
*-commutative23.3%
associate-*l*23.3%
Applied egg-rr23.3%
sub-neg23.3%
metadata-eval23.3%
+-commutative23.3%
log1p-undefine23.3%
rem-exp-log23.3%
+-commutative23.3%
associate-/l*23.3%
fma-define23.3%
*-commutative23.3%
associate-/l*23.3%
Simplified23.3%
Taylor expanded in n around 0 50.4%
Final simplification62.7%
(FPCore (k n) :precision binary64 (if (<= k 2150000.0) (sqrt (* PI (* 2.0 (/ n k)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = sqrt((((double) M_PI) * (2.0 * (n / k))));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = Math.sqrt((Math.PI * (2.0 * (n / k))));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2150000.0: tmp = math.sqrt((math.pi * (2.0 * (n / k)))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2150000.0) tmp = sqrt(Float64(pi * Float64(2.0 * Float64(n / k)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2150000.0) tmp = sqrt((pi * (2.0 * (n / k)))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2150000.0], N[Sqrt[N[(Pi * N[(2.0 * N[(n / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2150000:\\
\;\;\;\;\sqrt{\pi \cdot \left(2 \cdot \frac{n}{k}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.15e6Initial program 99.0%
associate-*l/99.2%
*-un-lft-identity99.2%
associate-*r*99.2%
div-sub99.2%
metadata-eval99.2%
pow-div99.4%
pow1/299.4%
associate-/l/99.4%
div-inv99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in k around 0 74.9%
*-commutative74.9%
associate-/l*74.9%
Simplified74.9%
clear-num74.9%
un-div-inv74.9%
Applied egg-rr74.9%
sqrt-unprod75.2%
div-inv75.1%
clear-num75.1%
associate-*l*75.1%
Applied egg-rr75.1%
if 2.15e6 < k Initial program 100.0%
Applied egg-rr100.0%
distribute-lft-in100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 2.6%
associate-*r/2.6%
associate-*r*2.6%
*-commutative2.6%
Simplified2.6%
expm1-log1p-u2.6%
expm1-undefine23.3%
*-commutative23.3%
associate-*l/23.3%
*-commutative23.3%
associate-*l*23.3%
Applied egg-rr23.3%
sub-neg23.3%
metadata-eval23.3%
+-commutative23.3%
log1p-undefine23.3%
rem-exp-log23.3%
+-commutative23.3%
associate-/l*23.3%
fma-define23.3%
*-commutative23.3%
associate-/l*23.3%
Simplified23.3%
Taylor expanded in n around 0 50.4%
Final simplification62.7%
(FPCore (k n) :precision binary64 (if (<= k 2150000.0) (sqrt (* PI (* n (/ 2.0 k)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = sqrt((((double) M_PI) * (n * (2.0 / k))));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = Math.sqrt((Math.PI * (n * (2.0 / k))));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2150000.0: tmp = math.sqrt((math.pi * (n * (2.0 / k)))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2150000.0) tmp = sqrt(Float64(pi * Float64(n * Float64(2.0 / k)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2150000.0) tmp = sqrt((pi * (n * (2.0 / k)))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2150000.0], N[Sqrt[N[(Pi * N[(n * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2150000:\\
\;\;\;\;\sqrt{\pi \cdot \left(n \cdot \frac{2}{k}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.15e6Initial program 99.0%
Applied egg-rr77.3%
distribute-lft-in77.3%
metadata-eval77.3%
*-commutative77.3%
associate-*r*77.3%
metadata-eval77.3%
neg-mul-177.3%
sub-neg77.3%
*-commutative77.3%
Simplified77.3%
Taylor expanded in k around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
Simplified75.2%
Taylor expanded in n around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
associate-*l/75.1%
*-commutative75.1%
associate-/l*75.1%
Simplified75.1%
if 2.15e6 < k Initial program 100.0%
Applied egg-rr100.0%
distribute-lft-in100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 2.6%
associate-*r/2.6%
associate-*r*2.6%
*-commutative2.6%
Simplified2.6%
expm1-log1p-u2.6%
expm1-undefine23.3%
*-commutative23.3%
associate-*l/23.3%
*-commutative23.3%
associate-*l*23.3%
Applied egg-rr23.3%
sub-neg23.3%
metadata-eval23.3%
+-commutative23.3%
log1p-undefine23.3%
rem-exp-log23.3%
+-commutative23.3%
associate-/l*23.3%
fma-define23.3%
*-commutative23.3%
associate-/l*23.3%
Simplified23.3%
Taylor expanded in n around 0 50.4%
Final simplification62.7%
(FPCore (k n) :precision binary64 (if (<= k 2150000.0) (sqrt (* n (* PI (/ 2.0 k)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = sqrt((n * (((double) M_PI) * (2.0 / k))));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2150000.0) {
tmp = Math.sqrt((n * (Math.PI * (2.0 / k))));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2150000.0: tmp = math.sqrt((n * (math.pi * (2.0 / k)))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2150000.0) tmp = sqrt(Float64(n * Float64(pi * Float64(2.0 / k)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2150000.0) tmp = sqrt((n * (pi * (2.0 / k)))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2150000.0], N[Sqrt[N[(n * N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2150000:\\
\;\;\;\;\sqrt{n \cdot \left(\pi \cdot \frac{2}{k}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.15e6Initial program 99.0%
Applied egg-rr77.3%
distribute-lft-in77.3%
metadata-eval77.3%
*-commutative77.3%
associate-*r*77.3%
metadata-eval77.3%
neg-mul-177.3%
sub-neg77.3%
*-commutative77.3%
Simplified77.3%
Taylor expanded in k around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
Simplified75.2%
Taylor expanded in n around 0 75.2%
associate-*r/75.2%
associate-*r*75.2%
*-commutative75.2%
associate-*r*75.2%
associate-/l*74.4%
*-commutative74.4%
associate-/l*74.4%
Simplified74.4%
if 2.15e6 < k Initial program 100.0%
Applied egg-rr100.0%
distribute-lft-in100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 2.6%
associate-*r/2.6%
associate-*r*2.6%
*-commutative2.6%
Simplified2.6%
expm1-log1p-u2.6%
expm1-undefine23.3%
*-commutative23.3%
associate-*l/23.3%
*-commutative23.3%
associate-*l*23.3%
Applied egg-rr23.3%
sub-neg23.3%
metadata-eval23.3%
+-commutative23.3%
log1p-undefine23.3%
rem-exp-log23.3%
+-commutative23.3%
associate-/l*23.3%
fma-define23.3%
*-commutative23.3%
associate-/l*23.3%
Simplified23.3%
Taylor expanded in n around 0 50.4%
Final simplification62.3%
(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.5%
Applied egg-rr88.7%
distribute-lft-in88.7%
metadata-eval88.7%
*-commutative88.7%
associate-*r*88.7%
metadata-eval88.7%
neg-mul-188.7%
sub-neg88.7%
*-commutative88.7%
Simplified88.7%
Taylor expanded in k around 0 38.6%
associate-*r/38.6%
associate-*r*38.6%
*-commutative38.6%
Simplified38.6%
expm1-log1p-u37.1%
expm1-undefine35.2%
*-commutative35.2%
associate-*l/35.2%
*-commutative35.2%
associate-*l*35.2%
Applied egg-rr35.2%
sub-neg35.2%
metadata-eval35.2%
+-commutative35.2%
log1p-undefine35.2%
rem-exp-log36.7%
+-commutative36.7%
associate-/l*36.3%
fma-define36.3%
*-commutative36.3%
associate-/l*36.3%
Simplified36.3%
Taylor expanded in n around 0 26.8%
Final simplification26.8%
herbie shell --seed 2024148
(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))))