
(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 (<= (* n (* PI 2.0)) 1e-278) (sqrt (/ (pow (fabs (* (* PI n) -2.0)) (- 1.0 k)) k)) (/ (pow (* 2.0 (* PI n)) (- 0.5 (/ k 2.0))) (sqrt k))))
double code(double k, double n) {
double tmp;
if ((n * (((double) M_PI) * 2.0)) <= 1e-278) {
tmp = sqrt((pow(fabs(((((double) M_PI) * n) * -2.0)), (1.0 - k)) / k));
} else {
tmp = pow((2.0 * (((double) M_PI) * n)), (0.5 - (k / 2.0))) / sqrt(k);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if ((n * (Math.PI * 2.0)) <= 1e-278) {
tmp = Math.sqrt((Math.pow(Math.abs(((Math.PI * n) * -2.0)), (1.0 - k)) / k));
} else {
tmp = Math.pow((2.0 * (Math.PI * n)), (0.5 - (k / 2.0))) / Math.sqrt(k);
}
return tmp;
}
def code(k, n): tmp = 0 if (n * (math.pi * 2.0)) <= 1e-278: tmp = math.sqrt((math.pow(math.fabs(((math.pi * n) * -2.0)), (1.0 - k)) / k)) else: tmp = math.pow((2.0 * (math.pi * n)), (0.5 - (k / 2.0))) / math.sqrt(k) return tmp
function code(k, n) tmp = 0.0 if (Float64(n * Float64(pi * 2.0)) <= 1e-278) tmp = sqrt(Float64((abs(Float64(Float64(pi * n) * -2.0)) ^ Float64(1.0 - k)) / k)); else tmp = Float64((Float64(2.0 * Float64(pi * n)) ^ Float64(0.5 - Float64(k / 2.0))) / sqrt(k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if ((n * (pi * 2.0)) <= 1e-278) tmp = sqrt(((abs(((pi * n) * -2.0)) ^ (1.0 - k)) / k)); else tmp = ((2.0 * (pi * n)) ^ (0.5 - (k / 2.0))) / sqrt(k); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision], 1e-278], N[Sqrt[N[(N[Power[N[Abs[N[(N[(Pi * n), $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;n \cdot \left(\pi \cdot 2\right) \leq 10^{-278}:\\
\;\;\;\;\sqrt{\frac{{\left(\left|\left(\pi \cdot n\right) \cdot -2\right|\right)}^{\left(1 - k\right)}}{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 2 (PI.f64)) n) < 9.99999999999999938e-279Initial program 94.0%
add-sqr-sqrt93.9%
sqrt-unprod94.0%
*-commutative94.0%
associate-*r*94.0%
div-sub94.0%
metadata-eval94.0%
div-inv94.0%
*-commutative94.0%
Applied egg-rr94.0%
Simplified94.0%
add-sqr-sqrt11.9%
fabs-sqr11.9%
add-sqr-sqrt100.0%
neg-fabs100.0%
associate-*r*100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
*-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if 9.99999999999999938e-279 < (*.f64 (*.f64 2 (PI.f64)) n) Initial program 99.3%
associate-*l/99.4%
*-lft-identity99.4%
associate-*l*99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
Final simplification99.6%
(FPCore (k n) :precision binary64 (* (/ 1.0 (sqrt k)) (pow (fabs (* PI (* n 2.0))) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return (1.0 / sqrt(k)) * pow(fabs((((double) M_PI) * (n * 2.0))), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return (1.0 / Math.sqrt(k)) * Math.pow(Math.abs((Math.PI * (n * 2.0))), ((1.0 - k) / 2.0));
}
def code(k, n): return (1.0 / math.sqrt(k)) * math.pow(math.fabs((math.pi * (n * 2.0))), ((1.0 - k) / 2.0))
function code(k, n) return Float64(Float64(1.0 / sqrt(k)) * (abs(Float64(pi * Float64(n * 2.0))) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = (1.0 / sqrt(k)) * (abs((pi * (n * 2.0))) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[(1.0 / N[Sqrt[k], $MachinePrecision]), $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}
\\
\frac{1}{\sqrt{k}} \cdot {\left(\left|\pi \cdot \left(n \cdot 2\right)\right|\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Initial program 97.9%
associate-*r*97.9%
add-sqr-sqrt76.4%
sqrt-unprod82.9%
*-commutative82.9%
*-commutative82.9%
swap-sqr82.9%
pow282.9%
metadata-eval82.9%
Applied egg-rr82.9%
*-commutative82.9%
metadata-eval82.9%
unpow282.9%
swap-sqr82.9%
rem-sqrt-square99.5%
*-commutative99.5%
associate-*l*99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (k n) :precision binary64 (if (<= k 1.35e-62) (/ (sqrt (* n 2.0)) (sqrt (/ k PI))) (/ 1.0 (sqrt (/ k (pow (* PI (* n 2.0)) (- 1.0 k)))))))
double code(double k, double n) {
double tmp;
if (k <= 1.35e-62) {
tmp = sqrt((n * 2.0)) / sqrt((k / ((double) M_PI)));
} else {
tmp = 1.0 / sqrt((k / pow((((double) M_PI) * (n * 2.0)), (1.0 - k))));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1.35e-62) {
tmp = Math.sqrt((n * 2.0)) / Math.sqrt((k / Math.PI));
} else {
tmp = 1.0 / Math.sqrt((k / Math.pow((Math.PI * (n * 2.0)), (1.0 - k))));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 1.35e-62: tmp = math.sqrt((n * 2.0)) / math.sqrt((k / math.pi)) else: tmp = 1.0 / math.sqrt((k / math.pow((math.pi * (n * 2.0)), (1.0 - k)))) return tmp
function code(k, n) tmp = 0.0 if (k <= 1.35e-62) tmp = Float64(sqrt(Float64(n * 2.0)) / sqrt(Float64(k / pi))); else tmp = Float64(1.0 / sqrt(Float64(k / (Float64(pi * Float64(n * 2.0)) ^ Float64(1.0 - k))))); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 1.35e-62) tmp = sqrt((n * 2.0)) / sqrt((k / pi)); else tmp = 1.0 / sqrt((k / ((pi * (n * 2.0)) ^ (1.0 - k)))); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.35e-62], N[(N[Sqrt[N[(n * 2.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(k / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sqrt[N[(k / N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.35 \cdot 10^{-62}:\\
\;\;\;\;\frac{\sqrt{n \cdot 2}}{\sqrt{\frac{k}{\pi}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{k}{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(1 - k\right)}}}}\\
\end{array}
\end{array}
if k < 1.3500000000000001e-62Initial program 99.2%
Taylor expanded in k around 0 71.8%
*-commutative71.8%
associate-/l*71.8%
Simplified71.8%
pow171.8%
sqrt-unprod72.2%
associate-*r/72.1%
*-commutative72.1%
Applied egg-rr72.1%
unpow172.1%
*-commutative72.1%
associate-/l*72.2%
Simplified72.2%
clear-num72.1%
un-div-inv72.1%
Applied egg-rr72.1%
associate-*r/72.1%
*-commutative72.1%
sqrt-div99.4%
Applied egg-rr99.4%
if 1.3500000000000001e-62 < k Initial program 97.4%
associate-*r*97.4%
add-sqr-sqrt66.4%
sqrt-unprod93.9%
*-commutative93.9%
*-commutative93.9%
swap-sqr93.9%
pow293.9%
metadata-eval93.9%
Applied egg-rr93.9%
*-commutative93.9%
metadata-eval93.9%
unpow293.9%
swap-sqr93.9%
rem-sqrt-square99.6%
*-commutative99.6%
associate-*l*99.6%
Simplified99.6%
*-commutative99.6%
add-sqr-sqrt66.4%
fabs-sqr66.4%
add-sqr-sqrt97.4%
div-inv97.4%
sqrt-pow196.9%
sqrt-div96.4%
clear-num96.4%
sqrt-div96.9%
metadata-eval96.9%
Applied egg-rr96.9%
Final simplification97.7%
(FPCore (k n) :precision binary64 (if (<= k 1.35e-36) (/ (sqrt (* n 2.0)) (sqrt (/ k PI))) (sqrt (/ (pow (* PI (* n 2.0)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 1.35e-36) {
tmp = sqrt((n * 2.0)) / sqrt((k / ((double) M_PI)));
} 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 <= 1.35e-36) {
tmp = Math.sqrt((n * 2.0)) / Math.sqrt((k / Math.PI));
} 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 <= 1.35e-36: tmp = math.sqrt((n * 2.0)) / math.sqrt((k / math.pi)) 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 <= 1.35e-36) tmp = Float64(sqrt(Float64(n * 2.0)) / sqrt(Float64(k / pi))); 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 <= 1.35e-36) tmp = sqrt((n * 2.0)) / sqrt((k / pi)); else tmp = sqrt((((pi * (n * 2.0)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.35e-36], N[(N[Sqrt[N[(n * 2.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(k / Pi), $MachinePrecision]], $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 1.35 \cdot 10^{-36}:\\
\;\;\;\;\frac{\sqrt{n \cdot 2}}{\sqrt{\frac{k}{\pi}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 1.35000000000000004e-36Initial program 99.2%
Taylor expanded in k around 0 74.1%
*-commutative74.1%
associate-/l*74.2%
Simplified74.2%
pow174.2%
sqrt-unprod74.5%
associate-*r/74.5%
*-commutative74.5%
Applied egg-rr74.5%
unpow174.5%
*-commutative74.5%
associate-/l*74.5%
Simplified74.5%
clear-num74.5%
un-div-inv74.5%
Applied egg-rr74.5%
associate-*r/74.5%
*-commutative74.5%
sqrt-div99.4%
Applied egg-rr99.4%
if 1.35000000000000004e-36 < k Initial program 97.2%
add-sqr-sqrt97.2%
sqrt-unprod96.7%
*-commutative96.7%
associate-*r*96.7%
div-sub96.7%
metadata-eval96.7%
div-inv96.7%
*-commutative96.7%
Applied egg-rr96.7%
Simplified96.7%
Final simplification97.6%
(FPCore (k n) :precision binary64 (if (<= k 3.8e+29) (* (sqrt (* n 2.0)) (sqrt (/ PI k))) (sqrt (* 2.0 (+ -1.0 (fma n (/ PI k) 1.0))))))
double code(double k, double n) {
double tmp;
if (k <= 3.8e+29) {
tmp = sqrt((n * 2.0)) * sqrt((((double) M_PI) / k));
} else {
tmp = sqrt((2.0 * (-1.0 + fma(n, (((double) M_PI) / k), 1.0))));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 3.8e+29) tmp = Float64(sqrt(Float64(n * 2.0)) * sqrt(Float64(pi / k))); else tmp = sqrt(Float64(2.0 * Float64(-1.0 + fma(n, Float64(pi / k), 1.0)))); end return tmp end
code[k_, n_] := If[LessEqual[k, 3.8e+29], N[(N[Sqrt[N[(n * 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(2.0 * N[(-1.0 + N[(n * N[(Pi / k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.8 \cdot 10^{+29}:\\
\;\;\;\;\sqrt{n \cdot 2} \cdot \sqrt{\frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2 \cdot \left(-1 + \mathsf{fma}\left(n, \frac{\pi}{k}, 1\right)\right)}\\
\end{array}
\end{array}
if k < 3.79999999999999971e29Initial program 95.5%
Taylor expanded in k around 0 65.0%
*-commutative65.0%
associate-/l*65.0%
Simplified65.0%
pow165.0%
sqrt-unprod65.3%
associate-*r/65.3%
*-commutative65.3%
Applied egg-rr65.3%
unpow165.3%
*-commutative65.3%
associate-/l*65.3%
Simplified65.3%
associate-*r*65.3%
*-commutative65.3%
sqrt-prod84.2%
*-commutative84.2%
Applied egg-rr84.2%
*-commutative84.2%
Simplified84.2%
if 3.79999999999999971e29 < k Initial program 100.0%
Taylor expanded in k around 0 1.6%
*-commutative1.6%
associate-/l*1.6%
Simplified1.6%
pow11.6%
sqrt-unprod1.6%
associate-*r/1.6%
*-commutative1.6%
Applied egg-rr1.6%
unpow11.6%
*-commutative1.6%
associate-/l*1.6%
Simplified1.6%
associate-*r/1.6%
*-commutative1.6%
associate-*r/1.6%
expm1-log1p-u1.6%
expm1-undefine32.6%
Applied egg-rr32.6%
sub-neg32.6%
metadata-eval32.6%
+-commutative32.6%
log1p-undefine32.6%
rem-exp-log32.6%
+-commutative32.6%
associate-*r/32.6%
*-commutative32.6%
associate-/l*32.6%
fma-define32.6%
Simplified32.6%
Final simplification56.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 97.9%
associate-*l/98.0%
*-lft-identity98.0%
associate-*l*98.0%
div-sub98.0%
metadata-eval98.0%
Simplified98.0%
Final simplification98.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 97.9%
Taylor expanded in k around 0 30.5%
*-commutative30.5%
associate-/l*30.5%
Simplified30.5%
pow130.5%
sqrt-unprod30.7%
associate-*r/30.7%
*-commutative30.7%
Applied egg-rr30.7%
unpow130.7%
*-commutative30.7%
associate-/l*30.7%
Simplified30.7%
clear-num30.7%
un-div-inv30.7%
Applied egg-rr30.7%
pow130.7%
associate-/r/30.7%
*-commutative30.7%
metadata-eval30.7%
pow-prod-up30.6%
pow-prod-down28.1%
pow228.1%
Applied egg-rr28.1%
unpow1/228.1%
unpow228.1%
rem-sqrt-square31.4%
Simplified31.4%
Final simplification31.4%
(FPCore (k n) :precision binary64 (* (sqrt (* n 2.0)) (sqrt (/ PI k))))
double code(double k, double n) {
return sqrt((n * 2.0)) * sqrt((((double) M_PI) / k));
}
public static double code(double k, double n) {
return Math.sqrt((n * 2.0)) * Math.sqrt((Math.PI / k));
}
def code(k, n): return math.sqrt((n * 2.0)) * math.sqrt((math.pi / k))
function code(k, n) return Float64(sqrt(Float64(n * 2.0)) * sqrt(Float64(pi / k))) end
function tmp = code(k, n) tmp = sqrt((n * 2.0)) * sqrt((pi / k)); end
code[k_, n_] := N[(N[Sqrt[N[(n * 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{n \cdot 2} \cdot \sqrt{\frac{\pi}{k}}
\end{array}
Initial program 97.9%
Taylor expanded in k around 0 30.5%
*-commutative30.5%
associate-/l*30.5%
Simplified30.5%
pow130.5%
sqrt-unprod30.7%
associate-*r/30.7%
*-commutative30.7%
Applied egg-rr30.7%
unpow130.7%
*-commutative30.7%
associate-/l*30.7%
Simplified30.7%
associate-*r*30.7%
*-commutative30.7%
sqrt-prod39.4%
*-commutative39.4%
Applied egg-rr39.4%
*-commutative39.4%
Simplified39.4%
Final simplification39.4%
(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 97.9%
Taylor expanded in k around 0 30.5%
*-commutative30.5%
associate-/l*30.5%
Simplified30.5%
pow130.5%
sqrt-unprod30.7%
associate-*r/30.7%
*-commutative30.7%
Applied egg-rr30.7%
unpow130.7%
*-commutative30.7%
associate-/l*30.7%
Simplified30.7%
Final simplification30.7%
herbie shell --seed 2024067
(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))))