
(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 8 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 (* PI (* 2.0 n))))
(if (<= (* (* 2.0 PI) n) 2e-213)
(/ (pow (log1p (expm1 (* 2.0 (* PI n)))) (- 0.5 (/ k 2.0))) (sqrt k))
(/ (/ (sqrt t_0) (pow t_0 (* 0.5 k))) (sqrt k)))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (2.0 * n);
double tmp;
if (((2.0 * ((double) M_PI)) * n) <= 2e-213) {
tmp = pow(log1p(expm1((2.0 * (((double) M_PI) * n)))), (0.5 - (k / 2.0))) / sqrt(k);
} else {
tmp = (sqrt(t_0) / pow(t_0, (0.5 * k))) / sqrt(k);
}
return tmp;
}
public static double code(double k, double n) {
double t_0 = Math.PI * (2.0 * n);
double tmp;
if (((2.0 * Math.PI) * n) <= 2e-213) {
tmp = Math.pow(Math.log1p(Math.expm1((2.0 * (Math.PI * n)))), (0.5 - (k / 2.0))) / Math.sqrt(k);
} else {
tmp = (Math.sqrt(t_0) / Math.pow(t_0, (0.5 * k))) / Math.sqrt(k);
}
return tmp;
}
def code(k, n): t_0 = math.pi * (2.0 * n) tmp = 0 if ((2.0 * math.pi) * n) <= 2e-213: tmp = math.pow(math.log1p(math.expm1((2.0 * (math.pi * n)))), (0.5 - (k / 2.0))) / math.sqrt(k) else: tmp = (math.sqrt(t_0) / math.pow(t_0, (0.5 * k))) / math.sqrt(k) return tmp
function code(k, n) t_0 = Float64(pi * Float64(2.0 * n)) tmp = 0.0 if (Float64(Float64(2.0 * pi) * n) <= 2e-213) tmp = Float64((log1p(expm1(Float64(2.0 * Float64(pi * n)))) ^ Float64(0.5 - Float64(k / 2.0))) / sqrt(k)); else tmp = Float64(Float64(sqrt(t_0) / (t_0 ^ Float64(0.5 * k))) / sqrt(k)); end return tmp end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], 2e-213], N[(N[Power[N[Log[1 + N[(Exp[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(0.5 - N[(k / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[t$95$0], $MachinePrecision] / N[Power[t$95$0, N[(0.5 * k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(2 \cdot n\right)\\
\mathbf{if}\;\left(2 \cdot \pi\right) \cdot n \leq 2 \cdot 10^{-213}:\\
\;\;\;\;\frac{{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(2 \cdot \left(\pi \cdot n\right)\right)\right)\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt{t\_0}}{{t\_0}^{\left(0.5 \cdot k\right)}}}{\sqrt{k}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 2 (PI.f64)) n) < 1.9999999999999999e-213Initial program 95.2%
associate-*l/95.2%
*-lft-identity95.2%
div-sub95.2%
metadata-eval95.2%
Simplified95.2%
log1p-expm1-u99.8%
associate-*l*99.8%
Applied egg-rr99.8%
if 1.9999999999999999e-213 < (*.f64 (*.f64 2 (PI.f64)) n) Initial program 99.3%
associate-*l/99.4%
*-un-lft-identity99.4%
unpow-prod-down80.9%
unpow-prod-down99.4%
div-sub99.4%
metadata-eval99.4%
pow-div99.7%
pow1/299.7%
associate-/l/99.6%
associate-*l*99.6%
associate-*l*99.6%
div-inv99.6%
metadata-eval99.6%
Applied egg-rr99.6%
associate-/l/99.7%
remove-double-neg99.7%
distribute-frac-neg299.7%
distribute-frac-neg99.7%
distribute-frac-neg299.7%
distribute-frac-neg299.7%
distribute-frac-neg99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (* 2.0 PI) n)))
(if (<= t_0 1e-278)
(sqrt (/ (pow (fabs (* 2.0 (* PI n))) (- 1.0 k)) k))
(/ (pow t_0 (- 0.5 (/ k 2.0))) (sqrt k)))))
double code(double k, double n) {
double t_0 = (2.0 * ((double) M_PI)) * n;
double tmp;
if (t_0 <= 1e-278) {
tmp = sqrt((pow(fabs((2.0 * (((double) M_PI) * n))), (1.0 - k)) / k));
} else {
tmp = pow(t_0, (0.5 - (k / 2.0))) / sqrt(k);
}
return tmp;
}
public static double code(double k, double n) {
double t_0 = (2.0 * Math.PI) * n;
double tmp;
if (t_0 <= 1e-278) {
tmp = Math.sqrt((Math.pow(Math.abs((2.0 * (Math.PI * n))), (1.0 - k)) / k));
} else {
tmp = Math.pow(t_0, (0.5 - (k / 2.0))) / Math.sqrt(k);
}
return tmp;
}
def code(k, n): t_0 = (2.0 * math.pi) * n tmp = 0 if t_0 <= 1e-278: tmp = math.sqrt((math.pow(math.fabs((2.0 * (math.pi * n))), (1.0 - k)) / k)) else: tmp = math.pow(t_0, (0.5 - (k / 2.0))) / math.sqrt(k) return tmp
function code(k, n) t_0 = Float64(Float64(2.0 * pi) * n) tmp = 0.0 if (t_0 <= 1e-278) tmp = sqrt(Float64((abs(Float64(2.0 * Float64(pi * n))) ^ Float64(1.0 - k)) / k)); else tmp = Float64((t_0 ^ Float64(0.5 - Float64(k / 2.0))) / sqrt(k)); end return tmp end
function tmp_2 = code(k, n) t_0 = (2.0 * pi) * n; tmp = 0.0; if (t_0 <= 1e-278) tmp = sqrt(((abs((2.0 * (pi * n))) ^ (1.0 - k)) / k)); else tmp = (t_0 ^ (0.5 - (k / 2.0))) / sqrt(k); end tmp_2 = tmp; end
code[k_, n_] := Block[{t$95$0 = N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-278], N[Sqrt[N[(N[Power[N[Abs[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision], N[(N[Power[t$95$0, N[(0.5 - N[(k / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \pi\right) \cdot n\\
\mathbf{if}\;t\_0 \leq 10^{-278}:\\
\;\;\;\;\sqrt{\frac{{\left(\left|2 \cdot \left(\pi \cdot n\right)\right|\right)}^{\left(1 - k\right)}}{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{t\_0}^{\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%
div-sub94.0%
metadata-eval94.0%
div-inv94.0%
*-commutative94.0%
div-sub94.0%
metadata-eval94.0%
div-inv94.0%
Applied egg-rr94.0%
sqr-pow94.0%
pow-sqr94.0%
associate-*r*94.0%
associate-/l*94.0%
metadata-eval94.0%
associate-*r*94.0%
*-commutative94.0%
associate-*r*94.0%
metadata-eval94.0%
associate-*r*94.0%
metadata-eval94.0%
*-lft-identity94.0%
*-commutative94.0%
associate-*l*94.0%
Simplified94.0%
associate-*r*94.0%
*-commutative94.0%
add-sqr-sqrt11.9%
pow1/211.9%
pow1/211.9%
pow-prod-down95.7%
pow295.7%
*-commutative95.7%
associate-*r*95.7%
*-commutative95.7%
Applied egg-rr95.7%
unpow1/295.7%
unpow295.7%
rem-sqrt-square100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
if 9.99999999999999938e-279 < (*.f64 (*.f64 2 (PI.f64)) n) Initial program 99.3%
associate-*l/99.4%
*-lft-identity99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 1.2e-36) (/ (sqrt (* (* 2.0 PI) n)) (sqrt k)) (sqrt (/ (pow (* PI (* 2.0 n)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 1.2e-36) {
tmp = sqrt(((2.0 * ((double) M_PI)) * n)) / sqrt(k);
} else {
tmp = sqrt((pow((((double) M_PI) * (2.0 * n)), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1.2e-36) {
tmp = Math.sqrt(((2.0 * Math.PI) * n)) / Math.sqrt(k);
} else {
tmp = Math.sqrt((Math.pow((Math.PI * (2.0 * n)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 1.2e-36: tmp = math.sqrt(((2.0 * math.pi) * n)) / math.sqrt(k) else: tmp = math.sqrt((math.pow((math.pi * (2.0 * n)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 1.2e-36) tmp = Float64(sqrt(Float64(Float64(2.0 * pi) * n)) / sqrt(k)); else tmp = sqrt(Float64((Float64(pi * Float64(2.0 * n)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 1.2e-36) tmp = sqrt(((2.0 * pi) * n)) / sqrt(k); else tmp = sqrt((((pi * (2.0 * n)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.2e-36], N[(N[Sqrt[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(Pi * N[(2.0 * n), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.2 \cdot 10^{-36}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \pi\right) \cdot n}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(\pi \cdot \left(2 \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 1.2e-36Initial program 99.2%
add-sqr-sqrt99.0%
sqrt-unprod74.1%
*-commutative74.1%
div-sub74.1%
metadata-eval74.1%
div-inv74.2%
*-commutative74.2%
div-sub74.2%
metadata-eval74.2%
div-inv74.2%
Applied egg-rr74.5%
sqr-pow74.2%
pow-sqr74.5%
associate-*r*74.5%
associate-/l*74.5%
metadata-eval74.5%
associate-*r*74.5%
*-commutative74.5%
associate-*r*74.5%
metadata-eval74.5%
associate-*r*74.5%
metadata-eval74.5%
*-lft-identity74.5%
*-commutative74.5%
associate-*l*74.5%
Simplified74.5%
Taylor expanded in k around 0 74.5%
sqrt-div99.4%
div-inv99.2%
*-commutative99.2%
Applied egg-rr99.2%
associate-*r/99.4%
*-rgt-identity99.4%
associate-*r*99.4%
*-commutative99.4%
Simplified99.4%
if 1.2e-36 < k Initial program 97.2%
add-sqr-sqrt97.2%
sqrt-unprod96.7%
*-commutative96.7%
div-sub96.7%
metadata-eval96.7%
div-inv96.7%
*-commutative96.7%
div-sub96.7%
metadata-eval96.7%
div-inv96.7%
Applied egg-rr96.7%
sqr-pow96.7%
pow-sqr96.7%
associate-*r*96.7%
associate-/l*96.7%
metadata-eval96.7%
associate-*r*96.7%
*-commutative96.7%
associate-*r*96.7%
metadata-eval96.7%
associate-*r*96.7%
metadata-eval96.7%
*-lft-identity96.7%
*-commutative96.7%
associate-*l*96.7%
Simplified96.7%
Final simplification97.6%
(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(Float64(2.0 * 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[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], N[(0.5 - N[(k / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 97.9%
associate-*l/98.0%
*-lft-identity98.0%
div-sub98.0%
metadata-eval98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (k n) :precision binary64 (sqrt (fabs (* n (* 2.0 (/ PI k))))))
double code(double k, double n) {
return sqrt(fabs((n * (2.0 * (((double) M_PI) / k)))));
}
public static double code(double k, double n) {
return Math.sqrt(Math.abs((n * (2.0 * (Math.PI / k)))));
}
def code(k, n): return math.sqrt(math.fabs((n * (2.0 * (math.pi / k)))))
function code(k, n) return sqrt(abs(Float64(n * Float64(2.0 * Float64(pi / k))))) end
function tmp = code(k, n) tmp = sqrt(abs((n * (2.0 * (pi / k))))); end
code[k_, n_] := N[Sqrt[N[Abs[N[(n * N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left|n \cdot \left(2 \cdot \frac{\pi}{k}\right)\right|}
\end{array}
Initial program 97.9%
add-sqr-sqrt97.8%
sqrt-unprod88.8%
*-commutative88.8%
div-sub88.8%
metadata-eval88.8%
div-inv88.9%
*-commutative88.9%
div-sub88.9%
metadata-eval88.9%
div-inv88.9%
Applied egg-rr89.0%
sqr-pow88.9%
pow-sqr89.0%
associate-*r*89.0%
associate-/l*89.0%
metadata-eval89.0%
associate-*r*89.0%
*-commutative89.0%
associate-*r*89.0%
metadata-eval89.0%
associate-*r*89.0%
metadata-eval89.0%
*-lft-identity89.0%
*-commutative89.0%
associate-*l*89.0%
Simplified89.0%
Taylor expanded in k around 0 30.7%
add-sqr-sqrt30.7%
pow1/230.7%
pow1/230.7%
pow-prod-down28.1%
pow228.1%
associate-/l*28.1%
*-commutative28.1%
Applied egg-rr28.1%
unpow1/228.1%
unpow228.1%
rem-sqrt-square31.4%
associate-*r/31.4%
associate-*r*31.4%
associate-*l/31.4%
*-commutative31.4%
associate-/l*31.4%
Simplified31.4%
Final simplification31.4%
(FPCore (k n) :precision binary64 (/ (sqrt (* (* 2.0 PI) n)) (sqrt k)))
double code(double k, double n) {
return sqrt(((2.0 * ((double) M_PI)) * n)) / sqrt(k);
}
public static double code(double k, double n) {
return Math.sqrt(((2.0 * Math.PI) * n)) / Math.sqrt(k);
}
def code(k, n): return math.sqrt(((2.0 * math.pi) * n)) / math.sqrt(k)
function code(k, n) return Float64(sqrt(Float64(Float64(2.0 * pi) * n)) / sqrt(k)) end
function tmp = code(k, n) tmp = sqrt(((2.0 * pi) * n)) / sqrt(k); end
code[k_, n_] := N[(N[Sqrt[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{\left(2 \cdot \pi\right) \cdot n}}{\sqrt{k}}
\end{array}
Initial program 97.9%
add-sqr-sqrt97.8%
sqrt-unprod88.8%
*-commutative88.8%
div-sub88.8%
metadata-eval88.8%
div-inv88.9%
*-commutative88.9%
div-sub88.9%
metadata-eval88.9%
div-inv88.9%
Applied egg-rr89.0%
sqr-pow88.9%
pow-sqr89.0%
associate-*r*89.0%
associate-/l*89.0%
metadata-eval89.0%
associate-*r*89.0%
*-commutative89.0%
associate-*r*89.0%
metadata-eval89.0%
associate-*r*89.0%
metadata-eval89.0%
*-lft-identity89.0%
*-commutative89.0%
associate-*l*89.0%
Simplified89.0%
Taylor expanded in k around 0 30.7%
sqrt-div39.4%
div-inv39.3%
*-commutative39.3%
Applied egg-rr39.3%
associate-*r/39.4%
*-rgt-identity39.4%
associate-*r*39.4%
*-commutative39.4%
Simplified39.4%
Final simplification39.4%
(FPCore (k n) :precision binary64 (pow (* 0.5 (/ k (* PI n))) -0.5))
double code(double k, double n) {
return pow((0.5 * (k / (((double) M_PI) * n))), -0.5);
}
public static double code(double k, double n) {
return Math.pow((0.5 * (k / (Math.PI * n))), -0.5);
}
def code(k, n): return math.pow((0.5 * (k / (math.pi * n))), -0.5)
function code(k, n) return Float64(0.5 * Float64(k / Float64(pi * n))) ^ -0.5 end
function tmp = code(k, n) tmp = (0.5 * (k / (pi * n))) ^ -0.5; end
code[k_, n_] := N[Power[N[(0.5 * N[(k / N[(Pi * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(0.5 \cdot \frac{k}{\pi \cdot n}\right)}^{-0.5}
\end{array}
Initial program 97.9%
add-sqr-sqrt97.8%
sqrt-unprod88.8%
*-commutative88.8%
div-sub88.8%
metadata-eval88.8%
div-inv88.9%
*-commutative88.9%
div-sub88.9%
metadata-eval88.9%
div-inv88.9%
Applied egg-rr89.0%
sqr-pow88.9%
pow-sqr89.0%
associate-*r*89.0%
associate-/l*89.0%
metadata-eval89.0%
associate-*r*89.0%
*-commutative89.0%
associate-*r*89.0%
metadata-eval89.0%
associate-*r*89.0%
metadata-eval89.0%
*-lft-identity89.0%
*-commutative89.0%
associate-*l*89.0%
Simplified89.0%
Taylor expanded in k around 0 30.7%
associate-/l*30.7%
*-commutative30.7%
Applied egg-rr30.7%
sqrt-prod30.5%
sqrt-div39.2%
associate-/l*39.3%
sqrt-prod39.4%
clear-num39.3%
inv-pow39.3%
sqrt-undiv31.3%
associate-*r*31.3%
*-commutative31.3%
sqrt-pow231.4%
*-commutative31.4%
associate-*r*31.4%
*-un-lft-identity31.4%
times-frac31.3%
metadata-eval31.3%
*-commutative31.3%
metadata-eval31.3%
Applied egg-rr31.3%
Final simplification31.3%
(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%
add-sqr-sqrt97.8%
sqrt-unprod88.8%
*-commutative88.8%
div-sub88.8%
metadata-eval88.8%
div-inv88.9%
*-commutative88.9%
div-sub88.9%
metadata-eval88.9%
div-inv88.9%
Applied egg-rr89.0%
sqr-pow88.9%
pow-sqr89.0%
associate-*r*89.0%
associate-/l*89.0%
metadata-eval89.0%
associate-*r*89.0%
*-commutative89.0%
associate-*r*89.0%
metadata-eval89.0%
associate-*r*89.0%
metadata-eval89.0%
*-lft-identity89.0%
*-commutative89.0%
associate-*l*89.0%
Simplified89.0%
Taylor expanded in k around 0 30.7%
associate-/l*30.7%
*-commutative30.7%
Applied egg-rr30.7%
Taylor expanded in n around 0 30.7%
associate-*r/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))))