
(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 11 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) (/ (pow k -0.5) (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) * (pow(k, -0.5) / 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.pow(k, -0.5) / Math.pow(t_0, (k * 0.5)));
}
def code(k, n): t_0 = (2.0 * math.pi) * n return math.sqrt(t_0) * (math.pow(k, -0.5) / math.pow(t_0, (k * 0.5)))
function code(k, n) t_0 = Float64(Float64(2.0 * pi) * n) return Float64(sqrt(t_0) * Float64((k ^ -0.5) / (t_0 ^ Float64(k * 0.5)))) end
function tmp = code(k, n) t_0 = (2.0 * pi) * n; tmp = sqrt(t_0) * ((k ^ -0.5) / (t_0 ^ (k * 0.5))); end
code[k_, n_] := Block[{t$95$0 = N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision]}, N[(N[Sqrt[t$95$0], $MachinePrecision] * N[(N[Power[k, -0.5], $MachinePrecision] / N[Power[t$95$0, N[(k * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \pi\right) \cdot n\\
\sqrt{t\_0} \cdot \frac{{k}^{-0.5}}{{t\_0}^{\left(k \cdot 0.5\right)}}
\end{array}
\end{array}
Initial program 99.5%
associate-*r*99.5%
div-sub99.5%
metadata-eval99.5%
pow-div99.6%
pow1/299.6%
associate-*r/99.7%
pow1/299.7%
pow-flip99.7%
metadata-eval99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/l*99.7%
associate-*r*99.7%
associate-*r*99.7%
Simplified99.7%
(FPCore (k n) :precision binary64 (let* ((t_0 (* (* 2.0 PI) n))) (/ (sqrt t_0) (* (pow t_0 (* k 0.5)) (sqrt k)))))
double code(double k, double n) {
double t_0 = (2.0 * ((double) M_PI)) * n;
return sqrt(t_0) / (pow(t_0, (k * 0.5)) * sqrt(k));
}
public static double code(double k, double n) {
double t_0 = (2.0 * Math.PI) * n;
return Math.sqrt(t_0) / (Math.pow(t_0, (k * 0.5)) * Math.sqrt(k));
}
def code(k, n): t_0 = (2.0 * math.pi) * n return math.sqrt(t_0) / (math.pow(t_0, (k * 0.5)) * math.sqrt(k))
function code(k, n) t_0 = Float64(Float64(2.0 * pi) * n) return Float64(sqrt(t_0) / Float64((t_0 ^ Float64(k * 0.5)) * sqrt(k))) end
function tmp = code(k, n) t_0 = (2.0 * pi) * n; tmp = sqrt(t_0) / ((t_0 ^ (k * 0.5)) * sqrt(k)); end
code[k_, n_] := Block[{t$95$0 = N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision]}, N[(N[Sqrt[t$95$0], $MachinePrecision] / N[(N[Power[t$95$0, N[(k * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \pi\right) \cdot n\\
\frac{\sqrt{t\_0}}{{t\_0}^{\left(k \cdot 0.5\right)} \cdot \sqrt{k}}
\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.6%
pow1/299.6%
associate-/l/99.6%
div-inv99.6%
metadata-eval99.6%
Applied egg-rr99.6%
associate-*r*99.6%
associate-*r*99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 2.15e-92) (* (sqrt (* PI (/ 2.0 k))) (sqrt n)) (sqrt (/ (pow (* (* 2.0 PI) n) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 2.15e-92) {
tmp = sqrt((((double) M_PI) * (2.0 / k))) * sqrt(n);
} 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 <= 2.15e-92) {
tmp = Math.sqrt((Math.PI * (2.0 / k))) * Math.sqrt(n);
} 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 <= 2.15e-92: tmp = math.sqrt((math.pi * (2.0 / k))) * math.sqrt(n) 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 <= 2.15e-92) tmp = Float64(sqrt(Float64(pi * Float64(2.0 / k))) * sqrt(n)); else tmp = sqrt(Float64((Float64(Float64(2.0 * pi) * n) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.15e-92) tmp = sqrt((pi * (2.0 / k))) * sqrt(n); else tmp = sqrt(((((2.0 * pi) * n) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.15e-92], N[(N[Sqrt[N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.15 \cdot 10^{-92}:\\
\;\;\;\;\sqrt{\pi \cdot \frac{2}{k}} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 2.15000000000000007e-92Initial program 99.3%
Taylor expanded in k around 0 60.4%
*-commutative60.4%
sqrt-prod60.7%
*-commutative60.7%
associate-/l*60.6%
Applied egg-rr60.6%
clear-num60.7%
un-div-inv60.7%
Applied egg-rr60.7%
associate-/r/60.7%
associate-*r*60.7%
*-commutative60.7%
sqrt-prod99.5%
associate-*l/99.5%
associate-/l*99.5%
Applied egg-rr99.5%
if 2.15000000000000007e-92 < k Initial program 99.7%
add-sqr-sqrt99.6%
sqrt-unprod97.3%
*-commutative97.3%
associate-*r*97.3%
div-sub97.3%
metadata-eval97.3%
div-inv97.4%
*-commutative97.4%
Applied egg-rr97.4%
Simplified97.4%
Final simplification98.2%
(FPCore (k n) :precision binary64 (* (pow k -0.5) (pow (* 2.0 (* PI n)) (- 0.5 (* k 0.5)))))
double code(double k, double n) {
return pow(k, -0.5) * pow((2.0 * (((double) M_PI) * n)), (0.5 - (k * 0.5)));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) * Math.pow((2.0 * (Math.PI * n)), (0.5 - (k * 0.5)));
}
def code(k, n): return math.pow(k, -0.5) * math.pow((2.0 * (math.pi * n)), (0.5 - (k * 0.5)))
function code(k, n) return Float64((k ^ -0.5) * (Float64(2.0 * Float64(pi * n)) ^ Float64(0.5 - Float64(k * 0.5)))) end
function tmp = code(k, n) tmp = (k ^ -0.5) * ((2.0 * (pi * n)) ^ (0.5 - (k * 0.5))); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision], N[(0.5 - N[(k * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{k}^{-0.5} \cdot {\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(0.5 - k \cdot 0.5\right)}
\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%
div-inv99.5%
div-inv99.5%
metadata-eval99.5%
pow1/299.5%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 1.06e-18) (* (sqrt (* PI (/ 2.0 k))) (sqrt n)) (sqrt (* (/ 2.0 k) 0.0))))
double code(double k, double n) {
double tmp;
if (k <= 1.06e-18) {
tmp = sqrt((((double) M_PI) * (2.0 / k))) * sqrt(n);
} else {
tmp = sqrt(((2.0 / k) * 0.0));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1.06e-18) {
tmp = Math.sqrt((Math.PI * (2.0 / k))) * Math.sqrt(n);
} else {
tmp = Math.sqrt(((2.0 / k) * 0.0));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 1.06e-18: tmp = math.sqrt((math.pi * (2.0 / k))) * math.sqrt(n) else: tmp = math.sqrt(((2.0 / k) * 0.0)) return tmp
function code(k, n) tmp = 0.0 if (k <= 1.06e-18) tmp = Float64(sqrt(Float64(pi * Float64(2.0 / k))) * sqrt(n)); else tmp = sqrt(Float64(Float64(2.0 / k) * 0.0)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 1.06e-18) tmp = sqrt((pi * (2.0 / k))) * sqrt(n); else tmp = sqrt(((2.0 / k) * 0.0)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.06e-18], N[(N[Sqrt[N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(2.0 / k), $MachinePrecision] * 0.0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.06 \cdot 10^{-18}:\\
\;\;\;\;\sqrt{\pi \cdot \frac{2}{k}} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{2}{k} \cdot 0}\\
\end{array}
\end{array}
if k < 1.05999999999999994e-18Initial program 99.3%
Taylor expanded in k around 0 67.5%
*-commutative67.5%
sqrt-prod67.8%
*-commutative67.8%
associate-/l*67.7%
Applied egg-rr67.7%
clear-num67.7%
un-div-inv67.8%
Applied egg-rr67.8%
associate-/r/67.8%
associate-*r*67.8%
*-commutative67.8%
sqrt-prod99.5%
associate-*l/99.5%
associate-/l*99.5%
Applied egg-rr99.5%
if 1.05999999999999994e-18 < k Initial program 99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
*-commutative99.8%
associate-*r*99.8%
div-sub99.8%
metadata-eval99.8%
div-inv99.8%
*-commutative99.8%
Applied egg-rr99.8%
Simplified99.8%
Taylor expanded in k around 0 5.1%
associate-*r/5.1%
*-commutative5.1%
associate-/l*5.1%
Simplified5.1%
expm1-log1p-u5.1%
expm1-undefine3.7%
*-commutative3.7%
Applied egg-rr3.7%
sub-neg3.7%
metadata-eval3.7%
+-commutative3.7%
log1p-undefine3.7%
rem-exp-log3.7%
+-commutative3.7%
*-commutative3.7%
fma-define3.7%
Simplified3.7%
Taylor expanded in n around 0 50.5%
Final simplification75.2%
(FPCore (k n) :precision binary64 (if (<= k 1.06e-18) (* (sqrt (* 2.0 n)) (sqrt (/ PI k))) (sqrt (* (/ 2.0 k) 0.0))))
double code(double k, double n) {
double tmp;
if (k <= 1.06e-18) {
tmp = sqrt((2.0 * n)) * sqrt((((double) M_PI) / k));
} else {
tmp = sqrt(((2.0 / k) * 0.0));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1.06e-18) {
tmp = Math.sqrt((2.0 * n)) * Math.sqrt((Math.PI / k));
} else {
tmp = Math.sqrt(((2.0 / k) * 0.0));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 1.06e-18: tmp = math.sqrt((2.0 * n)) * math.sqrt((math.pi / k)) else: tmp = math.sqrt(((2.0 / k) * 0.0)) return tmp
function code(k, n) tmp = 0.0 if (k <= 1.06e-18) tmp = Float64(sqrt(Float64(2.0 * n)) * sqrt(Float64(pi / k))); else tmp = sqrt(Float64(Float64(2.0 / k) * 0.0)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 1.06e-18) tmp = sqrt((2.0 * n)) * sqrt((pi / k)); else tmp = sqrt(((2.0 / k) * 0.0)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.06e-18], N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(2.0 / k), $MachinePrecision] * 0.0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.06 \cdot 10^{-18}:\\
\;\;\;\;\sqrt{2 \cdot n} \cdot \sqrt{\frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{2}{k} \cdot 0}\\
\end{array}
\end{array}
if k < 1.05999999999999994e-18Initial program 99.3%
add-sqr-sqrt99.0%
sqrt-unprod67.4%
*-commutative67.4%
associate-*r*67.4%
div-sub67.4%
metadata-eval67.4%
div-inv67.5%
*-commutative67.5%
Applied egg-rr67.6%
Simplified67.8%
Taylor expanded in k around 0 67.8%
associate-/l*67.8%
Simplified67.8%
pow1/267.8%
associate-*r*67.8%
unpow-prod-down99.5%
pow1/299.5%
Applied egg-rr99.5%
unpow1/299.5%
*-commutative99.5%
Simplified99.5%
if 1.05999999999999994e-18 < k Initial program 99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
*-commutative99.8%
associate-*r*99.8%
div-sub99.8%
metadata-eval99.8%
div-inv99.8%
*-commutative99.8%
Applied egg-rr99.8%
Simplified99.8%
Taylor expanded in k around 0 5.1%
associate-*r/5.1%
*-commutative5.1%
associate-/l*5.1%
Simplified5.1%
expm1-log1p-u5.1%
expm1-undefine3.7%
*-commutative3.7%
Applied egg-rr3.7%
sub-neg3.7%
metadata-eval3.7%
+-commutative3.7%
log1p-undefine3.7%
rem-exp-log3.7%
+-commutative3.7%
*-commutative3.7%
fma-define3.7%
Simplified3.7%
Taylor expanded in n around 0 50.5%
Final simplification75.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 3.5) (pow (* k (/ 0.5 (* PI n))) -0.5) (sqrt (* (/ 2.0 k) 0.0))))
double code(double k, double n) {
double tmp;
if (k <= 3.5) {
tmp = pow((k * (0.5 / (((double) M_PI) * n))), -0.5);
} else {
tmp = sqrt(((2.0 / k) * 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.PI * n))), -0.5);
} else {
tmp = Math.sqrt(((2.0 / k) * 0.0));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 3.5: tmp = math.pow((k * (0.5 / (math.pi * n))), -0.5) else: tmp = math.sqrt(((2.0 / k) * 0.0)) return tmp
function code(k, n) tmp = 0.0 if (k <= 3.5) tmp = Float64(k * Float64(0.5 / Float64(pi * n))) ^ -0.5; else tmp = sqrt(Float64(Float64(2.0 / k) * 0.0)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 3.5) tmp = (k * (0.5 / (pi * n))) ^ -0.5; else tmp = sqrt(((2.0 / k) * 0.0)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 3.5], N[Power[N[(k * N[(0.5 / N[(Pi * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision], N[Sqrt[N[(N[(2.0 / k), $MachinePrecision] * 0.0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.5:\\
\;\;\;\;{\left(k \cdot \frac{0.5}{\pi \cdot n}\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{2}{k} \cdot 0}\\
\end{array}
\end{array}
if k < 3.5Initial program 99.1%
Taylor expanded in k around 0 66.9%
*-commutative66.9%
sqrt-prod67.1%
*-commutative67.1%
associate-/l*67.1%
Applied egg-rr67.1%
clear-num67.1%
un-div-inv67.2%
Applied egg-rr67.2%
associate-/r/67.1%
associate-*r*67.1%
*-commutative67.1%
sqrt-prod97.5%
associate-*l/97.5%
associate-/l*97.5%
Applied egg-rr97.5%
*-commutative97.5%
associate-/r/97.5%
Applied egg-rr97.5%
*-commutative97.5%
sqrt-prod67.1%
associate-/r/67.1%
*-commutative67.1%
remove-double-div67.1%
inv-pow67.1%
sqrt-pow167.1%
associate-*r*67.1%
*-commutative67.1%
associate-/r*68.3%
clear-num68.4%
div-inv68.4%
metadata-eval68.4%
*-commutative68.4%
metadata-eval68.4%
Applied egg-rr68.4%
associate-/l*68.4%
*-commutative68.4%
Simplified68.4%
if 3.5 < k Initial program 100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
*-commutative100.0%
associate-*r*100.0%
div-sub100.0%
metadata-eval100.0%
div-inv100.0%
*-commutative100.0%
Applied egg-rr100.0%
Simplified100.0%
Taylor expanded in k around 0 2.7%
associate-*r/2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
expm1-log1p-u2.7%
expm1-undefine2.4%
*-commutative2.4%
Applied egg-rr2.4%
sub-neg2.4%
metadata-eval2.4%
+-commutative2.4%
log1p-undefine2.4%
rem-exp-log2.4%
+-commutative2.4%
*-commutative2.4%
fma-define2.4%
Simplified2.4%
Taylor expanded in n around 0 52.8%
Final simplification61.0%
(FPCore (k n) :precision binary64 (if (<= k 1.06e-18) (sqrt (* 2.0 (/ PI (/ k n)))) (sqrt (* (/ 2.0 k) 0.0))))
double code(double k, double n) {
double tmp;
if (k <= 1.06e-18) {
tmp = sqrt((2.0 * (((double) M_PI) / (k / n))));
} else {
tmp = sqrt(((2.0 / k) * 0.0));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1.06e-18) {
tmp = Math.sqrt((2.0 * (Math.PI / (k / n))));
} else {
tmp = Math.sqrt(((2.0 / k) * 0.0));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 1.06e-18: tmp = math.sqrt((2.0 * (math.pi / (k / n)))) else: tmp = math.sqrt(((2.0 / k) * 0.0)) return tmp
function code(k, n) tmp = 0.0 if (k <= 1.06e-18) tmp = sqrt(Float64(2.0 * Float64(pi / Float64(k / n)))); else tmp = sqrt(Float64(Float64(2.0 / k) * 0.0)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 1.06e-18) tmp = sqrt((2.0 * (pi / (k / n)))); else tmp = sqrt(((2.0 / k) * 0.0)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.06e-18], N[Sqrt[N[(2.0 * N[(Pi / N[(k / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(2.0 / k), $MachinePrecision] * 0.0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.06 \cdot 10^{-18}:\\
\;\;\;\;\sqrt{2 \cdot \frac{\pi}{\frac{k}{n}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{2}{k} \cdot 0}\\
\end{array}
\end{array}
if k < 1.05999999999999994e-18Initial program 99.3%
Taylor expanded in k around 0 67.5%
*-commutative67.5%
sqrt-prod67.8%
*-commutative67.8%
associate-/l*67.7%
Applied egg-rr67.7%
clear-num67.7%
un-div-inv67.8%
Applied egg-rr67.8%
if 1.05999999999999994e-18 < k Initial program 99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
*-commutative99.8%
associate-*r*99.8%
div-sub99.8%
metadata-eval99.8%
div-inv99.8%
*-commutative99.8%
Applied egg-rr99.8%
Simplified99.8%
Taylor expanded in k around 0 5.1%
associate-*r/5.1%
*-commutative5.1%
associate-/l*5.1%
Simplified5.1%
expm1-log1p-u5.1%
expm1-undefine3.7%
*-commutative3.7%
Applied egg-rr3.7%
sub-neg3.7%
metadata-eval3.7%
+-commutative3.7%
log1p-undefine3.7%
rem-exp-log3.7%
+-commutative3.7%
*-commutative3.7%
fma-define3.7%
Simplified3.7%
Taylor expanded in n around 0 50.5%
Final simplification59.2%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (/ PI (/ k n)))))
double code(double k, double n) {
return sqrt((2.0 * (((double) M_PI) / (k / n))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (Math.PI / (k / n))));
}
def code(k, n): return math.sqrt((2.0 * (math.pi / (k / n))))
function code(k, n) return sqrt(Float64(2.0 * Float64(pi / Float64(k / n)))) end
function tmp = code(k, n) tmp = sqrt((2.0 * (pi / (k / n)))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(Pi / N[(k / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \frac{\pi}{\frac{k}{n}}}
\end{array}
Initial program 99.5%
Taylor expanded in k around 0 36.5%
*-commutative36.5%
sqrt-prod36.7%
*-commutative36.7%
associate-/l*36.6%
Applied egg-rr36.6%
clear-num36.6%
un-div-inv36.7%
Applied egg-rr36.7%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (* n (/ PI k)))))
double code(double k, double n) {
return sqrt((2.0 * (n * (((double) M_PI) / k))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (n * (Math.PI / k))));
}
def code(k, n): return math.sqrt((2.0 * (n * (math.pi / k))))
function code(k, n) return sqrt(Float64(2.0 * Float64(n * Float64(pi / k)))) end
function tmp = code(k, n) tmp = sqrt((2.0 * (n * (pi / k)))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(n * N[(Pi / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \left(n \cdot \frac{\pi}{k}\right)}
\end{array}
Initial program 99.5%
add-sqr-sqrt99.4%
sqrt-unprod83.5%
*-commutative83.5%
associate-*r*83.5%
div-sub83.5%
metadata-eval83.5%
div-inv83.5%
*-commutative83.5%
Applied egg-rr83.6%
Simplified83.7%
Taylor expanded in k around 0 36.7%
associate-/l*36.7%
Simplified36.7%
herbie shell --seed 2024105
(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))))