
(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 (* (pow k -0.5) (pow (fabs (* PI (* n 2.0))) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return pow(k, -0.5) * pow(fabs((((double) M_PI) * (n * 2.0))), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) * Math.pow(Math.abs((Math.PI * (n * 2.0))), ((1.0 - k) / 2.0));
}
def code(k, n): return math.pow(k, -0.5) * math.pow(math.fabs((math.pi * (n * 2.0))), ((1.0 - k) / 2.0))
function code(k, n) return Float64((k ^ -0.5) * (abs(Float64(pi * Float64(n * 2.0))) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = (k ^ -0.5) * (abs((pi * (n * 2.0))) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[Abs[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{k}^{-0.5} \cdot {\left(\left|\pi \cdot \left(n \cdot 2\right)\right|\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Initial program 99.3%
associate-*r*99.3%
add-sqr-sqrt79.4%
sqrt-unprod82.3%
*-commutative82.3%
*-commutative82.3%
swap-sqr82.3%
pow282.3%
metadata-eval82.3%
Applied egg-rr82.3%
*-commutative82.3%
metadata-eval82.3%
unpow282.3%
swap-sqr82.3%
rem-sqrt-square99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
*-un-lft-identity99.7%
inv-pow99.7%
sqrt-pow299.7%
metadata-eval99.7%
Applied egg-rr99.7%
*-lft-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* PI (* n 2.0))))
(if (<= k 4.4e-17)
(/ (sqrt t_0) (sqrt k))
(sqrt (/ (pow t_0 (- 1.0 k)) k)))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (n * 2.0);
double tmp;
if (k <= 4.4e-17) {
tmp = sqrt(t_0) / sqrt(k);
} else {
tmp = sqrt((pow(t_0, (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double t_0 = Math.PI * (n * 2.0);
double tmp;
if (k <= 4.4e-17) {
tmp = Math.sqrt(t_0) / Math.sqrt(k);
} else {
tmp = Math.sqrt((Math.pow(t_0, (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): t_0 = math.pi * (n * 2.0) tmp = 0 if k <= 4.4e-17: tmp = math.sqrt(t_0) / math.sqrt(k) else: tmp = math.sqrt((math.pow(t_0, (1.0 - k)) / k)) return tmp
function code(k, n) t_0 = Float64(pi * Float64(n * 2.0)) tmp = 0.0 if (k <= 4.4e-17) tmp = Float64(sqrt(t_0) / sqrt(k)); else tmp = sqrt(Float64((t_0 ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) t_0 = pi * (n * 2.0); tmp = 0.0; if (k <= 4.4e-17) tmp = sqrt(t_0) / sqrt(k); else tmp = sqrt(((t_0 ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k, 4.4e-17], N[(N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[t$95$0, N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(n \cdot 2\right)\\
\mathbf{if}\;k \leq 4.4 \cdot 10^{-17}:\\
\;\;\;\;\frac{\sqrt{t\_0}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{t\_0}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 4.4e-17Initial program 99.2%
associate-*r*99.2%
add-sqr-sqrt99.2%
sqrt-unprod55.2%
*-commutative55.2%
*-commutative55.2%
swap-sqr55.2%
pow255.2%
metadata-eval55.2%
Applied egg-rr55.2%
*-commutative55.2%
metadata-eval55.2%
unpow255.2%
swap-sqr55.2%
rem-sqrt-square99.2%
*-commutative99.2%
associate-*l*99.2%
Simplified99.2%
Taylor expanded in k around 0 79.2%
associate-*r*79.2%
*-commutative79.2%
*-commutative79.2%
rem-square-sqrt79.0%
fabs-sqr79.0%
rem-square-sqrt79.2%
*-commutative79.2%
associate-/l*79.2%
*-commutative79.2%
associate-*r*79.2%
Simplified79.2%
sqrt-prod78.9%
associate-*r/79.0%
*-commutative79.0%
add-sqr-sqrt78.9%
fabs-sqr78.9%
add-sqr-sqrt79.0%
*-commutative79.0%
sqrt-prod79.2%
associate-/l*79.2%
sqrt-div99.4%
Applied egg-rr99.4%
if 4.4e-17 < k Initial program 99.3%
add-sqr-sqrt99.3%
sqrt-unprod99.3%
*-commutative99.3%
associate-*r*99.3%
div-sub99.3%
metadata-eval99.3%
div-inv99.3%
*-commutative99.3%
Applied egg-rr99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (k n) :precision binary64 (if (<= k 1.65e+73) (/ (sqrt (* PI (* n 2.0))) (sqrt k)) (sqrt (+ -1.0 (fma (* n 2.0) (/ PI k) 1.0)))))
double code(double k, double n) {
double tmp;
if (k <= 1.65e+73) {
tmp = sqrt((((double) M_PI) * (n * 2.0))) / sqrt(k);
} else {
tmp = sqrt((-1.0 + fma((n * 2.0), (((double) M_PI) / k), 1.0)));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 1.65e+73) tmp = Float64(sqrt(Float64(pi * Float64(n * 2.0))) / sqrt(k)); else tmp = sqrt(Float64(-1.0 + fma(Float64(n * 2.0), Float64(pi / k), 1.0))); end return tmp end
code[k_, n_] := If[LessEqual[k, 1.65e+73], N[(N[Sqrt[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(-1.0 + N[(N[(n * 2.0), $MachinePrecision] * N[(Pi / k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.65 \cdot 10^{+73}:\\
\;\;\;\;\frac{\sqrt{\pi \cdot \left(n \cdot 2\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{-1 + \mathsf{fma}\left(n \cdot 2, \frac{\pi}{k}, 1\right)}\\
\end{array}
\end{array}
if k < 1.65000000000000015e73Initial program 98.7%
associate-*r*98.7%
add-sqr-sqrt91.7%
sqrt-unprod68.1%
*-commutative68.1%
*-commutative68.1%
swap-sqr68.1%
pow268.1%
metadata-eval68.1%
Applied egg-rr68.1%
*-commutative68.1%
metadata-eval68.1%
unpow268.1%
swap-sqr68.1%
rem-sqrt-square99.4%
*-commutative99.4%
associate-*l*99.4%
Simplified99.4%
Taylor expanded in k around 0 57.5%
associate-*r*57.5%
*-commutative57.5%
*-commutative57.5%
rem-square-sqrt57.2%
fabs-sqr57.2%
rem-square-sqrt57.4%
*-commutative57.4%
associate-/l*57.4%
*-commutative57.4%
associate-*r*57.4%
Simplified57.4%
sqrt-prod57.2%
associate-*r/57.2%
*-commutative57.2%
add-sqr-sqrt57.2%
fabs-sqr57.2%
add-sqr-sqrt57.4%
*-commutative57.4%
sqrt-prod57.5%
associate-/l*57.5%
sqrt-div71.9%
Applied egg-rr71.7%
if 1.65000000000000015e73 < k Initial program 100.0%
associate-*r*100.0%
add-sqr-sqrt64.0%
sqrt-unprod100.0%
*-commutative100.0%
*-commutative100.0%
swap-sqr100.0%
pow2100.0%
metadata-eval100.0%
Applied egg-rr100.0%
*-commutative100.0%
metadata-eval100.0%
unpow2100.0%
swap-sqr100.0%
rem-sqrt-square100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
*-un-lft-identity100.0%
inv-pow100.0%
sqrt-pow2100.0%
metadata-eval100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in k around 0 2.9%
fabs-mul2.9%
metadata-eval2.9%
associate-*r/2.9%
*-commutative2.9%
rem-square-sqrt1.7%
*-commutative1.7%
*-commutative1.7%
fabs-sqr1.7%
*-commutative1.7%
*-commutative1.7%
rem-square-sqrt1.7%
associate-/l*1.7%
Simplified1.7%
expm1-log1p-u1.7%
expm1-undefine39.4%
Applied egg-rr39.4%
sub-neg39.4%
metadata-eval39.4%
+-commutative39.4%
log1p-undefine39.4%
rem-exp-log39.4%
+-commutative39.4%
associate-*r*39.4%
fma-define39.4%
Simplified39.4%
Final simplification57.3%
(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.3%
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 (* (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.3%
associate-*r*99.3%
add-sqr-sqrt79.4%
sqrt-unprod82.3%
*-commutative82.3%
*-commutative82.3%
swap-sqr82.3%
pow282.3%
metadata-eval82.3%
Applied egg-rr82.3%
*-commutative82.3%
metadata-eval82.3%
unpow282.3%
swap-sqr82.3%
rem-sqrt-square99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
*-un-lft-identity99.7%
inv-pow99.7%
sqrt-pow299.7%
metadata-eval99.7%
Applied egg-rr99.7%
*-lft-identity99.7%
Simplified99.7%
Taylor expanded in k around 0 33.2%
fabs-mul33.2%
metadata-eval33.2%
associate-*r/33.2%
*-commutative33.2%
rem-square-sqrt32.5%
*-commutative32.5%
*-commutative32.5%
fabs-sqr32.5%
*-commutative32.5%
*-commutative32.5%
rem-square-sqrt32.6%
associate-/l*32.6%
Simplified32.6%
pow1/232.6%
associate-*r/32.6%
associate-*r/32.6%
*-commutative32.6%
associate-*r*32.6%
associate-*l/32.6%
*-commutative32.6%
associate-*l*32.6%
metadata-eval32.6%
unpow-prod-down40.5%
metadata-eval40.5%
pow1/240.5%
metadata-eval40.5%
Applied egg-rr40.5%
unpow1/240.5%
Simplified40.5%
Final simplification40.5%
(FPCore (k n) :precision binary64 (/ (sqrt (* PI (* n 2.0))) (sqrt k)))
double code(double k, double n) {
return sqrt((((double) M_PI) * (n * 2.0))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI * (n * 2.0))) / Math.sqrt(k);
}
def code(k, n): return math.sqrt((math.pi * (n * 2.0))) / math.sqrt(k)
function code(k, n) return Float64(sqrt(Float64(pi * Float64(n * 2.0))) / sqrt(k)) end
function tmp = code(k, n) tmp = sqrt((pi * (n * 2.0))) / sqrt(k); end
code[k_, n_] := N[(N[Sqrt[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{\pi \cdot \left(n \cdot 2\right)}}{\sqrt{k}}
\end{array}
Initial program 99.3%
associate-*r*99.3%
add-sqr-sqrt79.4%
sqrt-unprod82.3%
*-commutative82.3%
*-commutative82.3%
swap-sqr82.3%
pow282.3%
metadata-eval82.3%
Applied egg-rr82.3%
*-commutative82.3%
metadata-eval82.3%
unpow282.3%
swap-sqr82.3%
rem-sqrt-square99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in k around 0 33.2%
associate-*r*33.2%
*-commutative33.2%
*-commutative33.2%
rem-square-sqrt32.5%
fabs-sqr32.5%
rem-square-sqrt32.6%
*-commutative32.6%
associate-/l*32.6%
*-commutative32.6%
associate-*r*32.6%
Simplified32.6%
sqrt-prod32.5%
associate-*r/32.5%
*-commutative32.5%
add-sqr-sqrt32.5%
fabs-sqr32.5%
add-sqr-sqrt33.1%
*-commutative33.1%
sqrt-prod33.2%
associate-/l*33.2%
sqrt-div41.2%
Applied egg-rr40.6%
Final simplification40.6%
(FPCore (k n) :precision binary64 (/ 1.0 (sqrt (/ k (* PI (* n 2.0))))))
double code(double k, double n) {
return 1.0 / sqrt((k / (((double) M_PI) * (n * 2.0))));
}
public static double code(double k, double n) {
return 1.0 / Math.sqrt((k / (Math.PI * (n * 2.0))));
}
def code(k, n): return 1.0 / math.sqrt((k / (math.pi * (n * 2.0))))
function code(k, n) return Float64(1.0 / sqrt(Float64(k / Float64(pi * Float64(n * 2.0))))) end
function tmp = code(k, n) tmp = 1.0 / sqrt((k / (pi * (n * 2.0)))); end
code[k_, n_] := N[(1.0 / N[Sqrt[N[(k / N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\frac{k}{\pi \cdot \left(n \cdot 2\right)}}}
\end{array}
Initial program 99.3%
associate-*r*99.3%
add-sqr-sqrt79.4%
sqrt-unprod82.3%
*-commutative82.3%
*-commutative82.3%
swap-sqr82.3%
pow282.3%
metadata-eval82.3%
Applied egg-rr82.3%
*-commutative82.3%
metadata-eval82.3%
unpow282.3%
swap-sqr82.3%
rem-sqrt-square99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in k around 0 33.2%
associate-*r*33.2%
*-commutative33.2%
*-commutative33.2%
rem-square-sqrt32.5%
fabs-sqr32.5%
rem-square-sqrt32.6%
*-commutative32.6%
associate-/l*32.6%
*-commutative32.6%
associate-*r*32.6%
Simplified32.6%
sqrt-prod32.5%
associate-*r/32.5%
*-commutative32.5%
add-sqr-sqrt32.5%
fabs-sqr32.5%
add-sqr-sqrt33.1%
*-commutative33.1%
sqrt-prod33.2%
associate-/l*33.2%
clear-num33.2%
sqrt-div34.1%
metadata-eval34.1%
*-commutative34.1%
add-sqr-sqrt33.4%
fabs-sqr33.4%
add-sqr-sqrt33.5%
*-commutative33.5%
Applied egg-rr33.5%
Final simplification33.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.3%
associate-*r*99.3%
add-sqr-sqrt79.4%
sqrt-unprod82.3%
*-commutative82.3%
*-commutative82.3%
swap-sqr82.3%
pow282.3%
metadata-eval82.3%
Applied egg-rr82.3%
*-commutative82.3%
metadata-eval82.3%
unpow282.3%
swap-sqr82.3%
rem-sqrt-square99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in k around 0 33.2%
associate-*r*33.2%
*-commutative33.2%
*-commutative33.2%
rem-square-sqrt32.5%
fabs-sqr32.5%
rem-square-sqrt32.6%
*-commutative32.6%
associate-/l*32.6%
*-commutative32.6%
associate-*r*32.6%
Simplified32.6%
Final simplification32.6%
(FPCore (k n) :precision binary64 (sqrt (* (* n 2.0) (/ PI k))))
double code(double k, double n) {
return sqrt(((n * 2.0) * (((double) M_PI) / k)));
}
public static double code(double k, double n) {
return Math.sqrt(((n * 2.0) * (Math.PI / k)));
}
def code(k, n): return math.sqrt(((n * 2.0) * (math.pi / k)))
function code(k, n) return sqrt(Float64(Float64(n * 2.0) * Float64(pi / k))) end
function tmp = code(k, n) tmp = sqrt(((n * 2.0) * (pi / k))); end
code[k_, n_] := N[Sqrt[N[(N[(n * 2.0), $MachinePrecision] * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left(n \cdot 2\right) \cdot \frac{\pi}{k}}
\end{array}
Initial program 99.3%
associate-*r*99.3%
add-sqr-sqrt79.4%
sqrt-unprod82.3%
*-commutative82.3%
*-commutative82.3%
swap-sqr82.3%
pow282.3%
metadata-eval82.3%
Applied egg-rr82.3%
*-commutative82.3%
metadata-eval82.3%
unpow282.3%
swap-sqr82.3%
rem-sqrt-square99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in k around 0 33.2%
fabs-mul33.2%
metadata-eval33.2%
Simplified33.2%
associate-/l*33.2%
*-commutative33.2%
add-sqr-sqrt32.5%
fabs-sqr32.5%
add-sqr-sqrt32.6%
*-commutative32.6%
associate-*r/32.6%
associate-*r*32.6%
*-commutative32.6%
Applied egg-rr32.6%
Final simplification32.6%
(FPCore (k n) :precision binary64 (sqrt (/ (* n 2.0) (/ k PI))))
double code(double k, double n) {
return sqrt(((n * 2.0) / (k / ((double) M_PI))));
}
public static double code(double k, double n) {
return Math.sqrt(((n * 2.0) / (k / Math.PI)));
}
def code(k, n): return math.sqrt(((n * 2.0) / (k / math.pi)))
function code(k, n) return sqrt(Float64(Float64(n * 2.0) / Float64(k / pi))) end
function tmp = code(k, n) tmp = sqrt(((n * 2.0) / (k / pi))); end
code[k_, n_] := N[Sqrt[N[(N[(n * 2.0), $MachinePrecision] / N[(k / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{n \cdot 2}{\frac{k}{\pi}}}
\end{array}
Initial program 99.3%
associate-*r*99.3%
add-sqr-sqrt79.4%
sqrt-unprod82.3%
*-commutative82.3%
*-commutative82.3%
swap-sqr82.3%
pow282.3%
metadata-eval82.3%
Applied egg-rr82.3%
*-commutative82.3%
metadata-eval82.3%
unpow282.3%
swap-sqr82.3%
rem-sqrt-square99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
*-un-lft-identity99.7%
inv-pow99.7%
sqrt-pow299.7%
metadata-eval99.7%
Applied egg-rr99.7%
*-lft-identity99.7%
Simplified99.7%
Taylor expanded in k around 0 33.2%
fabs-mul33.2%
metadata-eval33.2%
associate-*r/33.2%
*-commutative33.2%
rem-square-sqrt32.5%
*-commutative32.5%
*-commutative32.5%
fabs-sqr32.5%
*-commutative32.5%
*-commutative32.5%
rem-square-sqrt32.6%
associate-/l*32.6%
Simplified32.6%
associate-*r/32.6%
associate-*r/32.6%
*-commutative32.6%
associate-*r*32.6%
associate-*l/32.6%
clear-num32.6%
associate-*l/32.6%
*-un-lft-identity32.6%
Applied egg-rr32.6%
Final simplification32.6%
herbie shell --seed 2024059
(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))))