
(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 14 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 1.35e-22) (/ (sqrt (* PI (* 2.0 n))) (sqrt k)) (sqrt (/ (pow (* 2.0 (* PI n)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 1.35e-22) {
tmp = sqrt((((double) M_PI) * (2.0 * n))) / sqrt(k);
} 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 <= 1.35e-22) {
tmp = Math.sqrt((Math.PI * (2.0 * n))) / Math.sqrt(k);
} 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 <= 1.35e-22: tmp = math.sqrt((math.pi * (2.0 * n))) / math.sqrt(k) 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 <= 1.35e-22) tmp = Float64(sqrt(Float64(pi * Float64(2.0 * n))) / sqrt(k)); 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 <= 1.35e-22) tmp = sqrt((pi * (2.0 * n))) / sqrt(k); else tmp = sqrt((((2.0 * (pi * n)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.35e-22], N[(N[Sqrt[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $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 1.35 \cdot 10^{-22}:\\
\;\;\;\;\frac{\sqrt{\pi \cdot \left(2 \cdot n\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 1.3500000000000001e-22Initial program 99.5%
Applied egg-rr82.9%
distribute-lft-in82.9%
metadata-eval82.9%
*-commutative82.9%
associate-*r*82.9%
metadata-eval82.9%
neg-mul-182.9%
sub-neg82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in k around 0 82.9%
*-commutative82.9%
associate-/l*82.9%
Simplified82.9%
*-commutative82.9%
*-commutative82.9%
associate-*r/82.9%
*-commutative82.9%
associate-*r/82.9%
sqrt-div99.6%
*-commutative99.6%
Applied egg-rr99.6%
*-commutative99.6%
associate-*l*99.6%
Simplified99.6%
if 1.3500000000000001e-22 < k Initial program 99.9%
Applied egg-rr100.0%
distribute-lft-in100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (k n) :precision binary64 (if (<= k 2.4e-56) (/ (sqrt (* PI (* 2.0 n))) (sqrt k)) (sqrt (* n (+ -1.0 (fma PI (/ 2.0 k) 1.0))))))
double code(double k, double n) {
double tmp;
if (k <= 2.4e-56) {
tmp = sqrt((((double) M_PI) * (2.0 * n))) / sqrt(k);
} else {
tmp = sqrt((n * (-1.0 + fma(((double) M_PI), (2.0 / k), 1.0))));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 2.4e-56) tmp = Float64(sqrt(Float64(pi * Float64(2.0 * n))) / sqrt(k)); else tmp = sqrt(Float64(n * Float64(-1.0 + fma(pi, Float64(2.0 / k), 1.0)))); end return tmp end
code[k_, n_] := If[LessEqual[k, 2.4e-56], N[(N[Sqrt[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(n * N[(-1.0 + N[(Pi * N[(2.0 / k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.4 \cdot 10^{-56}:\\
\;\;\;\;\frac{\sqrt{\pi \cdot \left(2 \cdot n\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{n \cdot \left(-1 + \mathsf{fma}\left(\pi, \frac{2}{k}, 1\right)\right)}\\
\end{array}
\end{array}
if k < 2.40000000000000001e-56Initial program 99.5%
Applied egg-rr81.4%
distribute-lft-in81.4%
metadata-eval81.4%
*-commutative81.4%
associate-*r*81.4%
metadata-eval81.4%
neg-mul-181.4%
sub-neg81.4%
*-commutative81.4%
Simplified81.4%
Taylor expanded in k around 0 81.4%
*-commutative81.4%
associate-/l*81.4%
Simplified81.4%
*-commutative81.4%
*-commutative81.4%
associate-*r/81.4%
*-commutative81.4%
associate-*r/81.4%
sqrt-div99.6%
*-commutative99.6%
Applied egg-rr99.6%
*-commutative99.6%
associate-*l*99.6%
Simplified99.6%
if 2.40000000000000001e-56 < k Initial program 99.9%
Applied egg-rr99.9%
distribute-lft-in99.9%
metadata-eval99.9%
*-commutative99.9%
associate-*r*99.9%
metadata-eval99.9%
neg-mul-199.9%
sub-neg99.9%
*-commutative99.9%
Simplified99.9%
pow-sub99.4%
pow199.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
Applied egg-rr99.4%
associate-/l*99.4%
associate-*l*99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in k around 0 9.2%
associate-*l/9.2%
associate-/r/9.2%
associate-*r/9.2%
associate-*l/9.2%
*-commutative9.2%
Simplified9.2%
div-inv9.2%
clear-num9.2%
expm1-log1p-u8.8%
expm1-undefine67.5%
*-commutative67.5%
associate-*l/67.5%
Applied egg-rr67.5%
sub-neg67.5%
metadata-eval67.5%
+-commutative67.5%
log1p-undefine67.5%
rem-exp-log67.9%
+-commutative67.9%
associate-*r/67.9%
fma-define67.9%
Simplified67.9%
Final simplification78.7%
(FPCore (k n) :precision binary64 (if (<= k 1.45e+226) (/ (sqrt (* PI (* 2.0 n))) (sqrt k)) (cbrt (pow (* 2.0 (* n (/ PI k))) 1.5))))
double code(double k, double n) {
double tmp;
if (k <= 1.45e+226) {
tmp = sqrt((((double) M_PI) * (2.0 * n))) / sqrt(k);
} else {
tmp = cbrt(pow((2.0 * (n * (((double) M_PI) / k))), 1.5));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1.45e+226) {
tmp = Math.sqrt((Math.PI * (2.0 * n))) / Math.sqrt(k);
} else {
tmp = Math.cbrt(Math.pow((2.0 * (n * (Math.PI / k))), 1.5));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 1.45e+226) tmp = Float64(sqrt(Float64(pi * Float64(2.0 * n))) / sqrt(k)); else tmp = cbrt((Float64(2.0 * Float64(n * Float64(pi / k))) ^ 1.5)); end return tmp end
code[k_, n_] := If[LessEqual[k, 1.45e+226], N[(N[Sqrt[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(2.0 * N[(n * N[(Pi / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.45 \cdot 10^{+226}:\\
\;\;\;\;\frac{\sqrt{\pi \cdot \left(2 \cdot n\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(2 \cdot \left(n \cdot \frac{\pi}{k}\right)\right)}^{1.5}}\\
\end{array}
\end{array}
if k < 1.44999999999999987e226Initial program 99.7%
Applied egg-rr92.0%
distribute-lft-in92.0%
metadata-eval92.0%
*-commutative92.0%
associate-*r*92.0%
metadata-eval92.0%
neg-mul-192.0%
sub-neg92.0%
*-commutative92.0%
Simplified92.0%
Taylor expanded in k around 0 41.8%
*-commutative41.8%
associate-/l*41.8%
Simplified41.8%
*-commutative41.8%
*-commutative41.8%
associate-*r/41.8%
*-commutative41.8%
associate-*r/41.8%
sqrt-div49.6%
*-commutative49.6%
Applied egg-rr49.6%
*-commutative49.6%
associate-*l*49.6%
Simplified49.6%
if 1.44999999999999987e226 < k Initial program 100.0%
Applied egg-rr100.0%
distribute-lft-in100.0%
metadata-eval100.0%
*-commutative100.0%
associate-*r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 2.0%
*-commutative2.0%
associate-/l*2.0%
Simplified2.0%
*-commutative2.0%
associate-*r/2.0%
*-commutative2.0%
associate-*r/2.0%
add-cbrt-cube11.1%
pow1/311.1%
Applied egg-rr11.1%
unpow1/311.1%
associate-*r/11.1%
associate-*l/11.1%
*-commutative11.1%
Simplified11.1%
Final simplification41.8%
(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.8%
associate-*l/99.8%
*-lft-identity99.8%
associate-*l*99.8%
div-sub99.8%
metadata-eval99.8%
Simplified99.8%
(FPCore (k n) :precision binary64 (/ (sqrt (* PI (* 2.0 n))) (sqrt k)))
double code(double k, double n) {
return sqrt((((double) M_PI) * (2.0 * n))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI * (2.0 * n))) / Math.sqrt(k);
}
def code(k, n): return math.sqrt((math.pi * (2.0 * n))) / math.sqrt(k)
function code(k, n) return Float64(sqrt(Float64(pi * Float64(2.0 * n))) / sqrt(k)) end
function tmp = code(k, n) tmp = sqrt((pi * (2.0 * n))) / sqrt(k); end
code[k_, n_] := N[(N[Sqrt[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{\pi \cdot \left(2 \cdot n\right)}}{\sqrt{k}}
\end{array}
Initial program 99.8%
Applied egg-rr93.6%
distribute-lft-in93.6%
metadata-eval93.6%
*-commutative93.6%
associate-*r*93.6%
metadata-eval93.6%
neg-mul-193.6%
sub-neg93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in k around 0 33.7%
*-commutative33.7%
associate-/l*33.7%
Simplified33.7%
*-commutative33.7%
*-commutative33.7%
associate-*r/33.7%
*-commutative33.7%
associate-*r/33.7%
sqrt-div40.0%
*-commutative40.0%
Applied egg-rr40.0%
*-commutative40.0%
associate-*l*40.0%
Simplified40.0%
Final simplification40.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(2.0 * Float64(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[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{n} \cdot \sqrt{2 \cdot \frac{\pi}{k}}
\end{array}
Initial program 99.8%
Applied egg-rr93.6%
distribute-lft-in93.6%
metadata-eval93.6%
*-commutative93.6%
associate-*r*93.6%
metadata-eval93.6%
neg-mul-193.6%
sub-neg93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in k around 0 33.7%
*-commutative33.7%
associate-/l*33.7%
Simplified33.7%
pow1/233.7%
*-commutative33.7%
associate-*r/33.7%
*-commutative33.7%
associate-*r/33.7%
associate-*l*33.7%
unpow-prod-down40.0%
pow1/240.0%
*-commutative40.0%
Applied egg-rr40.0%
unpow1/240.0%
Simplified40.0%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (fabs (* PI (/ n k))))))
double code(double k, double n) {
return sqrt((2.0 * fabs((((double) M_PI) * (n / k)))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * Math.abs((Math.PI * (n / k)))));
}
def code(k, n): return math.sqrt((2.0 * math.fabs((math.pi * (n / k)))))
function code(k, n) return sqrt(Float64(2.0 * abs(Float64(pi * Float64(n / k))))) end
function tmp = code(k, n) tmp = sqrt((2.0 * abs((pi * (n / k))))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[Abs[N[(Pi * N[(n / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \left|\pi \cdot \frac{n}{k}\right|}
\end{array}
Initial program 99.8%
Taylor expanded in k around 0 33.6%
associate-/l*33.6%
Simplified33.6%
sqrt-unprod33.7%
Applied egg-rr33.7%
add-sqr-sqrt33.6%
pow1/233.6%
pow1/233.6%
pow-prod-down30.0%
pow230.0%
Applied egg-rr30.0%
unpow1/230.0%
unpow230.0%
rem-sqrt-square34.4%
associate-*r/34.4%
*-commutative34.4%
associate-/l*34.4%
Simplified34.4%
Final simplification34.4%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (/ (fabs (* PI n)) k))))
double code(double k, double n) {
return sqrt((2.0 * (fabs((((double) M_PI) * n)) / k)));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (Math.abs((Math.PI * n)) / k)));
}
def code(k, n): return math.sqrt((2.0 * (math.fabs((math.pi * n)) / k)))
function code(k, n) return sqrt(Float64(2.0 * Float64(abs(Float64(pi * n)) / k))) end
function tmp = code(k, n) tmp = sqrt((2.0 * (abs((pi * n)) / k))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(N[Abs[N[(Pi * n), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \frac{\left|\pi \cdot n\right|}{k}}
\end{array}
Initial program 99.8%
Applied egg-rr93.6%
distribute-lft-in93.6%
metadata-eval93.6%
*-commutative93.6%
associate-*r*93.6%
metadata-eval93.6%
neg-mul-193.6%
sub-neg93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in k around 0 33.7%
*-commutative33.7%
add-sqr-sqrt33.6%
sqrt-unprod21.1%
pow221.1%
Applied egg-rr21.1%
unpow221.1%
rem-sqrt-square34.4%
*-commutative34.4%
Simplified34.4%
Final simplification34.4%
(FPCore (k n) :precision binary64 (sqrt (fabs (/ (* 2.0 n) (/ k PI)))))
double code(double k, double n) {
return sqrt(fabs(((2.0 * n) / (k / ((double) M_PI)))));
}
public static double code(double k, double n) {
return Math.sqrt(Math.abs(((2.0 * n) / (k / Math.PI))));
}
def code(k, n): return math.sqrt(math.fabs(((2.0 * n) / (k / math.pi))))
function code(k, n) return sqrt(abs(Float64(Float64(2.0 * n) / Float64(k / pi)))) end
function tmp = code(k, n) tmp = sqrt(abs(((2.0 * n) / (k / pi)))); end
code[k_, n_] := N[Sqrt[N[Abs[N[(N[(2.0 * n), $MachinePrecision] / N[(k / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left|\frac{2 \cdot n}{\frac{k}{\pi}}\right|}
\end{array}
Initial program 99.8%
Applied egg-rr93.6%
distribute-lft-in93.6%
metadata-eval93.6%
*-commutative93.6%
associate-*r*93.6%
metadata-eval93.6%
neg-mul-193.6%
sub-neg93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in k around 0 33.7%
*-commutative33.7%
associate-/l*33.7%
Simplified33.7%
pow133.7%
metadata-eval33.7%
pow-prod-up33.7%
pow-prod-down29.9%
pow229.9%
Applied egg-rr29.9%
unpow1/229.9%
unpow229.9%
rem-sqrt-square34.4%
associate-*r*34.4%
*-commutative34.4%
*-commutative34.4%
associate-*l*34.4%
associate-/r/34.4%
associate-*l/34.4%
*-commutative34.4%
associate-*l/34.4%
*-commutative34.4%
Simplified34.4%
associate-*r/34.4%
Applied egg-rr34.4%
Final simplification34.4%
(FPCore (k n) :precision binary64 (sqrt (fabs (* n (/ 2.0 (/ k PI))))))
double code(double k, double n) {
return sqrt(fabs((n * (2.0 / (k / ((double) M_PI))))));
}
public static double code(double k, double n) {
return Math.sqrt(Math.abs((n * (2.0 / (k / Math.PI)))));
}
def code(k, n): return math.sqrt(math.fabs((n * (2.0 / (k / math.pi)))))
function code(k, n) return sqrt(abs(Float64(n * Float64(2.0 / Float64(k / pi))))) end
function tmp = code(k, n) tmp = sqrt(abs((n * (2.0 / (k / pi))))); end
code[k_, n_] := N[Sqrt[N[Abs[N[(n * N[(2.0 / N[(k / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left|n \cdot \frac{2}{\frac{k}{\pi}}\right|}
\end{array}
Initial program 99.8%
Applied egg-rr93.6%
distribute-lft-in93.6%
metadata-eval93.6%
*-commutative93.6%
associate-*r*93.6%
metadata-eval93.6%
neg-mul-193.6%
sub-neg93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in k around 0 33.7%
*-commutative33.7%
associate-/l*33.7%
Simplified33.7%
pow133.7%
metadata-eval33.7%
pow-prod-up33.7%
pow-prod-down29.9%
pow229.9%
Applied egg-rr29.9%
unpow1/229.9%
unpow229.9%
rem-sqrt-square34.4%
associate-*r*34.4%
*-commutative34.4%
*-commutative34.4%
associate-*l*34.4%
associate-/r/34.4%
associate-*l/34.4%
*-commutative34.4%
associate-*l/34.4%
*-commutative34.4%
Simplified34.4%
(FPCore (k n) :precision binary64 (/ 1.0 (sqrt (/ k (* PI (* 2.0 n))))))
double code(double k, double n) {
return 1.0 / sqrt((k / (((double) M_PI) * (2.0 * n))));
}
public static double code(double k, double n) {
return 1.0 / Math.sqrt((k / (Math.PI * (2.0 * n))));
}
def code(k, n): return 1.0 / math.sqrt((k / (math.pi * (2.0 * n))))
function code(k, n) return Float64(1.0 / sqrt(Float64(k / Float64(pi * Float64(2.0 * n))))) end
function tmp = code(k, n) tmp = 1.0 / sqrt((k / (pi * (2.0 * n)))); end
code[k_, n_] := N[(1.0 / N[Sqrt[N[(k / N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\frac{k}{\pi \cdot \left(2 \cdot n\right)}}}
\end{array}
Initial program 99.8%
Applied egg-rr93.6%
distribute-lft-in93.6%
metadata-eval93.6%
*-commutative93.6%
associate-*r*93.6%
metadata-eval93.6%
neg-mul-193.6%
sub-neg93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in k around 0 33.7%
*-commutative33.7%
associate-/l*33.7%
Simplified33.7%
*-commutative33.7%
*-commutative33.7%
associate-*r/33.7%
*-commutative33.7%
associate-*r/33.7%
sqrt-div40.0%
*-commutative40.0%
Applied egg-rr40.0%
*-commutative40.0%
associate-*l*40.0%
Simplified40.0%
clear-num39.9%
inv-pow39.9%
sqrt-undiv34.2%
Applied egg-rr34.2%
unpow-134.2%
Simplified34.2%
Final simplification34.2%
(FPCore (k n) :precision binary64 (/ 1.0 (sqrt (* 0.5 (/ (/ k n) PI)))))
double code(double k, double n) {
return 1.0 / sqrt((0.5 * ((k / n) / ((double) M_PI))));
}
public static double code(double k, double n) {
return 1.0 / Math.sqrt((0.5 * ((k / n) / Math.PI)));
}
def code(k, n): return 1.0 / math.sqrt((0.5 * ((k / n) / math.pi)))
function code(k, n) return Float64(1.0 / sqrt(Float64(0.5 * Float64(Float64(k / n) / pi)))) end
function tmp = code(k, n) tmp = 1.0 / sqrt((0.5 * ((k / n) / pi))); end
code[k_, n_] := N[(1.0 / N[Sqrt[N[(0.5 * N[(N[(k / n), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{0.5 \cdot \frac{\frac{k}{n}}{\pi}}}
\end{array}
Initial program 99.8%
Applied egg-rr93.6%
distribute-lft-in93.6%
metadata-eval93.6%
*-commutative93.6%
associate-*r*93.6%
metadata-eval93.6%
neg-mul-193.6%
sub-neg93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in k around 0 33.7%
*-commutative33.7%
associate-/l*33.7%
Simplified33.7%
*-commutative33.7%
*-commutative33.7%
associate-*r/33.7%
*-commutative33.7%
associate-*r/33.7%
sqrt-div40.0%
*-commutative40.0%
Applied egg-rr40.0%
*-commutative40.0%
associate-*l*40.0%
Simplified40.0%
clear-num39.9%
inv-pow39.9%
sqrt-undiv34.2%
Applied egg-rr34.2%
unpow-134.2%
associate-/r*34.2%
*-lft-identity34.2%
*-commutative34.2%
times-frac34.2%
metadata-eval34.2%
associate-/l/34.2%
associate-/r*34.2%
Simplified34.2%
(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.8%
Taylor expanded in k around 0 33.6%
associate-/l*33.6%
Simplified33.6%
sqrt-unprod33.7%
Applied egg-rr33.7%
Final simplification33.7%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (* PI (/ n k)))))
double code(double k, double n) {
return sqrt((2.0 * (((double) M_PI) * (n / k))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (Math.PI * (n / k))));
}
def code(k, n): return math.sqrt((2.0 * (math.pi * (n / k))))
function code(k, n) return sqrt(Float64(2.0 * Float64(pi * Float64(n / k)))) end
function tmp = code(k, n) tmp = sqrt((2.0 * (pi * (n / k)))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(Pi * N[(n / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \left(\pi \cdot \frac{n}{k}\right)}
\end{array}
Initial program 99.8%
Applied egg-rr93.6%
distribute-lft-in93.6%
metadata-eval93.6%
*-commutative93.6%
associate-*r*93.6%
metadata-eval93.6%
neg-mul-193.6%
sub-neg93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in k around 0 33.7%
*-commutative33.7%
associate-/l*33.7%
Simplified33.7%
herbie shell --seed 2024177
(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))))