I'm looking for the number of integer partitions for a total N, with a number of parts S, having a maximum part that is exactly X, without enumerating all of them.
For example: all partitions of 100 that have 10 parts and 42 as the largest part.
I've found no theorems or partitioning identities that address this question and I suspect that is a non-trivial problem that is not easily derived from known theorems (e.g. Nijenhuis and Wilf 1978, Andrews et al. 2004, Bona 2006):
For example: The number of partitions of N with exactly S parts equals the number of partitions of N with exactly S as the largest part.
This question is related to my research, which is far-outside pure math.
Update: This question is answered below but I wanted to post the Python script I used to implement it. I'll probably push it through Cython to get some speed.
n = 100 # the total
s = 10 # number of parts
x = 20 # largest part
print Partitions(n,length=s,max_part=x).cardinality() # Sage is very slow at this
def parts_nsx(n,s,x):
if n==0 and s==0:return 1
if n<=0 or s<=0 or x<=0:return 0
if n>0 and s>0 and x>0:
_sum = 0
for i in range(0,s+1):
_sum += parts_nsx(n-i*x, s-i, x-1)
return _sum
print parts_nsx(n,s,x)
P(n,s,x) = 0 if n>s*x, 1 if n==s*x, upper sum if n<s*x
– Crosspollination