
(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 13 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 (* n 2.0)))) (* (/ (sqrt t_0) (pow t_0 (* 0.5 k))) (pow k -0.5))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (n * 2.0);
return (sqrt(t_0) / pow(t_0, (0.5 * k))) * pow(k, -0.5);
}
public static double code(double k, double n) {
double t_0 = Math.PI * (n * 2.0);
return (Math.sqrt(t_0) / Math.pow(t_0, (0.5 * k))) * Math.pow(k, -0.5);
}
def code(k, n): t_0 = math.pi * (n * 2.0) return (math.sqrt(t_0) / math.pow(t_0, (0.5 * k))) * math.pow(k, -0.5)
function code(k, n) t_0 = Float64(pi * Float64(n * 2.0)) return Float64(Float64(sqrt(t_0) / (t_0 ^ Float64(0.5 * k))) * (k ^ -0.5)) end
function tmp = code(k, n) t_0 = pi * (n * 2.0); tmp = (sqrt(t_0) / (t_0 ^ (0.5 * k))) * (k ^ -0.5); end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Sqrt[t$95$0], $MachinePrecision] / N[Power[t$95$0, N[(0.5 * k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[k, -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(n \cdot 2\right)\\
\frac{\sqrt{t_0}}{{t_0}^{\left(0.5 \cdot k\right)}} \cdot {k}^{-0.5}
\end{array}
\end{array}
Initial program 99.3%
unpow-prod-down77.7%
unpow-prod-down99.3%
div-sub99.3%
metadata-eval99.3%
pow-sub99.6%
pow1/299.6%
associate-*r/99.6%
inv-pow99.6%
sqrt-pow299.7%
metadata-eval99.7%
associate-*l*99.7%
associate-*l*99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/l*99.6%
associate-/r/99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (let* ((t_0 (* PI (* n 2.0)))) (/ (sqrt t_0) (* (pow t_0 (* 0.5 k)) (sqrt k)))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (n * 2.0);
return sqrt(t_0) / (pow(t_0, (0.5 * k)) * sqrt(k));
}
public static double code(double k, double n) {
double t_0 = Math.PI * (n * 2.0);
return Math.sqrt(t_0) / (Math.pow(t_0, (0.5 * k)) * Math.sqrt(k));
}
def code(k, n): t_0 = math.pi * (n * 2.0) return math.sqrt(t_0) / (math.pow(t_0, (0.5 * k)) * math.sqrt(k))
function code(k, n) t_0 = Float64(pi * Float64(n * 2.0)) return Float64(sqrt(t_0) / Float64((t_0 ^ Float64(0.5 * k)) * sqrt(k))) end
function tmp = code(k, n) t_0 = pi * (n * 2.0); tmp = sqrt(t_0) / ((t_0 ^ (0.5 * k)) * sqrt(k)); end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Sqrt[t$95$0], $MachinePrecision] / N[(N[Power[t$95$0, N[(0.5 * k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(n \cdot 2\right)\\
\frac{\sqrt{t_0}}{{t_0}^{\left(0.5 \cdot k\right)} \cdot \sqrt{k}}
\end{array}
\end{array}
Initial program 99.3%
unpow-prod-down77.7%
unpow-prod-down99.3%
div-sub99.3%
metadata-eval99.3%
pow-sub99.6%
pow1/299.6%
frac-times99.6%
*-un-lft-identity99.6%
associate-*l*99.6%
associate-*l*99.6%
div-inv99.6%
metadata-eval99.6%
Applied egg-rr99.6%
*-commutative99.6%
associate-*l*99.6%
*-commutative99.6%
associate-*l*99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (k n) :precision binary64 (let* ((t_0 (* PI (* n 2.0)))) (/ (* (sqrt t_0) (pow t_0 (* k -0.5))) (sqrt k))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (n * 2.0);
return (sqrt(t_0) * pow(t_0, (k * -0.5))) / sqrt(k);
}
public static double code(double k, double n) {
double t_0 = Math.PI * (n * 2.0);
return (Math.sqrt(t_0) * Math.pow(t_0, (k * -0.5))) / Math.sqrt(k);
}
def code(k, n): t_0 = math.pi * (n * 2.0) return (math.sqrt(t_0) * math.pow(t_0, (k * -0.5))) / math.sqrt(k)
function code(k, n) t_0 = Float64(pi * Float64(n * 2.0)) return Float64(Float64(sqrt(t_0) * (t_0 ^ Float64(k * -0.5))) / sqrt(k)) end
function tmp = code(k, n) t_0 = pi * (n * 2.0); tmp = (sqrt(t_0) * (t_0 ^ (k * -0.5))) / sqrt(k); end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Sqrt[t$95$0], $MachinePrecision] * N[Power[t$95$0, N[(k * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(n \cdot 2\right)\\
\frac{\sqrt{t_0} \cdot {t_0}^{\left(k \cdot -0.5\right)}}{\sqrt{k}}
\end{array}
\end{array}
Initial program 99.3%
associate-*l/99.4%
*-lft-identity99.4%
sqr-pow99.2%
pow-sqr99.4%
*-commutative99.4%
associate-*l/99.4%
associate-/l*99.4%
metadata-eval99.4%
/-rgt-identity99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in k around inf 96.0%
exp-to-pow99.4%
*-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
cancel-sign-sub-inv99.4%
unpow-prod-up99.6%
pow1/299.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 6e-17) (* (pow k -0.5) (pow (/ 0.5 (* PI n)) -0.5)) (pow (* k (pow (* 2.0 (* PI n)) (+ k -1.0))) -0.5)))
double code(double k, double n) {
double tmp;
if (k <= 6e-17) {
tmp = pow(k, -0.5) * pow((0.5 / (((double) M_PI) * n)), -0.5);
} else {
tmp = pow((k * pow((2.0 * (((double) M_PI) * n)), (k + -1.0))), -0.5);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 6e-17) {
tmp = Math.pow(k, -0.5) * Math.pow((0.5 / (Math.PI * n)), -0.5);
} else {
tmp = Math.pow((k * Math.pow((2.0 * (Math.PI * n)), (k + -1.0))), -0.5);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 6e-17: tmp = math.pow(k, -0.5) * math.pow((0.5 / (math.pi * n)), -0.5) else: tmp = math.pow((k * math.pow((2.0 * (math.pi * n)), (k + -1.0))), -0.5) return tmp
function code(k, n) tmp = 0.0 if (k <= 6e-17) tmp = Float64((k ^ -0.5) * (Float64(0.5 / Float64(pi * n)) ^ -0.5)); else tmp = Float64(k * (Float64(2.0 * Float64(pi * n)) ^ Float64(k + -1.0))) ^ -0.5; end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 6e-17) tmp = (k ^ -0.5) * ((0.5 / (pi * n)) ^ -0.5); else tmp = (k * ((2.0 * (pi * n)) ^ (k + -1.0))) ^ -0.5; end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 6e-17], N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(0.5 / N[(Pi * n), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[Power[N[(k * N[Power[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision], N[(k + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 6 \cdot 10^{-17}:\\
\;\;\;\;{k}^{-0.5} \cdot {\left(\frac{0.5}{\pi \cdot n}\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{\left(k \cdot {\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(k + -1\right)}\right)}^{-0.5}\\
\end{array}
\end{array}
if k < 6.00000000000000012e-17Initial program 99.0%
unpow-prod-down98.7%
unpow-prod-down99.0%
div-sub99.0%
metadata-eval99.0%
pow-sub99.2%
pow1/299.2%
associate-*r/99.2%
inv-pow99.2%
sqrt-pow299.3%
metadata-eval99.3%
associate-*l*99.3%
associate-*l*99.3%
div-inv99.3%
metadata-eval99.3%
Applied egg-rr99.3%
*-commutative99.3%
associate-/l*99.3%
associate-/r/99.4%
*-commutative99.4%
associate-*l*99.4%
*-commutative99.4%
associate-*l*99.4%
*-commutative99.4%
Simplified99.4%
Applied egg-rr73.4%
inv-pow73.3%
sqrt-pow273.5%
metadata-eval73.5%
Applied egg-rr73.5%
Taylor expanded in k around 0 90.3%
distribute-rgt-in90.3%
exp-sum90.9%
exp-to-pow92.3%
exp-to-pow99.3%
Simplified99.3%
if 6.00000000000000012e-17 < k Initial program 99.6%
unpow-prod-down57.6%
unpow-prod-down99.6%
div-sub99.6%
metadata-eval99.6%
pow-sub99.9%
pow1/299.9%
associate-*r/99.9%
inv-pow99.9%
sqrt-pow2100.0%
metadata-eval100.0%
associate-*l*100.0%
associate-*l*100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
*-commutative100.0%
associate-/l*100.0%
associate-/r/100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
Simplified100.0%
Applied egg-rr99.6%
inv-pow99.6%
sqrt-pow299.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in k around inf 99.5%
Simplified99.6%
Final simplification99.4%
(FPCore (k n) :precision binary64 (* (pow k -0.5) (pow (* n (* PI 2.0)) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return pow(k, -0.5) * pow((n * (((double) M_PI) * 2.0)), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) * Math.pow((n * (Math.PI * 2.0)), ((1.0 - k) / 2.0));
}
def code(k, n): return math.pow(k, -0.5) * math.pow((n * (math.pi * 2.0)), ((1.0 - k) / 2.0))
function code(k, n) return Float64((k ^ -0.5) * (Float64(n * Float64(pi * 2.0)) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = (k ^ -0.5) * ((n * (pi * 2.0)) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{k}^{-0.5} \cdot {\left(n \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Initial program 99.3%
expm1-log1p-u96.0%
expm1-udef77.2%
inv-pow77.2%
sqrt-pow277.2%
metadata-eval77.2%
Applied egg-rr77.2%
expm1-def96.0%
expm1-log1p99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (if (<= k 1e-16) (* (pow k -0.5) (pow (/ 0.5 (* PI n)) -0.5)) (sqrt (/ (pow (* PI (* n 2.0)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 1e-16) {
tmp = pow(k, -0.5) * pow((0.5 / (((double) M_PI) * n)), -0.5);
} 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 <= 1e-16) {
tmp = Math.pow(k, -0.5) * Math.pow((0.5 / (Math.PI * n)), -0.5);
} 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 <= 1e-16: tmp = math.pow(k, -0.5) * math.pow((0.5 / (math.pi * n)), -0.5) 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 <= 1e-16) tmp = Float64((k ^ -0.5) * (Float64(0.5 / Float64(pi * n)) ^ -0.5)); 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 <= 1e-16) tmp = (k ^ -0.5) * ((0.5 / (pi * n)) ^ -0.5); else tmp = sqrt((((pi * (n * 2.0)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1e-16], N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(0.5 / N[(Pi * n), $MachinePrecision]), $MachinePrecision], -0.5], $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 10^{-16}:\\
\;\;\;\;{k}^{-0.5} \cdot {\left(\frac{0.5}{\pi \cdot n}\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 9.9999999999999998e-17Initial program 99.0%
unpow-prod-down98.7%
unpow-prod-down99.0%
div-sub99.0%
metadata-eval99.0%
pow-sub99.2%
pow1/299.2%
associate-*r/99.2%
inv-pow99.2%
sqrt-pow299.3%
metadata-eval99.3%
associate-*l*99.3%
associate-*l*99.3%
div-inv99.3%
metadata-eval99.3%
Applied egg-rr99.3%
*-commutative99.3%
associate-/l*99.3%
associate-/r/99.4%
*-commutative99.4%
associate-*l*99.4%
*-commutative99.4%
associate-*l*99.4%
*-commutative99.4%
Simplified99.4%
Applied egg-rr73.4%
inv-pow73.3%
sqrt-pow273.5%
metadata-eval73.5%
Applied egg-rr73.5%
Taylor expanded in k around 0 90.3%
distribute-rgt-in90.3%
exp-sum90.9%
exp-to-pow92.3%
exp-to-pow99.3%
Simplified99.3%
if 9.9999999999999998e-17 < k Initial program 99.6%
*-commutative99.6%
div-sub99.6%
metadata-eval99.6%
div-inv99.6%
expm1-log1p-u99.6%
expm1-udef96.2%
Applied egg-rr96.2%
expm1-def99.6%
expm1-log1p99.6%
*-commutative99.6%
associate-*l*99.6%
Simplified99.6%
Final simplification99.4%
(FPCore (k n) :precision binary64 (/ (pow (* n (* PI 2.0)) (- 0.5 (/ k 2.0))) (sqrt k)))
double code(double k, double n) {
return pow((n * (((double) M_PI) * 2.0)), (0.5 - (k / 2.0))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow((n * (Math.PI * 2.0)), (0.5 - (k / 2.0))) / Math.sqrt(k);
}
def code(k, n): return math.pow((n * (math.pi * 2.0)), (0.5 - (k / 2.0))) / math.sqrt(k)
function code(k, n) return Float64((Float64(n * Float64(pi * 2.0)) ^ Float64(0.5 - Float64(k / 2.0))) / sqrt(k)) end
function tmp = code(k, n) tmp = ((n * (pi * 2.0)) ^ (0.5 - (k / 2.0))) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 - N[(k / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(n \cdot \left(\pi \cdot 2\right)\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.3%
associate-*l/99.4%
*-lft-identity99.4%
sqr-pow99.2%
pow-sqr99.4%
*-commutative99.4%
associate-*l/99.4%
associate-/l*99.4%
metadata-eval99.4%
/-rgt-identity99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (* (pow k -0.5) (pow (/ 0.5 (* PI n)) -0.5)))
double code(double k, double n) {
return pow(k, -0.5) * pow((0.5 / (((double) M_PI) * n)), -0.5);
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) * Math.pow((0.5 / (Math.PI * n)), -0.5);
}
def code(k, n): return math.pow(k, -0.5) * math.pow((0.5 / (math.pi * n)), -0.5)
function code(k, n) return Float64((k ^ -0.5) * (Float64(0.5 / Float64(pi * n)) ^ -0.5)) end
function tmp = code(k, n) tmp = (k ^ -0.5) * ((0.5 / (pi * n)) ^ -0.5); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(0.5 / N[(Pi * n), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{k}^{-0.5} \cdot {\left(\frac{0.5}{\pi \cdot n}\right)}^{-0.5}
\end{array}
Initial program 99.3%
unpow-prod-down77.7%
unpow-prod-down99.3%
div-sub99.3%
metadata-eval99.3%
pow-sub99.6%
pow1/299.6%
associate-*r/99.6%
inv-pow99.6%
sqrt-pow299.7%
metadata-eval99.7%
associate-*l*99.7%
associate-*l*99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/l*99.6%
associate-/r/99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
Applied egg-rr86.8%
inv-pow86.8%
sqrt-pow286.9%
metadata-eval86.9%
Applied egg-rr86.9%
Taylor expanded in k around 0 46.8%
distribute-rgt-in46.8%
exp-sum47.0%
exp-to-pow47.7%
exp-to-pow51.1%
Simplified51.1%
Final simplification51.1%
(FPCore (k n) :precision binary64 (* (sqrt (* PI (* n 2.0))) (pow k -0.5)))
double code(double k, double n) {
return sqrt((((double) M_PI) * (n * 2.0))) * pow(k, -0.5);
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI * (n * 2.0))) * Math.pow(k, -0.5);
}
def code(k, n): return math.sqrt((math.pi * (n * 2.0))) * math.pow(k, -0.5)
function code(k, n) return Float64(sqrt(Float64(pi * Float64(n * 2.0))) * (k ^ -0.5)) end
function tmp = code(k, n) tmp = sqrt((pi * (n * 2.0))) * (k ^ -0.5); end
code[k_, n_] := N[(N[Sqrt[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[k, -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\pi \cdot \left(n \cdot 2\right)} \cdot {k}^{-0.5}
\end{array}
Initial program 99.3%
associate-*l/99.4%
*-lft-identity99.4%
sqr-pow99.2%
pow-sqr99.4%
*-commutative99.4%
associate-*l/99.4%
associate-/l*99.4%
metadata-eval99.4%
/-rgt-identity99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in k around inf 96.0%
Taylor expanded in k around 0 51.1%
div-inv51.0%
sqrt-unprod51.0%
*-commutative51.0%
associate-*r*51.0%
pow1/251.0%
pow-flip51.1%
metadata-eval51.1%
Applied egg-rr51.1%
Final simplification51.1%
(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-*l/99.4%
*-lft-identity99.4%
sqr-pow99.2%
pow-sqr99.4%
*-commutative99.4%
associate-*l/99.4%
associate-/l*99.4%
metadata-eval99.4%
/-rgt-identity99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in k around inf 96.0%
Taylor expanded in k around 0 51.1%
sqrt-unprod51.1%
*-commutative51.1%
associate-*r*51.1%
Applied egg-rr51.1%
Final simplification51.1%
(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 99.3%
unpow-prod-down77.7%
unpow-prod-down99.3%
div-sub99.3%
metadata-eval99.3%
pow-sub99.6%
pow1/299.6%
associate-*r/99.6%
inv-pow99.6%
sqrt-pow299.7%
metadata-eval99.7%
associate-*l*99.7%
associate-*l*99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/l*99.6%
associate-/r/99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
Applied egg-rr86.8%
inv-pow86.8%
sqrt-pow286.9%
metadata-eval86.9%
Applied egg-rr86.9%
Taylor expanded in k around 0 38.5%
Final simplification38.5%
(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-*l/99.4%
*-lft-identity99.4%
sqr-pow99.2%
pow-sqr99.4%
*-commutative99.4%
associate-*l/99.4%
associate-/l*99.4%
metadata-eval99.4%
/-rgt-identity99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in k around inf 96.0%
Taylor expanded in k around 0 51.1%
expm1-log1p-u48.1%
expm1-udef47.9%
sqrt-unprod47.9%
*-commutative47.9%
associate-*r*47.9%
sqrt-undiv35.8%
Applied egg-rr35.8%
expm1-def36.0%
expm1-log1p37.7%
associate-/l*37.7%
associate-/r/37.7%
Simplified37.7%
Final simplification37.7%
(FPCore (k n) :precision binary64 (sqrt (/ PI (/ k (* n 2.0)))))
double code(double k, double n) {
return sqrt((((double) M_PI) / (k / (n * 2.0))));
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI / (k / (n * 2.0))));
}
def code(k, n): return math.sqrt((math.pi / (k / (n * 2.0))))
function code(k, n) return sqrt(Float64(pi / Float64(k / Float64(n * 2.0)))) end
function tmp = code(k, n) tmp = sqrt((pi / (k / (n * 2.0)))); end
code[k_, n_] := N[Sqrt[N[(Pi / N[(k / N[(n * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{\pi}{\frac{k}{n \cdot 2}}}
\end{array}
Initial program 99.3%
associate-*l/99.4%
*-lft-identity99.4%
sqr-pow99.2%
pow-sqr99.4%
*-commutative99.4%
associate-*l/99.4%
associate-/l*99.4%
metadata-eval99.4%
/-rgt-identity99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in k around inf 96.0%
Taylor expanded in k around 0 51.1%
expm1-log1p-u48.1%
expm1-udef47.9%
sqrt-unprod47.9%
*-commutative47.9%
associate-*r*47.9%
sqrt-undiv35.8%
Applied egg-rr35.8%
expm1-def36.0%
expm1-log1p37.7%
associate-/l*37.7%
Simplified37.7%
Final simplification37.7%
herbie shell --seed 2023272
(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))))