
(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 12 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 (* n (* 2.0 PI)))) (* (pow k -0.5) (pow (/ t_0 (pow t_0 k)) 0.5))))
double code(double k, double n) {
double t_0 = n * (2.0 * ((double) M_PI));
return pow(k, -0.5) * pow((t_0 / pow(t_0, k)), 0.5);
}
public static double code(double k, double n) {
double t_0 = n * (2.0 * Math.PI);
return Math.pow(k, -0.5) * Math.pow((t_0 / Math.pow(t_0, k)), 0.5);
}
def code(k, n): t_0 = n * (2.0 * math.pi) return math.pow(k, -0.5) * math.pow((t_0 / math.pow(t_0, k)), 0.5)
function code(k, n) t_0 = Float64(n * Float64(2.0 * pi)) return Float64((k ^ -0.5) * (Float64(t_0 / (t_0 ^ k)) ^ 0.5)) end
function tmp = code(k, n) t_0 = n * (2.0 * pi); tmp = (k ^ -0.5) * ((t_0 / (t_0 ^ k)) ^ 0.5); end
code[k_, n_] := Block[{t$95$0 = N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(t$95$0 / N[Power[t$95$0, k], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(2 \cdot \pi\right)\\
{k}^{-0.5} \cdot {\left(\frac{t\_0}{{t\_0}^{k}}\right)}^{0.5}
\end{array}
\end{array}
Initial program 99.6%
associate-*r*99.6%
div-sub99.6%
metadata-eval99.6%
pow-div81.7%
pow1/281.7%
associate-*r/81.7%
pow1/281.7%
pow-flip81.8%
metadata-eval81.8%
div-inv81.8%
metadata-eval81.8%
Applied egg-rr81.8%
associate-/l*81.8%
*-rgt-identity81.8%
associate-*l*81.8%
*-lft-identity81.8%
remove-double-neg81.8%
distribute-neg-frac81.8%
distribute-neg-frac81.8%
remove-double-neg81.8%
*-commutative81.8%
*-commutative81.8%
Simplified81.8%
pow1/281.8%
*-commutative81.8%
metadata-eval81.8%
div-inv81.8%
*-commutative81.8%
pow-sub99.6%
metadata-eval99.6%
div-sub99.6%
div-inv99.6%
metadata-eval99.6%
pow-unpow99.6%
associate-*r*99.6%
*-commutative99.6%
Applied egg-rr99.6%
pow-sub99.7%
pow199.7%
Applied egg-rr99.7%
(FPCore (k n) :precision binary64 (if (<= k 6.4e-49) (/ (sqrt (* n (* 2.0 PI))) (sqrt k)) (sqrt (/ (pow (* 2.0 (* n PI)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 6.4e-49) {
tmp = sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
} else {
tmp = sqrt((pow((2.0 * (n * ((double) M_PI))), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 6.4e-49) {
tmp = Math.sqrt((n * (2.0 * Math.PI))) / Math.sqrt(k);
} else {
tmp = Math.sqrt((Math.pow((2.0 * (n * Math.PI)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 6.4e-49: tmp = math.sqrt((n * (2.0 * math.pi))) / math.sqrt(k) else: tmp = math.sqrt((math.pow((2.0 * (n * math.pi)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 6.4e-49) tmp = Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k)); else tmp = sqrt(Float64((Float64(2.0 * Float64(n * pi)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 6.4e-49) tmp = sqrt((n * (2.0 * pi))) / sqrt(k); else tmp = sqrt((((2.0 * (n * pi)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 6.4e-49], N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(2.0 * N[(n * Pi), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 6.4 \cdot 10^{-49}:\\
\;\;\;\;\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 6.40000000000000005e-49Initial program 99.2%
Taylor expanded in k around 0 66.4%
associate-/l*66.4%
Simplified66.4%
sqrt-unprod66.7%
Applied egg-rr66.7%
associate-*r/66.6%
*-commutative66.6%
Applied egg-rr66.6%
associate-*l/66.6%
sqrt-div99.5%
*-commutative99.5%
associate-*r*99.5%
*-commutative99.5%
Applied egg-rr99.5%
*-commutative99.5%
Simplified99.5%
if 6.40000000000000005e-49 < k Initial program 99.8%
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 8e+86) (/ (sqrt (* n (* 2.0 PI))) (sqrt k)) (sqrt (+ 1.0 (fma (* 2.0 PI) (/ n k) -1.0)))))
double code(double k, double n) {
double tmp;
if (k <= 8e+86) {
tmp = sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
} else {
tmp = sqrt((1.0 + fma((2.0 * ((double) M_PI)), (n / k), -1.0)));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 8e+86) tmp = Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k)); else tmp = sqrt(Float64(1.0 + fma(Float64(2.0 * pi), Float64(n / k), -1.0))); end return tmp end
code[k_, n_] := If[LessEqual[k, 8e+86], N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(1.0 + N[(N[(2.0 * Pi), $MachinePrecision] * N[(n / k), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 8 \cdot 10^{+86}:\\
\;\;\;\;\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 + \mathsf{fma}\left(2 \cdot \pi, \frac{n}{k}, -1\right)}\\
\end{array}
\end{array}
if k < 8.0000000000000001e86Initial program 99.2%
Taylor expanded in k around 0 52.0%
associate-/l*52.0%
Simplified52.0%
sqrt-unprod52.2%
Applied egg-rr52.2%
associate-*r/52.2%
*-commutative52.2%
Applied egg-rr52.2%
associate-*l/52.2%
sqrt-div74.7%
*-commutative74.7%
associate-*r*74.7%
*-commutative74.7%
Applied egg-rr74.7%
*-commutative74.7%
Simplified74.7%
if 8.0000000000000001e86 < k Initial program 100.0%
Taylor expanded in k around 0 1.9%
associate-/l*1.9%
Simplified1.9%
sqrt-unprod1.9%
Applied egg-rr1.9%
associate-*r/1.9%
*-commutative1.9%
Applied egg-rr1.9%
expm1-log1p-u1.9%
expm1-undefine40.6%
*-commutative40.6%
associate-*r/40.6%
associate-*l*40.6%
*-commutative40.6%
associate-*r/40.6%
Applied egg-rr40.6%
log1p-undefine40.6%
rem-exp-log40.6%
associate-+r-40.6%
*-commutative40.6%
associate-*l/40.6%
associate-/l*40.6%
fmm-def40.6%
*-commutative40.6%
metadata-eval40.6%
Simplified40.6%
Final simplification56.6%
(FPCore (k n) :precision binary64 (/ (pow (* 2.0 (* n PI)) (- 0.5 (/ k 2.0))) (sqrt k)))
double code(double k, double n) {
return pow((2.0 * (n * ((double) M_PI))), (0.5 - (k / 2.0))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow((2.0 * (n * Math.PI)), (0.5 - (k / 2.0))) / Math.sqrt(k);
}
def code(k, n): return math.pow((2.0 * (n * math.pi)), (0.5 - (k / 2.0))) / math.sqrt(k)
function code(k, n) return Float64((Float64(2.0 * Float64(n * pi)) ^ Float64(0.5 - Float64(k / 2.0))) / sqrt(k)) end
function tmp = code(k, n) tmp = ((2.0 * (n * pi)) ^ (0.5 - (k / 2.0))) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(2.0 * N[(n * Pi), $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(n \cdot \pi\right)\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.6%
associate-*l/99.7%
*-lft-identity99.7%
associate-*l*99.7%
div-sub99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (/ (sqrt (* n (* 2.0 PI))) (sqrt k)))
double code(double k, double n) {
return sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.sqrt((n * (2.0 * Math.PI))) / Math.sqrt(k);
}
def code(k, n): return math.sqrt((n * (2.0 * math.pi))) / math.sqrt(k)
function code(k, n) return Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k)) end
function tmp = code(k, n) tmp = sqrt((n * (2.0 * pi))) / sqrt(k); end
code[k_, n_] := N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0 25.4%
associate-/l*25.4%
Simplified25.4%
sqrt-unprod25.5%
Applied egg-rr25.5%
associate-*r/25.5%
*-commutative25.5%
Applied egg-rr25.5%
associate-*l/25.5%
sqrt-div36.0%
*-commutative36.0%
associate-*r*36.0%
*-commutative36.0%
Applied egg-rr36.0%
*-commutative36.0%
Simplified36.0%
Final simplification36.0%
(FPCore (k n) :precision binary64 (* (sqrt n) (sqrt (/ (* 2.0 PI) k))))
double code(double k, double n) {
return sqrt(n) * sqrt(((2.0 * ((double) M_PI)) / k));
}
public static double code(double k, double n) {
return Math.sqrt(n) * Math.sqrt(((2.0 * Math.PI) / k));
}
def code(k, n): return math.sqrt(n) * math.sqrt(((2.0 * math.pi) / k))
function code(k, n) return Float64(sqrt(n) * sqrt(Float64(Float64(2.0 * pi) / k))) end
function tmp = code(k, n) tmp = sqrt(n) * sqrt(((2.0 * pi) / k)); end
code[k_, n_] := N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(N[(2.0 * Pi), $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{n} \cdot \sqrt{\frac{2 \cdot \pi}{k}}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0 25.4%
associate-/l*25.4%
Simplified25.4%
sqrt-unprod25.5%
Applied egg-rr25.5%
pow1/225.5%
associate-*l*25.5%
unpow-prod-down36.0%
pow1/236.0%
Applied egg-rr36.0%
unpow1/236.0%
associate-*l/36.0%
*-commutative36.0%
Simplified36.0%
(FPCore (k n) :precision binary64 (* (sqrt n) (sqrt (* PI (/ 2.0 k)))))
double code(double k, double n) {
return sqrt(n) * sqrt((((double) M_PI) * (2.0 / k)));
}
public static double code(double k, double n) {
return Math.sqrt(n) * Math.sqrt((Math.PI * (2.0 / k)));
}
def code(k, n): return math.sqrt(n) * math.sqrt((math.pi * (2.0 / k)))
function code(k, n) return Float64(sqrt(n) * sqrt(Float64(pi * Float64(2.0 / k)))) end
function tmp = code(k, n) tmp = sqrt(n) * sqrt((pi * (2.0 / k))); end
code[k_, n_] := N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{n} \cdot \sqrt{\pi \cdot \frac{2}{k}}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0 25.4%
associate-/l*25.4%
Simplified25.4%
sqrt-unprod25.5%
Applied egg-rr25.5%
associate-*r/25.5%
*-commutative25.5%
Applied egg-rr25.5%
sqrt-prod25.4%
*-commutative25.4%
associate-*r/25.4%
sqrt-prod25.5%
associate-*r*25.5%
*-commutative25.5%
sqrt-prod36.0%
associate-*l/36.0%
*-commutative36.0%
Applied egg-rr36.0%
*-commutative36.0%
*-commutative36.0%
associate-/l*36.0%
Simplified36.0%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (fabs (* n (/ PI k))))))
double code(double k, double n) {
return sqrt((2.0 * fabs((n * (((double) M_PI) / k)))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * Math.abs((n * (Math.PI / k)))));
}
def code(k, n): return math.sqrt((2.0 * math.fabs((n * (math.pi / k)))))
function code(k, n) return sqrt(Float64(2.0 * abs(Float64(n * Float64(pi / k))))) end
function tmp = code(k, n) tmp = sqrt((2.0 * abs((n * (pi / k))))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[Abs[N[(n * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \left|n \cdot \frac{\pi}{k}\right|}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0 25.4%
associate-/l*25.4%
Simplified25.4%
sqrt-unprod25.5%
Applied egg-rr25.5%
add-sqr-sqrt25.4%
pow1/225.4%
pow1/225.4%
pow-prod-down25.7%
pow225.7%
Applied egg-rr25.7%
unpow1/225.7%
unpow225.7%
rem-sqrt-square26.1%
Simplified26.1%
Final simplification26.1%
(FPCore (k n) :precision binary64 (sqrt (fabs (* (* n PI) (/ 2.0 k)))))
double code(double k, double n) {
return sqrt(fabs(((n * ((double) M_PI)) * (2.0 / k))));
}
public static double code(double k, double n) {
return Math.sqrt(Math.abs(((n * Math.PI) * (2.0 / k))));
}
def code(k, n): return math.sqrt(math.fabs(((n * math.pi) * (2.0 / k))))
function code(k, n) return sqrt(abs(Float64(Float64(n * pi) * Float64(2.0 / k)))) end
function tmp = code(k, n) tmp = sqrt(abs(((n * pi) * (2.0 / k)))); end
code[k_, n_] := N[Sqrt[N[Abs[N[(N[(n * Pi), $MachinePrecision] * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left|\left(n \cdot \pi\right) \cdot \frac{2}{k}\right|}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0 25.4%
associate-/l*25.4%
Simplified25.4%
sqrt-unprod25.5%
Applied egg-rr25.5%
associate-*r/25.5%
*-commutative25.5%
Applied egg-rr25.5%
*-commutative25.5%
associate-*r/25.5%
pow125.5%
associate-*r*25.5%
metadata-eval25.5%
pow-sqr25.5%
pow-prod-down25.7%
Applied egg-rr25.7%
unpow1/225.7%
*-commutative25.7%
metadata-eval25.7%
unpow225.7%
swap-sqr25.7%
associate-*r/25.7%
associate-*r/25.7%
associate-*r*25.7%
*-commutative25.7%
associate-*r*25.7%
associate-*r/25.7%
associate-*r/25.7%
associate-*r/25.7%
associate-*r*25.7%
*-commutative25.7%
associate-*r*25.7%
associate-*r/25.7%
Simplified26.0%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (* n (* PI (/ 1.0 k))))))
double code(double k, double n) {
return sqrt((2.0 * (n * (((double) M_PI) * (1.0 / k)))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (n * (Math.PI * (1.0 / k)))));
}
def code(k, n): return math.sqrt((2.0 * (n * (math.pi * (1.0 / k)))))
function code(k, n) return sqrt(Float64(2.0 * Float64(n * Float64(pi * Float64(1.0 / k))))) end
function tmp = code(k, n) tmp = sqrt((2.0 * (n * (pi * (1.0 / k))))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(n * N[(Pi * N[(1.0 / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \left(n \cdot \left(\pi \cdot \frac{1}{k}\right)\right)}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0 25.4%
associate-/l*25.4%
Simplified25.4%
sqrt-unprod25.5%
Applied egg-rr25.5%
div-inv25.5%
Applied egg-rr25.5%
Final simplification25.5%
(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.6%
Taylor expanded in k around 0 25.4%
associate-/l*25.4%
Simplified25.4%
sqrt-unprod25.5%
Applied egg-rr25.5%
Final simplification25.5%
(FPCore (k n) :precision binary64 (sqrt (* (* n PI) (/ 2.0 k))))
double code(double k, double n) {
return sqrt(((n * ((double) M_PI)) * (2.0 / k)));
}
public static double code(double k, double n) {
return Math.sqrt(((n * Math.PI) * (2.0 / k)));
}
def code(k, n): return math.sqrt(((n * math.pi) * (2.0 / k)))
function code(k, n) return sqrt(Float64(Float64(n * pi) * Float64(2.0 / k))) end
function tmp = code(k, n) tmp = sqrt(((n * pi) * (2.0 / k))); end
code[k_, n_] := N[Sqrt[N[(N[(n * Pi), $MachinePrecision] * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left(n \cdot \pi\right) \cdot \frac{2}{k}}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0 25.4%
associate-/l*25.4%
Simplified25.4%
sqrt-unprod25.5%
Applied egg-rr25.5%
associate-*r/25.5%
*-commutative25.5%
Applied egg-rr25.5%
Taylor expanded in n around 0 25.5%
associate-*r/25.5%
*-commutative25.5%
associate-/l*25.5%
Simplified25.5%
herbie shell --seed 2024180
(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))))