diff --git a/src/AnalyticComb.jl b/src/AnalyticComb.jl index ae65057..6efcd2f 100644 --- a/src/AnalyticComb.jl +++ b/src/AnalyticComb.jl @@ -6,14 +6,14 @@ using Reexport @reexport using SymPy export - SEQ, - stirling_factorial, stirling_catalan, - partitions, primes_composition, + SEQ, MSET, + stirling_factorial_asym, stirling_catalan_asym, + I_gf, partitions_gf, partitions_asym, primes_composition_asym, restricted_sum_comp_gf, restricted_sum_comp, restricted_sum_part_gf, restricted_sum_part, p_binary_words_doub_runl include("operators.jl") -include("asymptotics.jl") +include("misc.jl") include("parts_comps.jl") include("binary_words.jl") diff --git a/src/binary_words.jl b/src/binary_words.jl index 5f29572..daba69f 100644 --- a/src/binary_words.jl +++ b/src/binary_words.jl @@ -18,8 +18,6 @@ function W_coeff(r;n_tot=200) end - - """ p_binary_words_doub_runl(k,n) diff --git a/src/asymptotics.jl b/src/misc.jl similarity index 56% rename from src/asymptotics.jl rename to src/misc.jl index 5232f67..5ab53e6 100644 --- a/src/asymptotics.jl +++ b/src/misc.jl @@ -1,18 +1,18 @@ """ - stirling_factorial(n) + stirling_factorial_asym(n) Stirling approximation for n! as (n/exp(1))^n*sqrt(2*pi*n). ``n! \\sim \\sqrt{2 \\pi n} {\\frac{n}{e}}^{n}`` """ -stirling_factorial(n) = (n/exp(1))^n*sqrt(2*pi*n) +stirling_factorial_asym(n) = (n/exp(1))^n*sqrt(2*pi*n) """ - stirling_catalan(n) + stirling_catalan_asym(n) Stirling approximation for n_th Catalan number . ``frac{4^n}{\\sqrt{\\pi n^3}}`` """ -stirling_catalan(n) = 4^n/(sqrt(pi*n^3)) +stirling_catalan_asym(n) = 4^n/(sqrt(pi*n^3)) diff --git a/src/operators.jl b/src/operators.jl index 529ffc8..4d02b32 100644 --- a/src/operators.jl +++ b/src/operators.jl @@ -1,6 +1,26 @@ """ SEQ(z) -Sequence operator +Sequence operator (Pólya quasi-inverse operator). + +Defined as ``A = SEQ(B) \\implies A(z) = \\frac{1}{1 - B(z)}``. +""" +function SEQ(z) + z = SymPy.symbols("z") + return(1/(1-z)) +end + + +""" + MSET(z) + +Multiset operator (Pólya exponential operator). + +Defined as ``A = MSET(B) \\implies A(z) = \\frac{1}{1 - B(z)}``. """ -SEQ(z) = 1/(1-z) +function MSET(z,max) + z = SymPy.symbols("z") + n = SymPy.symbols("n") + return(exp(summation(1/n * z^n,(n,1,max)))) +end +#MSET(z) = prod(1-z^n)^((-1)*(-B_n)) diff --git a/src/parts_comps.jl b/src/parts_comps.jl index 23e41ae..313c824 100644 --- a/src/parts_comps.jl +++ b/src/parts_comps.jl @@ -1,17 +1,42 @@ """ - partitions(n) + I_gf(z) + +Integers as combinatorial structures ``I(z)= \\sum{n \\geq 1}_{} z^n = \\frac{z}{1-z}`` +""" +function I_gf(z) + z = SymPy.symbols("z") + return(z*SEQ(z)) +end + +""" + partitions_gf(z,max) + +Generating function for partitions ``P(z)= \\prod{m = 1}_{\\Inf} \\frac{1}{1-z^m}``. +For instance, use `series(partitions_gf(z,10),z,0,8)` to obtain counts for n up to 8 (EIS A000041) +""" +function partitions_gf(z,max) + z = SymPy.symbols("z") + n = SymPy.symbols("n") + prod([1/(1-z^n) for n in 1:max]) +end +#MSET(I_gf(z)) yields the correct gen. function, as in page 41 (equation 38), +# but series(MSET(I_gf(z))) returns coefficients in 2^n + + +""" + partitions_asym(n) Asymptotics for partition of integers by Hardy and Ramanujan, later improved by Rademache """ -partitions(n) = (1/(4*n*sqrt(3)))*exp(pi*sqrt(2n/3)) +partitions_asym(n) = (1/(4*n*sqrt(3)))*exp(pi*sqrt(2n/3)) """ - primes_composition(n) + primes_composition_asym(n) Asymptotics for composition of primes. """ -primes_composition(n) = 0.30365 * 1.47622^n +primes_composition_asym(n) = 0.30365 * 1.47622^n """ restricted_sum_comp_gf(r)