
(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 8 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 4.2e-36) (* (sqrt (* 2.0 n)) (sqrt (/ PI k))) (sqrt (/ (pow (* n (* 2.0 PI)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 4.2e-36) {
tmp = sqrt((2.0 * n)) * sqrt((((double) M_PI) / k));
} else {
tmp = sqrt((pow((n * (2.0 * ((double) M_PI))), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 4.2e-36) {
tmp = Math.sqrt((2.0 * n)) * Math.sqrt((Math.PI / k));
} else {
tmp = Math.sqrt((Math.pow((n * (2.0 * Math.PI)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 4.2e-36: tmp = math.sqrt((2.0 * n)) * math.sqrt((math.pi / k)) else: tmp = math.sqrt((math.pow((n * (2.0 * math.pi)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 4.2e-36) tmp = Float64(sqrt(Float64(2.0 * n)) * sqrt(Float64(pi / k))); else tmp = sqrt(Float64((Float64(n * Float64(2.0 * pi)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 4.2e-36) tmp = sqrt((2.0 * n)) * sqrt((pi / k)); else tmp = sqrt((((n * (2.0 * pi)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 4.2e-36], N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 4.2 \cdot 10^{-36}:\\
\;\;\;\;\sqrt{2 \cdot n} \cdot \sqrt{\frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(n \cdot \left(2 \cdot \pi\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 4.19999999999999982e-36Initial program 99.2%
associate-*l/99.4%
*-lft-identity99.4%
associate-*l*99.4%
div-sub99.4%
sub-neg99.4%
distribute-frac-neg99.4%
+-commutative99.4%
neg-mul-199.4%
*-commutative99.4%
associate-/l*99.4%
fma-define99.4%
metadata-eval99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in k around 0 70.5%
associate-/l*70.5%
Simplified70.5%
*-commutative70.5%
sqrt-unprod70.7%
Applied egg-rr70.7%
pow1/270.7%
associate-*r*70.7%
unpow-prod-down99.5%
pow1/299.5%
Applied egg-rr99.5%
unpow1/299.5%
Simplified99.5%
if 4.19999999999999982e-36 < k Initial program 99.8%
associate-*l/99.8%
*-lft-identity99.8%
associate-*l*99.8%
div-sub99.8%
sub-neg99.8%
distribute-frac-neg99.8%
+-commutative99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/l*99.8%
fma-define99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
frac-times99.8%
pow-sqr99.8%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
Simplified99.8%
(FPCore (k n) :precision binary64 (if (<= k 2200000.0) (* (sqrt (* 2.0 n)) (sqrt (/ PI k))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2200000.0) {
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 <= 2200000.0) {
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 <= 2200000.0: 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 <= 2200000.0) 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 <= 2200000.0) tmp = sqrt((2.0 * n)) * sqrt((pi / k)); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2200000.0], 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 2200000:\\
\;\;\;\;\sqrt{2 \cdot n} \cdot \sqrt{\frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.2e6Initial program 99.0%
associate-*l/99.1%
*-lft-identity99.1%
associate-*l*99.1%
div-sub99.1%
sub-neg99.1%
distribute-frac-neg99.1%
+-commutative99.1%
neg-mul-199.1%
*-commutative99.1%
associate-/l*99.1%
fma-define99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in k around 0 69.6%
associate-/l*69.6%
Simplified69.6%
*-commutative69.6%
sqrt-unprod69.8%
Applied egg-rr69.8%
pow1/269.8%
associate-*r*69.8%
unpow-prod-down96.1%
pow1/296.1%
Applied egg-rr96.1%
unpow1/296.1%
Simplified96.1%
if 2.2e6 < k Initial program 100.0%
associate-*l/100.0%
*-lft-identity100.0%
associate-*l*100.0%
div-sub100.0%
sub-neg100.0%
distribute-frac-neg100.0%
+-commutative100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in k around 0 2.0%
associate-/l*2.0%
Simplified2.0%
*-commutative2.0%
sqrt-unprod2.0%
Applied egg-rr2.0%
expm1-log1p-u2.0%
expm1-undefine41.5%
Applied egg-rr41.5%
sub-neg41.5%
metadata-eval41.5%
+-commutative41.5%
log1p-undefine41.5%
rem-exp-log41.5%
+-commutative41.5%
associate-*r/41.5%
*-commutative41.5%
associate-/l*41.5%
fma-define41.5%
Simplified41.5%
Taylor expanded in n around 0 69.8%
Final simplification80.3%
(FPCore (k n) :precision binary64 (if (<= k 2200000.0) (* (sqrt n) (sqrt (/ (* 2.0 PI) k))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2200000.0) {
tmp = sqrt(n) * sqrt(((2.0 * ((double) M_PI)) / k));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2200000.0) {
tmp = Math.sqrt(n) * Math.sqrt(((2.0 * Math.PI) / k));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2200000.0: tmp = math.sqrt(n) * math.sqrt(((2.0 * math.pi) / k)) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2200000.0) tmp = Float64(sqrt(n) * sqrt(Float64(Float64(2.0 * pi) / k))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2200000.0) tmp = sqrt(n) * sqrt(((2.0 * pi) / k)); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2200000.0], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(N[(2.0 * Pi), $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2200000:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{\frac{2 \cdot \pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.2e6Initial program 99.0%
associate-*l/99.1%
*-lft-identity99.1%
associate-*l*99.1%
div-sub99.1%
sub-neg99.1%
distribute-frac-neg99.1%
+-commutative99.1%
neg-mul-199.1%
*-commutative99.1%
associate-/l*99.1%
fma-define99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in k around 0 69.6%
associate-/l*69.6%
Simplified69.6%
*-commutative69.6%
sqrt-unprod69.8%
Applied egg-rr69.8%
associate-*r*69.8%
associate-*r/69.8%
*-commutative69.8%
associate-*r*69.8%
pow1/269.7%
associate-/l*69.8%
unpow-prod-down96.0%
pow1/296.0%
associate-/l*96.0%
Applied egg-rr96.0%
unpow1/296.0%
associate-*r/96.0%
Simplified96.0%
if 2.2e6 < k Initial program 100.0%
associate-*l/100.0%
*-lft-identity100.0%
associate-*l*100.0%
div-sub100.0%
sub-neg100.0%
distribute-frac-neg100.0%
+-commutative100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in k around 0 2.0%
associate-/l*2.0%
Simplified2.0%
*-commutative2.0%
sqrt-unprod2.0%
Applied egg-rr2.0%
expm1-log1p-u2.0%
expm1-undefine41.5%
Applied egg-rr41.5%
sub-neg41.5%
metadata-eval41.5%
+-commutative41.5%
log1p-undefine41.5%
rem-exp-log41.5%
+-commutative41.5%
associate-*r/41.5%
*-commutative41.5%
associate-/l*41.5%
fma-define41.5%
Simplified41.5%
Taylor expanded in n around 0 69.8%
Final simplification80.3%
(FPCore (k n) :precision binary64 (/ (pow (* 2.0 (* PI n)) (- 0.5 (* 0.5 k))) (sqrt k)))
double code(double k, double n) {
return pow((2.0 * (((double) M_PI) * n)), (0.5 - (0.5 * k))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow((2.0 * (Math.PI * n)), (0.5 - (0.5 * k))) / Math.sqrt(k);
}
def code(k, n): return math.pow((2.0 * (math.pi * n)), (0.5 - (0.5 * k))) / math.sqrt(k)
function code(k, n) return Float64((Float64(2.0 * Float64(pi * n)) ^ Float64(0.5 - Float64(0.5 * k))) / sqrt(k)) end
function tmp = code(k, n) tmp = ((2.0 * (pi * n)) ^ (0.5 - (0.5 * k))) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision], N[(0.5 - N[(0.5 * k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(0.5 - 0.5 \cdot k\right)}}{\sqrt{k}}
\end{array}
Initial program 99.6%
associate-*l/99.7%
*-un-lft-identity99.7%
associate-*r*99.7%
div-sub99.7%
metadata-eval99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (if (<= k 2200000.0) (pow (/ k (* 2.0 (* PI n))) -0.5) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2200000.0) {
tmp = pow((k / (2.0 * (((double) M_PI) * n))), -0.5);
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2200000.0) {
tmp = Math.pow((k / (2.0 * (Math.PI * n))), -0.5);
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2200000.0: tmp = math.pow((k / (2.0 * (math.pi * n))), -0.5) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2200000.0) tmp = Float64(k / Float64(2.0 * Float64(pi * n))) ^ -0.5; else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2200000.0) tmp = (k / (2.0 * (pi * n))) ^ -0.5; else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2200000.0], N[Power[N[(k / N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2200000:\\
\;\;\;\;{\left(\frac{k}{2 \cdot \left(\pi \cdot n\right)}\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.2e6Initial program 99.0%
associate-*l/99.1%
*-lft-identity99.1%
associate-*l*99.1%
div-sub99.1%
sub-neg99.1%
distribute-frac-neg99.1%
+-commutative99.1%
neg-mul-199.1%
*-commutative99.1%
associate-/l*99.1%
fma-define99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in k around 0 69.6%
associate-/l*69.6%
Simplified69.6%
pow169.6%
*-commutative69.6%
sqrt-unprod69.8%
Applied egg-rr69.8%
unpow169.8%
associate-*r/69.8%
*-commutative69.8%
associate-/l*69.9%
Simplified69.9%
associate-*r*69.9%
associate-*r/69.8%
*-commutative69.8%
clear-num69.8%
metadata-eval69.8%
add-sqr-sqrt69.5%
frac-times69.6%
sqrt-unprod70.2%
add-sqr-sqrt70.5%
pow1/270.5%
pow-flip70.7%
*-commutative70.7%
associate-*l*70.7%
*-commutative70.7%
metadata-eval70.7%
Applied egg-rr70.7%
if 2.2e6 < k Initial program 100.0%
associate-*l/100.0%
*-lft-identity100.0%
associate-*l*100.0%
div-sub100.0%
sub-neg100.0%
distribute-frac-neg100.0%
+-commutative100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in k around 0 2.0%
associate-/l*2.0%
Simplified2.0%
*-commutative2.0%
sqrt-unprod2.0%
Applied egg-rr2.0%
expm1-log1p-u2.0%
expm1-undefine41.5%
Applied egg-rr41.5%
sub-neg41.5%
metadata-eval41.5%
+-commutative41.5%
log1p-undefine41.5%
rem-exp-log41.5%
+-commutative41.5%
associate-*r/41.5%
*-commutative41.5%
associate-/l*41.5%
fma-define41.5%
Simplified41.5%
Taylor expanded in n around 0 69.8%
Final simplification70.1%
(FPCore (k n) :precision binary64 (if (<= k 2200000.0) (sqrt (* 2.0 (* PI (/ n k)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2200000.0) {
tmp = sqrt((2.0 * (((double) M_PI) * (n / k))));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2200000.0) {
tmp = Math.sqrt((2.0 * (Math.PI * (n / k))));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2200000.0: tmp = math.sqrt((2.0 * (math.pi * (n / k)))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2200000.0) tmp = sqrt(Float64(2.0 * Float64(pi * Float64(n / k)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2200000.0) tmp = sqrt((2.0 * (pi * (n / k)))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2200000.0], N[Sqrt[N[(2.0 * N[(Pi * N[(n / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2200000:\\
\;\;\;\;\sqrt{2 \cdot \left(\pi \cdot \frac{n}{k}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.2e6Initial program 99.0%
associate-*l/99.1%
*-lft-identity99.1%
associate-*l*99.1%
div-sub99.1%
sub-neg99.1%
distribute-frac-neg99.1%
+-commutative99.1%
neg-mul-199.1%
*-commutative99.1%
associate-/l*99.1%
fma-define99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in k around 0 69.6%
associate-/l*69.6%
Simplified69.6%
pow169.6%
*-commutative69.6%
sqrt-unprod69.8%
Applied egg-rr69.8%
unpow169.8%
associate-*r/69.8%
*-commutative69.8%
associate-/l*69.9%
Simplified69.9%
if 2.2e6 < k Initial program 100.0%
associate-*l/100.0%
*-lft-identity100.0%
associate-*l*100.0%
div-sub100.0%
sub-neg100.0%
distribute-frac-neg100.0%
+-commutative100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in k around 0 2.0%
associate-/l*2.0%
Simplified2.0%
*-commutative2.0%
sqrt-unprod2.0%
Applied egg-rr2.0%
expm1-log1p-u2.0%
expm1-undefine41.5%
Applied egg-rr41.5%
sub-neg41.5%
metadata-eval41.5%
+-commutative41.5%
log1p-undefine41.5%
rem-exp-log41.5%
+-commutative41.5%
associate-*r/41.5%
*-commutative41.5%
associate-/l*41.5%
fma-define41.5%
Simplified41.5%
Taylor expanded in n around 0 69.8%
Final simplification69.8%
(FPCore (k n) :precision binary64 (if (<= k 2200000.0) (sqrt (* 2.0 (* n (/ PI k)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2200000.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 <= 2200000.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 <= 2200000.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 <= 2200000.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 <= 2200000.0) tmp = sqrt((2.0 * (n * (pi / k)))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2200000.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 2200000:\\
\;\;\;\;\sqrt{2 \cdot \left(n \cdot \frac{\pi}{k}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.2e6Initial program 99.0%
associate-*l/99.1%
*-lft-identity99.1%
associate-*l*99.1%
div-sub99.1%
sub-neg99.1%
distribute-frac-neg99.1%
+-commutative99.1%
neg-mul-199.1%
*-commutative99.1%
associate-/l*99.1%
fma-define99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in k around 0 69.6%
associate-/l*69.6%
Simplified69.6%
*-commutative69.6%
sqrt-unprod69.8%
Applied egg-rr69.8%
if 2.2e6 < k Initial program 100.0%
associate-*l/100.0%
*-lft-identity100.0%
associate-*l*100.0%
div-sub100.0%
sub-neg100.0%
distribute-frac-neg100.0%
+-commutative100.0%
neg-mul-1100.0%
*-commutative100.0%
associate-/l*100.0%
fma-define100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in k around 0 2.0%
associate-/l*2.0%
Simplified2.0%
*-commutative2.0%
sqrt-unprod2.0%
Applied egg-rr2.0%
expm1-log1p-u2.0%
expm1-undefine41.5%
Applied egg-rr41.5%
sub-neg41.5%
metadata-eval41.5%
+-commutative41.5%
log1p-undefine41.5%
rem-exp-log41.5%
+-commutative41.5%
associate-*r/41.5%
*-commutative41.5%
associate-/l*41.5%
fma-define41.5%
Simplified41.5%
Taylor expanded in n around 0 69.8%
Final simplification69.8%
(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.6%
associate-*l/99.7%
*-lft-identity99.7%
associate-*l*99.7%
div-sub99.7%
sub-neg99.7%
distribute-frac-neg99.7%
+-commutative99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/l*99.7%
fma-define99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in k around 0 29.2%
associate-/l*29.2%
Simplified29.2%
*-commutative29.2%
sqrt-unprod29.3%
Applied egg-rr29.3%
expm1-log1p-u28.0%
expm1-undefine44.2%
Applied egg-rr44.2%
sub-neg44.2%
metadata-eval44.2%
+-commutative44.2%
log1p-undefine44.2%
rem-exp-log45.5%
+-commutative45.5%
associate-*r/45.5%
*-commutative45.5%
associate-/l*45.5%
fma-define45.5%
Simplified45.5%
Taylor expanded in n around 0 42.7%
Final simplification42.7%
herbie shell --seed 2024170
(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))))