Skip to content

Commit

Permalink
MSET + partitions gen. funct. + Integers gen funct + refactoring and …
Browse files Browse the repository at this point in the history
…renaming
  • Loading branch information
fargolo committed Oct 7, 2023
1 parent 9c4d4d9 commit a1bcab3
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/AnalyticComb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 0 additions & 2 deletions src/binary_words.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ function W_coeff(r;n_tot=200)
end




"""
p_binary_words_doub_runl(k,n)
Expand Down
8 changes: 4 additions & 4 deletions src/asymptotics.jl → src/misc.jl
Original file line number Diff line number Diff line change
@@ -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))

24 changes: 22 additions & 2 deletions src/operators.jl
Original file line number Diff line number Diff line change
@@ -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))
33 changes: 29 additions & 4 deletions src/parts_comps.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit a1bcab3

Please sign in to comment.