
(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 9 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.5e-75) (* (sqrt (* PI (/ 2.0 k))) (sqrt n)) (sqrt (/ (pow (* PI (* n 2.0)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 4.5e-75) {
tmp = sqrt((((double) M_PI) * (2.0 / k))) * sqrt(n);
} else {
tmp = sqrt((pow((((double) M_PI) * (n * 2.0)), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 4.5e-75) {
tmp = Math.sqrt((Math.PI * (2.0 / k))) * Math.sqrt(n);
} else {
tmp = Math.sqrt((Math.pow((Math.PI * (n * 2.0)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 4.5e-75: tmp = math.sqrt((math.pi * (2.0 / k))) * math.sqrt(n) else: tmp = math.sqrt((math.pow((math.pi * (n * 2.0)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 4.5e-75) tmp = Float64(sqrt(Float64(pi * Float64(2.0 / k))) * sqrt(n)); else tmp = sqrt(Float64((Float64(pi * Float64(n * 2.0)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 4.5e-75) tmp = sqrt((pi * (2.0 / k))) * sqrt(n); else tmp = sqrt((((pi * (n * 2.0)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 4.5e-75], N[(N[Sqrt[N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 4.5 \cdot 10^{-75}:\\
\;\;\;\;\sqrt{\pi \cdot \frac{2}{k}} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 4.5000000000000003e-75Initial program 98.3%
Taylor expanded in k around 0 68.2%
*-commutative68.2%
associate-/l*68.2%
Simplified68.2%
pow168.2%
sqrt-unprod68.5%
clear-num68.5%
un-div-inv68.4%
Applied egg-rr68.4%
unpow168.4%
associate-/r/68.4%
Simplified68.4%
sqrt-prod68.2%
associate-*l/68.2%
associate-/l*68.2%
sqrt-prod99.1%
*-commutative99.1%
associate-*r*99.1%
sqrt-unprod99.4%
Applied egg-rr99.4%
associate-*r/99.4%
*-commutative99.4%
associate-/l*99.5%
Simplified99.5%
if 4.5000000000000003e-75 < k Initial program 99.7%
add-sqr-sqrt99.6%
sqrt-unprod99.7%
*-commutative99.7%
associate-*r*99.7%
div-sub99.7%
metadata-eval99.7%
div-inv99.7%
*-commutative99.7%
Applied egg-rr99.7%
Simplified99.7%
Final simplification99.6%
(FPCore (k n) :precision binary64 (let* ((t_0 (* PI (* n 2.0)))) (/ (sqrt t_0) (* (pow t_0 (* 0.5 k)) (sqrt k)))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (n * 2.0);
return sqrt(t_0) / (pow(t_0, (0.5 * k)) * sqrt(k));
}
public static double code(double k, double n) {
double t_0 = Math.PI * (n * 2.0);
return Math.sqrt(t_0) / (Math.pow(t_0, (0.5 * k)) * Math.sqrt(k));
}
def code(k, n): t_0 = math.pi * (n * 2.0) return math.sqrt(t_0) / (math.pow(t_0, (0.5 * k)) * math.sqrt(k))
function code(k, n) t_0 = Float64(pi * Float64(n * 2.0)) return Float64(sqrt(t_0) / Float64((t_0 ^ Float64(0.5 * k)) * sqrt(k))) end
function tmp = code(k, n) t_0 = pi * (n * 2.0); tmp = sqrt(t_0) / ((t_0 ^ (0.5 * k)) * sqrt(k)); end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Sqrt[t$95$0], $MachinePrecision] / N[(N[Power[t$95$0, N[(0.5 * k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(n \cdot 2\right)\\
\frac{\sqrt{t\_0}}{{t\_0}^{\left(0.5 \cdot k\right)} \cdot \sqrt{k}}
\end{array}
\end{array}
Initial program 99.2%
associate-*l/99.3%
*-un-lft-identity99.3%
associate-*r*99.3%
div-sub99.3%
metadata-eval99.3%
pow-div99.4%
pow1/299.4%
associate-/l/99.4%
div-inv99.4%
metadata-eval99.4%
Applied egg-rr99.4%
*-commutative99.4%
associate-*l*99.4%
*-commutative99.4%
*-commutative99.4%
associate-*l*99.4%
*-commutative99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (if (<= k 3.1) (* (sqrt n) (sqrt (* 2.0 (/ PI k)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 3.1) {
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 <= 3.1) {
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 <= 3.1: 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 <= 3.1) tmp = Float64(sqrt(n) * sqrt(Float64(2.0 * 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(n) * sqrt((2.0 * (pi / k))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.1], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.1:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{2 \cdot \frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 3.10000000000000009Initial program 98.2%
Taylor expanded in k around 0 74.3%
*-commutative74.3%
associate-/l*74.2%
Simplified74.2%
pow174.2%
sqrt-unprod74.5%
clear-num74.5%
un-div-inv74.5%
Applied egg-rr74.5%
unpow174.5%
associate-/r/74.5%
Simplified74.5%
sqrt-prod74.3%
associate-*l/74.3%
associate-/l*74.2%
sqrt-prod96.4%
*-commutative96.4%
associate-*r*96.3%
sqrt-unprod96.7%
Applied egg-rr96.7%
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%
clear-num2.7%
un-div-inv2.7%
Applied egg-rr2.7%
unpow12.7%
associate-/r/2.7%
Simplified2.7%
associate-*l/2.7%
expm1-log1p-u2.7%
expm1-undefine22.7%
associate-*l/22.7%
*-commutative22.7%
clear-num22.7%
un-div-inv22.7%
Applied egg-rr22.7%
sub-neg22.7%
metadata-eval22.7%
+-commutative22.7%
log1p-undefine22.7%
rem-exp-log22.7%
+-commutative22.7%
associate-/r/22.7%
*-commutative22.7%
fma-define22.7%
Simplified22.7%
Taylor expanded in n around 0 51.1%
Final simplification70.5%
(FPCore (k n) :precision binary64 (if (<= k 3.2) (* (sqrt (* PI (/ 2.0 k))) (sqrt n)) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 3.2) {
tmp = sqrt((((double) M_PI) * (2.0 / k))) * sqrt(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((Math.PI * (2.0 / k))) * Math.sqrt(n);
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 3.2: tmp = math.sqrt((math.pi * (2.0 / k))) * math.sqrt(n) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 3.2) tmp = Float64(sqrt(Float64(pi * Float64(2.0 / k))) * sqrt(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((pi * (2.0 / k))) * sqrt(n); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.2], N[(N[Sqrt[N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.2:\\
\;\;\;\;\sqrt{\pi \cdot \frac{2}{k}} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 3.2000000000000002Initial program 98.2%
Taylor expanded in k around 0 74.3%
*-commutative74.3%
associate-/l*74.2%
Simplified74.2%
pow174.2%
sqrt-unprod74.5%
clear-num74.5%
un-div-inv74.5%
Applied egg-rr74.5%
unpow174.5%
associate-/r/74.5%
Simplified74.5%
sqrt-prod74.3%
associate-*l/74.3%
associate-/l*74.2%
sqrt-prod96.4%
*-commutative96.4%
associate-*r*96.3%
sqrt-unprod96.7%
Applied egg-rr96.7%
associate-*r/96.7%
*-commutative96.7%
associate-/l*96.7%
Simplified96.7%
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%
clear-num2.7%
un-div-inv2.7%
Applied egg-rr2.7%
unpow12.7%
associate-/r/2.7%
Simplified2.7%
associate-*l/2.7%
expm1-log1p-u2.7%
expm1-undefine22.7%
associate-*l/22.7%
*-commutative22.7%
clear-num22.7%
un-div-inv22.7%
Applied egg-rr22.7%
sub-neg22.7%
metadata-eval22.7%
+-commutative22.7%
log1p-undefine22.7%
rem-exp-log22.7%
+-commutative22.7%
associate-/r/22.7%
*-commutative22.7%
fma-define22.7%
Simplified22.7%
Taylor expanded in n around 0 51.1%
Final simplification70.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.2%
associate-*l/99.3%
*-lft-identity99.3%
associate-*l*99.3%
div-sub99.3%
metadata-eval99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (k n) :precision binary64 (if (<= k 2.9) (/ 1.0 (sqrt (* 0.5 (/ (/ k PI) n)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 2.9) {
tmp = 1.0 / sqrt((0.5 * ((k / ((double) M_PI)) / n)));
} else {
tmp = sqrt(0.0);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.9) {
tmp = 1.0 / Math.sqrt((0.5 * ((k / Math.PI) / n)));
} else {
tmp = Math.sqrt(0.0);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.9: tmp = 1.0 / math.sqrt((0.5 * ((k / math.pi) / n))) else: tmp = math.sqrt(0.0) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.9) tmp = Float64(1.0 / sqrt(Float64(0.5 * Float64(Float64(k / pi) / n)))); else tmp = sqrt(0.0); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.9) tmp = 1.0 / sqrt((0.5 * ((k / pi) / n))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.9], N[(1.0 / N[Sqrt[N[(0.5 * N[(N[(k / Pi), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.9:\\
\;\;\;\;\frac{1}{\sqrt{0.5 \cdot \frac{\frac{k}{\pi}}{n}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 2.89999999999999991Initial program 98.2%
Taylor expanded in k around 0 74.3%
*-commutative74.3%
associate-/l*74.2%
Simplified74.2%
pow174.2%
sqrt-unprod74.5%
clear-num74.5%
un-div-inv74.5%
Applied egg-rr74.5%
unpow174.5%
associate-/r/74.5%
Simplified74.5%
Taylor expanded in n around 0 74.5%
associate-*r/74.5%
Simplified74.5%
sqrt-prod74.2%
associate-*r/74.3%
*-commutative74.3%
clear-num74.3%
sqrt-prod74.5%
div-inv74.5%
clear-num74.5%
sqrt-div75.5%
metadata-eval75.5%
div-inv75.5%
metadata-eval75.5%
Applied egg-rr75.5%
*-commutative75.5%
associate-/r*75.5%
Simplified75.5%
if 2.89999999999999991 < 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%
clear-num2.7%
un-div-inv2.7%
Applied egg-rr2.7%
unpow12.7%
associate-/r/2.7%
Simplified2.7%
associate-*l/2.7%
expm1-log1p-u2.7%
expm1-undefine22.7%
associate-*l/22.7%
*-commutative22.7%
clear-num22.7%
un-div-inv22.7%
Applied egg-rr22.7%
sub-neg22.7%
metadata-eval22.7%
+-commutative22.7%
log1p-undefine22.7%
rem-exp-log22.7%
+-commutative22.7%
associate-/r/22.7%
*-commutative22.7%
fma-define22.7%
Simplified22.7%
Taylor expanded in n around 0 51.1%
Final simplification61.5%
(FPCore (k n) :precision binary64 (if (<= k 3.1) (sqrt (* 2.0 (* n (/ PI k)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 3.1) {
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.1) {
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.1: 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.1) 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.1) tmp = sqrt((2.0 * (n * (pi / 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[(n * N[(Pi / k), $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(n \cdot \frac{\pi}{k}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 3.10000000000000009Initial program 98.2%
Taylor expanded in k around 0 74.3%
*-commutative74.3%
associate-/l*74.2%
Simplified74.2%
pow174.2%
sqrt-unprod74.5%
clear-num74.5%
un-div-inv74.5%
Applied egg-rr74.5%
unpow174.5%
associate-/r/74.5%
Simplified74.5%
Taylor expanded in n around 0 74.5%
associate-*r/74.5%
Simplified74.5%
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%
clear-num2.7%
un-div-inv2.7%
Applied egg-rr2.7%
unpow12.7%
associate-/r/2.7%
Simplified2.7%
associate-*l/2.7%
expm1-log1p-u2.7%
expm1-undefine22.7%
associate-*l/22.7%
*-commutative22.7%
clear-num22.7%
un-div-inv22.7%
Applied egg-rr22.7%
sub-neg22.7%
metadata-eval22.7%
+-commutative22.7%
log1p-undefine22.7%
rem-exp-log22.7%
+-commutative22.7%
associate-/r/22.7%
*-commutative22.7%
fma-define22.7%
Simplified22.7%
Taylor expanded in n around 0 51.1%
Final simplification61.1%
(FPCore (k n) :precision binary64 (if (<= k 3.1) (sqrt (* 2.0 (/ n (/ k PI)))) (sqrt 0.0)))
double code(double k, double n) {
double tmp;
if (k <= 3.1) {
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.1) {
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.1: 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.1) tmp = sqrt(Float64(2.0 * Float64(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.1) tmp = sqrt((2.0 * (n / (k / pi)))); else tmp = sqrt(0.0); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.1], N[Sqrt[N[(2.0 * N[(n / N[(k / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[0.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.1:\\
\;\;\;\;\sqrt{2 \cdot \frac{n}{\frac{k}{\pi}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0}\\
\end{array}
\end{array}
if k < 3.10000000000000009Initial program 98.2%
Taylor expanded in k around 0 74.3%
*-commutative74.3%
associate-/l*74.2%
Simplified74.2%
sqrt-unprod74.5%
clear-num74.5%
un-div-inv74.5%
Applied egg-rr74.5%
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%
clear-num2.7%
un-div-inv2.7%
Applied egg-rr2.7%
unpow12.7%
associate-/r/2.7%
Simplified2.7%
associate-*l/2.7%
expm1-log1p-u2.7%
expm1-undefine22.7%
associate-*l/22.7%
*-commutative22.7%
clear-num22.7%
un-div-inv22.7%
Applied egg-rr22.7%
sub-neg22.7%
metadata-eval22.7%
+-commutative22.7%
log1p-undefine22.7%
rem-exp-log22.7%
+-commutative22.7%
associate-/r/22.7%
*-commutative22.7%
fma-define22.7%
Simplified22.7%
Taylor expanded in n around 0 51.1%
Final simplification61.1%
(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.2%
Taylor expanded in k around 0 33.2%
*-commutative33.2%
associate-/l*33.2%
Simplified33.2%
pow133.2%
sqrt-unprod33.3%
clear-num33.3%
un-div-inv33.3%
Applied egg-rr33.3%
unpow133.3%
associate-/r/33.3%
Simplified33.3%
associate-*l/33.3%
expm1-log1p-u31.8%
expm1-undefine34.1%
associate-*l/34.1%
*-commutative34.1%
clear-num34.1%
un-div-inv34.1%
Applied egg-rr34.1%
sub-neg34.1%
metadata-eval34.1%
+-commutative34.1%
log1p-undefine34.1%
rem-exp-log35.6%
+-commutative35.6%
associate-/r/35.6%
*-commutative35.6%
fma-define35.6%
Simplified35.6%
Taylor expanded in n around 0 30.5%
Final simplification30.5%
herbie shell --seed 2024076
(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))))