bugs with integer_partitions



Hi,

(%i2) integer_partitions(0);
(%o2) {}

which is wrong: it must be {[]}.

The documentation of integer_partitions correctly states

"A list [a_1, ..., a_m] is a partition of a nonnegative integer n
     when (1) each a_i is a nonzero integer, and (2) a_1 + ... + a_m =
     n."

Unfortunately, then follows:

"Thus 0 has no partitions."

while obviously from the definition it follows that [] is the unique
partition of 0.

The partition function p(n), which counts the number of
partitions of n, is accordingly defined as p(0) = 1.

See any book on number theory, or e.g.
http://en.wikipedia.org/wiki/Partition_(number_theory).
Or see http://www.research.att.com/~njas/sequences/A000041.
(For example, S_0 is the trivial group, the same as S_1,
and thus p(0) = p(1) = 1.)

Another bug: The documentation states that n is an integer.
However:

(%i4) integer_partitions(-1);
(%o4) int_partitions(-1)

The value is {} for negative n. The corrected integer_partition is

corrected_integer_partitions(n) :=
 if n < 0 then {}
 elseif n = 0 then {[]}
 else integer_partitions(n)$

Oliver