
(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 10 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 9.8e-28) (/ 1.0 (/ (sqrt k) (sqrt (* n (* 2.0 PI))))) (sqrt (/ (pow (* 2.0 (* PI n)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 9.8e-28) {
tmp = 1.0 / (sqrt(k) / sqrt((n * (2.0 * ((double) M_PI)))));
} else {
tmp = sqrt((pow((2.0 * (((double) M_PI) * n)), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 9.8e-28) {
tmp = 1.0 / (Math.sqrt(k) / Math.sqrt((n * (2.0 * Math.PI))));
} else {
tmp = Math.sqrt((Math.pow((2.0 * (Math.PI * n)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 9.8e-28: tmp = 1.0 / (math.sqrt(k) / math.sqrt((n * (2.0 * math.pi)))) else: tmp = math.sqrt((math.pow((2.0 * (math.pi * n)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 9.8e-28) tmp = Float64(1.0 / Float64(sqrt(k) / sqrt(Float64(n * Float64(2.0 * pi))))); else tmp = sqrt(Float64((Float64(2.0 * Float64(pi * n)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 9.8e-28) tmp = 1.0 / (sqrt(k) / sqrt((n * (2.0 * pi)))); else tmp = sqrt((((2.0 * (pi * n)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 9.8e-28], N[(1.0 / N[(N[Sqrt[k], $MachinePrecision] / N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $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 9.8 \cdot 10^{-28}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{k}}{\sqrt{n \cdot \left(2 \cdot \pi\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 9.80000000000000059e-28Initial program 99.4%
Taylor expanded in k around 0 99.2%
associate-*l/99.1%
*-un-lft-identity99.1%
clear-num99.1%
sqrt-unprod99.4%
*-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
Applied egg-rr99.4%
if 9.80000000000000059e-28 < k Initial program 99.7%
Applied egg-rr99.7%
distribute-lft-in99.7%
metadata-eval99.7%
*-commutative99.7%
associate-*r*99.7%
metadata-eval99.7%
neg-mul-199.7%
sub-neg99.7%
*-commutative99.7%
Simplified99.7%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 3.5) (* (pow k -0.5) (sqrt (* PI (* 2.0 n)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 3.5) {
tmp = pow(k, -0.5) * sqrt((((double) M_PI) * (2.0 * n)));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 3.5) {
tmp = Math.pow(k, -0.5) * Math.sqrt((Math.PI * (2.0 * n)));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 3.5: tmp = math.pow(k, -0.5) * math.sqrt((math.pi * (2.0 * n))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 3.5) tmp = Float64((k ^ -0.5) * sqrt(Float64(pi * Float64(2.0 * n)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 3.5) tmp = (k ^ -0.5) * sqrt((pi * (2.0 * n))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.5], N[(N[Power[k, -0.5], $MachinePrecision] * N[Sqrt[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.5:\\
\;\;\;\;{k}^{-0.5} \cdot \sqrt{\pi \cdot \left(2 \cdot n\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 3.5Initial program 99.0%
Taylor expanded in k around 0 71.8%
*-commutative71.8%
associate-/l*71.7%
Simplified71.7%
pow171.7%
sqrt-unprod72.0%
associate-*r*72.0%
Applied egg-rr72.0%
unpow172.0%
associate-*l*72.0%
associate-*r/72.0%
*-commutative72.0%
associate-/l*72.0%
Simplified72.0%
associate-*r*72.0%
sqrt-prod71.5%
sqrt-div96.3%
associate-/l*96.3%
sqrt-prod96.7%
div-inv96.7%
*-commutative96.7%
inv-pow96.7%
sqrt-pow296.8%
metadata-eval96.8%
associate-*r*96.8%
Applied egg-rr96.8%
*-commutative96.8%
associate-*r*96.8%
*-commutative96.8%
Simplified96.8%
if 3.5 < k Initial program 100.0%
Taylor expanded in k around 0 2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
pow12.7%
sqrt-unprod2.7%
associate-*r*2.7%
Applied egg-rr2.7%
unpow12.7%
associate-*l*2.7%
associate-*r/2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
expm1-log1p-u2.7%
expm1-undefine23.2%
associate-*r/23.2%
*-commutative23.2%
associate-/l*23.2%
Applied egg-rr23.2%
sub-neg23.2%
metadata-eval23.2%
+-commutative23.2%
log1p-undefine23.2%
rem-exp-log23.2%
+-commutative23.2%
associate-*r*23.2%
*-commutative23.2%
associate-*l*23.2%
associate-/l*23.2%
fma-define23.2%
*-commutative23.2%
associate-/l*23.2%
Simplified23.2%
Taylor expanded in n around 0 54.9%
Final simplification73.2%
(FPCore (k n) :precision binary64 (* (pow (* 2.0 (* PI n)) (+ 0.5 (* k -0.5))) (pow k -0.5)))
double code(double k, double n) {
return pow((2.0 * (((double) M_PI) * n)), (0.5 + (k * -0.5))) * pow(k, -0.5);
}
public static double code(double k, double n) {
return Math.pow((2.0 * (Math.PI * n)), (0.5 + (k * -0.5))) * Math.pow(k, -0.5);
}
def code(k, n): return math.pow((2.0 * (math.pi * n)), (0.5 + (k * -0.5))) * math.pow(k, -0.5)
function code(k, n) return Float64((Float64(2.0 * Float64(pi * n)) ^ Float64(0.5 + Float64(k * -0.5))) * (k ^ -0.5)) end
function tmp = code(k, n) tmp = ((2.0 * (pi * n)) ^ (0.5 + (k * -0.5))) * (k ^ -0.5); end
code[k_, n_] := N[(N[Power[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision], N[(0.5 + N[(k * -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[k, -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(0.5 + k \cdot -0.5\right)} \cdot {k}^{-0.5}
\end{array}
Initial program 99.6%
associate-*l/99.5%
*-lft-identity99.5%
associate-*l*99.5%
div-sub99.5%
metadata-eval99.5%
Simplified99.5%
metadata-eval99.5%
div-sub99.5%
associate-*r*99.5%
div-inv99.6%
associate-*r*99.6%
div-sub99.6%
metadata-eval99.6%
sub-neg99.6%
div-inv99.6%
metadata-eval99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
pow1/299.6%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
(FPCore (k n) :precision binary64 (if (<= k 2.8) (/ (sqrt (* n (* 2.0 PI))) (sqrt k)) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2.8) {
tmp = sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.8) {
tmp = Math.sqrt((n * (2.0 * Math.PI))) / Math.sqrt(k);
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.8: tmp = math.sqrt((n * (2.0 * math.pi))) / math.sqrt(k) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.8) tmp = Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k)); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.8) tmp = sqrt((n * (2.0 * pi))) / sqrt(k); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.8], N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.8:\\
\;\;\;\;\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.7999999999999998Initial program 99.0%
Taylor expanded in k around 0 96.6%
*-commutative96.6%
div-inv96.5%
sqrt-unprod96.7%
*-commutative96.7%
*-commutative96.7%
associate-*r*96.7%
Applied egg-rr96.7%
if 2.7999999999999998 < k Initial program 100.0%
Taylor expanded in k around 0 2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
pow12.7%
sqrt-unprod2.7%
associate-*r*2.7%
Applied egg-rr2.7%
unpow12.7%
associate-*l*2.7%
associate-*r/2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
expm1-log1p-u2.7%
expm1-undefine23.2%
associate-*r/23.2%
*-commutative23.2%
associate-/l*23.2%
Applied egg-rr23.2%
sub-neg23.2%
metadata-eval23.2%
+-commutative23.2%
log1p-undefine23.2%
rem-exp-log23.2%
+-commutative23.2%
associate-*r*23.2%
*-commutative23.2%
associate-*l*23.2%
associate-/l*23.2%
fma-define23.2%
*-commutative23.2%
associate-/l*23.2%
Simplified23.2%
Taylor expanded in n around 0 54.9%
Final simplification73.2%
(FPCore (k n) :precision binary64 (if (<= k 2.8) (* (sqrt (* 2.0 (/ PI k))) (sqrt n)) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2.8) {
tmp = sqrt((2.0 * (((double) M_PI) / k))) * sqrt(n);
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.8) {
tmp = Math.sqrt((2.0 * (Math.PI / k))) * Math.sqrt(n);
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.8: tmp = math.sqrt((2.0 * (math.pi / k))) * math.sqrt(n) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.8) tmp = Float64(sqrt(Float64(2.0 * Float64(pi / k))) * sqrt(n)); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.8) tmp = sqrt((2.0 * (pi / k))) * sqrt(n); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.8], N[(N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.8:\\
\;\;\;\;\sqrt{2 \cdot \frac{\pi}{k}} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.7999999999999998Initial program 99.0%
Taylor expanded in k around 0 71.8%
*-commutative71.8%
associate-/l*71.7%
Simplified71.7%
Taylor expanded in n around 0 71.8%
*-commutative71.8%
*-commutative71.8%
associate-/l*71.8%
Simplified71.8%
sqrt-prod72.0%
associate-*r/72.0%
*-commutative72.0%
associate-/l*72.0%
Applied egg-rr72.0%
associate-*r/72.0%
*-commutative72.0%
associate-*r/72.0%
*-commutative72.0%
associate-*r/72.0%
*-commutative72.0%
associate-*r*71.9%
*-commutative71.9%
sqrt-prod95.9%
Applied egg-rr95.9%
associate-*r/96.0%
*-commutative96.0%
associate-*r/96.0%
Simplified96.0%
if 2.7999999999999998 < k Initial program 100.0%
Taylor expanded in k around 0 2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
pow12.7%
sqrt-unprod2.7%
associate-*r*2.7%
Applied egg-rr2.7%
unpow12.7%
associate-*l*2.7%
associate-*r/2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
expm1-log1p-u2.7%
expm1-undefine23.2%
associate-*r/23.2%
*-commutative23.2%
associate-/l*23.2%
Applied egg-rr23.2%
sub-neg23.2%
metadata-eval23.2%
+-commutative23.2%
log1p-undefine23.2%
rem-exp-log23.2%
+-commutative23.2%
associate-*r*23.2%
*-commutative23.2%
associate-*l*23.2%
associate-/l*23.2%
fma-define23.2%
*-commutative23.2%
associate-/l*23.2%
Simplified23.2%
Taylor expanded in n around 0 54.9%
Final simplification72.9%
(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.6%
associate-*l/99.5%
*-lft-identity99.5%
associate-*l*99.5%
div-sub99.5%
metadata-eval99.5%
Simplified99.5%
(FPCore (k n) :precision binary64 (if (<= k 3.1) (sqrt (* 2.0 (* PI (* n (/ 1.0 k))))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 3.1) {
tmp = sqrt((2.0 * (((double) M_PI) * (n * (1.0 / 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 * (Math.PI * (n * (1.0 / k)))));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 3.1: tmp = math.sqrt((2.0 * (math.pi * (n * (1.0 / k))))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 3.1) tmp = sqrt(Float64(2.0 * Float64(pi * Float64(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 <= 3.1) tmp = sqrt((2.0 * (pi * (n * (1.0 / k))))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.1], N[Sqrt[N[(2.0 * N[(Pi * N[(n * N[(1.0 / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.1:\\
\;\;\;\;\sqrt{2 \cdot \left(\pi \cdot \left(n \cdot \frac{1}{k}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 3.10000000000000009Initial program 99.0%
Taylor expanded in k around 0 71.8%
*-commutative71.8%
associate-/l*71.7%
Simplified71.7%
pow171.7%
sqrt-unprod72.0%
associate-*r*72.0%
Applied egg-rr72.0%
unpow172.0%
associate-*l*72.0%
associate-*r/72.0%
*-commutative72.0%
associate-/l*72.0%
Simplified72.0%
associate-*r/72.0%
clear-num72.0%
Applied egg-rr72.0%
associate-/r/72.0%
*-commutative72.0%
associate-*r*72.0%
Applied egg-rr72.0%
if 3.10000000000000009 < k Initial program 100.0%
Taylor expanded in k around 0 2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
pow12.7%
sqrt-unprod2.7%
associate-*r*2.7%
Applied egg-rr2.7%
unpow12.7%
associate-*l*2.7%
associate-*r/2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
expm1-log1p-u2.7%
expm1-undefine23.2%
associate-*r/23.2%
*-commutative23.2%
associate-/l*23.2%
Applied egg-rr23.2%
sub-neg23.2%
metadata-eval23.2%
+-commutative23.2%
log1p-undefine23.2%
rem-exp-log23.2%
+-commutative23.2%
associate-*r*23.2%
*-commutative23.2%
associate-*l*23.2%
associate-/l*23.2%
fma-define23.2%
*-commutative23.2%
associate-/l*23.2%
Simplified23.2%
Taylor expanded in n around 0 54.9%
Final simplification62.4%
(FPCore (k n) :precision binary64 (if (<= k 3.2) (sqrt (/ 2.0 (/ k (* PI n)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 3.2) {
tmp = sqrt((2.0 / (k / (((double) M_PI) * n))));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 3.2) {
tmp = Math.sqrt((2.0 / (k / (Math.PI * n))));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 3.2: tmp = math.sqrt((2.0 / (k / (math.pi * n)))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 3.2) tmp = sqrt(Float64(2.0 / Float64(k / Float64(pi * n)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 3.2) tmp = sqrt((2.0 / (k / (pi * n)))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.2], N[Sqrt[N[(2.0 / N[(k / N[(Pi * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.2:\\
\;\;\;\;\sqrt{\frac{2}{\frac{k}{\pi \cdot n}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 3.2000000000000002Initial program 99.0%
Taylor expanded in k around 0 71.8%
*-commutative71.8%
associate-/l*71.7%
Simplified71.7%
Taylor expanded in n around 0 71.8%
*-commutative71.8%
*-commutative71.8%
associate-/l*71.8%
Simplified71.8%
sqrt-prod72.0%
associate-*r/72.0%
*-commutative72.0%
associate-/l*72.0%
Applied egg-rr72.0%
associate-*r/72.0%
*-commutative72.0%
clear-num72.0%
un-div-inv72.0%
*-commutative72.0%
Applied egg-rr72.0%
if 3.2000000000000002 < k Initial program 100.0%
Taylor expanded in k around 0 2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
pow12.7%
sqrt-unprod2.7%
associate-*r*2.7%
Applied egg-rr2.7%
unpow12.7%
associate-*l*2.7%
associate-*r/2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
expm1-log1p-u2.7%
expm1-undefine23.2%
associate-*r/23.2%
*-commutative23.2%
associate-/l*23.2%
Applied egg-rr23.2%
sub-neg23.2%
metadata-eval23.2%
+-commutative23.2%
log1p-undefine23.2%
rem-exp-log23.2%
+-commutative23.2%
associate-*r*23.2%
*-commutative23.2%
associate-*l*23.2%
associate-/l*23.2%
fma-define23.2%
*-commutative23.2%
associate-/l*23.2%
Simplified23.2%
Taylor expanded in n around 0 54.9%
Final simplification62.4%
(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 99.0%
Taylor expanded in k around 0 71.8%
*-commutative71.8%
associate-/l*71.7%
Simplified71.7%
Taylor expanded in n around 0 71.8%
*-commutative71.8%
*-commutative71.8%
associate-/l*71.8%
Simplified71.8%
sqrt-prod72.0%
associate-*r/72.0%
*-commutative72.0%
associate-/l*72.0%
Applied egg-rr72.0%
if 3 < k Initial program 100.0%
Taylor expanded in k around 0 2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
pow12.7%
sqrt-unprod2.7%
associate-*r*2.7%
Applied egg-rr2.7%
unpow12.7%
associate-*l*2.7%
associate-*r/2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
expm1-log1p-u2.7%
expm1-undefine23.2%
associate-*r/23.2%
*-commutative23.2%
associate-/l*23.2%
Applied egg-rr23.2%
sub-neg23.2%
metadata-eval23.2%
+-commutative23.2%
log1p-undefine23.2%
rem-exp-log23.2%
+-commutative23.2%
associate-*r*23.2%
*-commutative23.2%
associate-*l*23.2%
associate-/l*23.2%
fma-define23.2%
*-commutative23.2%
associate-/l*23.2%
Simplified23.2%
Taylor expanded in n around 0 54.9%
Final simplification62.4%
(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%
Taylor expanded in k around 0 32.9%
*-commutative32.9%
associate-/l*32.9%
Simplified32.9%
pow132.9%
sqrt-unprod33.0%
associate-*r*33.0%
Applied egg-rr33.0%
unpow133.0%
associate-*l*33.0%
associate-*r/33.0%
*-commutative33.0%
associate-/l*33.0%
Simplified33.0%
expm1-log1p-u31.5%
expm1-undefine33.7%
associate-*r/33.7%
*-commutative33.7%
associate-/l*33.7%
Applied egg-rr33.7%
sub-neg33.7%
metadata-eval33.7%
+-commutative33.7%
log1p-undefine33.7%
rem-exp-log35.2%
+-commutative35.2%
associate-*r*35.2%
*-commutative35.2%
associate-*l*35.2%
associate-/l*35.2%
fma-define35.2%
*-commutative35.2%
associate-/l*35.2%
Simplified35.2%
Taylor expanded in n around 0 32.0%
Final simplification32.0%
herbie shell --seed 2024144
(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))))