Is there a formula for calculating partitions with restrictions?

  • Thread starter oleg-mary
  • Start date
  • Tags
    partitions
In summary, the conversation discusses the search for a solution to the problem of calculating p(N,K,L), which represents the number of partitions of N into no more than K parts not exceeding L. The conversation mentions the different formulas and algorithms that have been found, but none that can handle high parameters efficiently. It is stated that the problem is likely a P problem in information theory, and will require a formula to be solved efficiently.
  • #1
oleg-mary
3
0
After long and careful search on the web and in literature,
I could not find the solution of the following problem.

I need calculate p(N,K,L) - the number of partitions of N into
no more than K parts not exceeding L.

Example: N = 7, K = 4, L = 5

1) 2+5
2) 3+4
3) 1+1+5
4) 1+2+4
5) 1+3+3
6) 2+2+3
7) 1+1+1+4
8) 1+1+2+3
9) 1+2+2+2

So, here is p(7,4,5)=9

I found the different formulas for the partitions with different restrictions,
but not both for quantity and size of parts.
May be I was bad looking, but might be the solution has not yet been found?

Of course, it is not a problem to write search algorithms, to solve this problem,
as in Pascal:

*********************************************************************

var K,L,M,i,i1,i2,itog:longint; b:real;
Code:integer;

procedure Box(pr:longint;ostatok:longint;nbox:longint);
var j1,j2,j:longint;
a: real;
begin
a:=ostatok/nbox;
if frac(a)>0
then j1:=trunc(a)+1
else j1:=trunc(a);
if pr>ostatok then j2:=ostatok else j2:= pr;
for j:=j1 to j2 do
if nbox>1 then Box(j,ostatok-j,nbox-1) else itog:=itog+1
end;

begin

val(ParamStr(1),K,Code);
val(ParamStr(2),L,Code);
val(ParamStr(3),M,Code);
{
writeln(K);
writeln(L);
writeln(M);
}
itog:=0;
If L*M<K Then writeln('It is impossible')
Else
begin
If M>K Then i2:=K Else i2:=M;
b:=K/L;
If frac(b)>0 Then i1:=trunc(b)+1 Else i1:=trunc(b);

For i:=i1 to i2 do Box(i,K-i,L-1)

end;
writeln (Itog)
end.

**********************************************************

but it bogged down with a slight increase of parameters.
Roughly speaking, if the value of parameters begins to run into the hundreds,
then modern computer begins to squeak.

Is there some "nice" formula to calculate p(N,K,L) ?
 
Last edited:
Physics news on Phys.org
  • #2
Nobody knows, but it seems unlikely that a formula exists.
 
  • #3
Not really answering your question, but a generating function should not be very hard to find.

Also, check out http://www.btinternet.com/~se16/js/partitionstest.htm if you haven't done that already.
 
Last edited by a moderator:
  • #4
The question was if there is a "nice" formula, not a "nice" algorithm. The formula, for now, isn't discovered, maybe it doesn't exists, but the algorithm to calculate p(n,l,k) is easy to make.
 
  • #5
Easy-to-make algorithms will go into deep-deep recursion, so it is not easy to make really fast one.
For example, shown code in Pascal will fall even on low parameters like p(200,20,20).
After some thinking I wrote algorithm which gives result in suitable time for p(125000,500,500).
It uses arbitrary length integer arithmetics and gives result of near thousand bits.
But I need about p(millions,thousands,thousands) job.
 
  • #6
In this case the problem is a P problem in information theory, in other words the time to calculate p(n,l,k) is Polynomial, so it will spend more time to calculate p(millions,thousands,thousands). Only a formula will give you a gift, but it is not discovered yet, and maybe it's likely that it doesn't exist.
 

1. What are partitions with restrictions?

Partitions with restrictions refer to the process of dividing a set of objects into subsets, with the additional constraint that certain elements must be included in specific subsets. These restrictions can be based on factors such as size, color, or type of object.

2. Why are partitions with restrictions important in science?

Partitions with restrictions are important in science because they allow researchers to analyze data in a more precise and focused manner. By dividing a set of objects into subsets based on specific criteria, researchers can gain a deeper understanding of the relationships between the different elements.

3. How are partitions with restrictions used in statistical analysis?

In statistical analysis, partitions with restrictions can be used to group data into distinct categories and then compare the results between these categories. This can provide valuable insights into patterns and trends within the data.

4. Can partitions with restrictions be applied in other fields besides science?

Yes, partitions with restrictions can be applied in a variety of fields including mathematics, computer science, and economics. In mathematics, partitions with restrictions are used in number theory to study the properties of integers. In computer science, they are used in data clustering algorithms. And in economics, they can be used to analyze consumer behavior and market trends.

5. What are some potential challenges when working with partitions with restrictions?

One potential challenge when working with partitions with restrictions is determining the most appropriate criteria for dividing the data. This can often be a subjective decision and may require a thorough understanding of the data and its underlying patterns. Additionally, the size and complexity of the data set can also pose challenges when creating partitions with restrictions.

Similar threads

  • Linear and Abstract Algebra
Replies
8
Views
776
  • Advanced Physics Homework Help
Replies
1
Views
1K
  • Atomic and Condensed Matter
Replies
3
Views
857
  • Linear and Abstract Algebra
Replies
8
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
2K
  • Linear and Abstract Algebra
Replies
2
Views
954
  • Linear and Abstract Algebra
Replies
3
Views
979
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
592
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Linear and Abstract Algebra
Replies
6
Views
1K
Back
Top