1

I'm looking for an efficient way to compute the number of partitions of integer for which the xor is zero: F(n,c) = #{ (x1,x2, ... ,xc) | x1 + x2 + ... + xc = n & x1 xor x2 xor ... xor xc = 0 }

For little values of n and c, it's easy to run nested loops to compute those values. But for larger values, it's not tractable. I'd like to obtain a closed form or at least a recursive formula which allow dynamic programming..

Chris Gerken
  • 16,221
  • 6
  • 44
  • 59
  • It might be worth considering an alternative way of expressing the constraint on the partition, which is that the frequency of each integer in the partition must to be even. – Paul R Nov 22 '11 at 09:45

1 Answers1

1

Unless your problem's constraints lead to a particularly clever and very unobvious solution, I believe you are asking an exceedingly difficult question which would be at the state of the art of research mathematics.

First, counting just plain unrestricted partitions of an integer (that is, counting the number of distinguishable, order-independent ways of representing an integer as a sum of positive integers) is a deep mathematical problem with a history hundreds of years old.

http://en.wikipedia.org/wiki/Partition_%28number_theory%29#Partition_function_formulas

You have some additional unorthodox constraints---first that you only want the subset of partitions with a given number of terms (that may make it easier), and then that, I presume, a constraint on the XOR of the binary representation of the terms, which would probably be very difficult to handle.

How big do you intend n to be? The reference above says that p(1000) is roughly 2.44 * 10^31.

If n is big, do you also believe that c will be small? That would greatly simplify things.

To solve your problem you need to engage the interest of a research mathematician specializing in this field.

www.aimath.org/news/partition/

You might try Math Overflow using "Partitions" as a keyword.

I found this thread about partitioning into exactly c (they use 'k' for this part) individual parts, which is the first (easier) constraint of yours.

https://mathoverflow.net/questions/72418/what-are-the-best-known-bounds-on-the-number-of-partitions-of-n-into-exactly-k

Community
  • 1
  • 1
drchaos
  • 21
  • 2
  • You're right, this is not an easy question. When I say large integers, that means F(100,10) and F(10^6,100). Of course, I'll need infinite precision to do that. – user1059422 Nov 22 '11 at 09:43
  • F(10^6,100) is totally intractable. For say N <= 100, I'd find some generator of partitions, and brute force the thing and store it in a table. – drchaos Nov 22 '11 at 09:49
  • From the math overflow comment, they point to eq 2.27 for your problem without XOR constraints. These are approximations, not exact numbers of course. http://dl.dropbox.com/u/5188175/2101859.pdf. – drchaos Nov 22 '11 at 09:53
  • From @Paul R's comment, I think this means that F(n,c) = p(n/2,c) for even n, and zero for odd n, where p(m,k) is the # of partitions of m with k terms. (please check!) This will help connect to the literature. It grows (fixed k) as m^(k-1). – drchaos Nov 22 '11 at 09:59
  • Interesting ideas. I'm going to try to check those. Thanks – user1059422 Nov 22 '11 at 10:10