bugs in function stirling1() in version 5.21.1 (and up?)
Subject: bugs in function stirling1() in version 5.21.1 (and up?)
From: Barton Willis
Date: Tue, 17 Dec 2013 12:32:18 +0000
Another documentation bug is
Maxima uses a recursion relation to define stirling1 (n, m) for m less than 0; it is undefined
for n less than 0 and for non-integer arguments.
This is wrong--striling1 returns a nounform when the second argument is a negative integer:
(%i6) stirling1(8,-25);
(%o6) stirling1(8,-25)
I suppose http://dlmf.nist.gov/26.8.E18 provides the recursion that extends striling1 to the
negative second arguments, but I haven't thought about it all that much.
For striling1, I have putative fixes to the code and the user documentation. My revised user documentation
uses the dlmf as a reference and it hyperlinks to the dlmf. If folks generally agree that referencing
dlmf is better than a reference to Concrete Math, I'll similarly repair striling2.
@anchor{stirling1}
@deffn {Function} stirling1 (@var{n}, @var{k})
Represents the Stirling number of the first kind. When @var{n} and @var{k} are nonnegative
integers, @code{stirling1 (@var{n}, @var{k})} is @math{(-1)^(n-k)} times the number of
permutations of a set with @var{n} members that have @var{k} cycles.
@code{stirling1} is a simplifying function. For literal or declared arguments @math{n}
and @math{k}, the simplifications for @code{stirling1} are
@enumerate
@item
@math{stirling1(1, k) = kron_delta(0, k), k >= 0} @url{http://dlmf.nist.gov/26.8.E2}
@item
@math{stirling1(n, n) = 1, n >= 0}, @url{http://dlmf.nist.gov/26.8.E1}
@item
@math{stirling1(n, n - 1) = -binomial(n, 2), n >= 1} @url{http://dlmf.nist.gov/26.8.E16}
@item
@math{stirling1(n, 0) = 0, n >= 1} @url{http://dlmf.nist.gov/26.8.E14}
@item
@math{stirling1(n, 1) = (-1)^(n-1) (n-1)!, n >= 1} @url{http://dlmf.nist.gov/26.8.E14}
@end enumerate
Examples:
@c ===beg===
@c declare (n, integer)$
@c assume (n >= 0)$
@c stirling1 (n, n);
@c ===end===
@example
(%i1) declare (n, integer)$
(%i2) assume (n >= 0)$
(%i3) stirling1 (n, n);
(%o3) 1
@end example
Simplifications of @code{stirling1}:
@c ===beg===
@c declare (n, integer)$
@c assume (n >= 0)$
@c stirling1 (n + 1, n);
@c stirling1 (n + 1, 1);
@c ===end===
@example
(%i1) declare (n, integer)$
(%i2) assume (n >= 0)$
(%i3) stirling1 (n + 1, n);
n (n + 1)
(%o3) - ---------
2
(%i4) stirling1 (n + 1, 1);
n
(%o4) (-1) * n!
@end example
@opencatbox
@category{Integers}
@closecatbox
Finally, the text above http://dlmf.nist.gov/26.8.E14 requires that n >= 1, but clicking the i box on the
right side only requires that n is non negative. Let's be careful out there.
--Barton
________________________________________
From: maxima-bounces at math.utexas.edu <maxima-bounces at math.utexas.edu> on behalf of Barton Willis <willisb at unk.edu>
Sent: Monday, December 16, 2013 21:28
To: Bernhard Marx; maxima at math.utexas.edu
Subject: Re: [Maxima] bugs in function stirling1() in version 5.21.1 (and up?)
Would the dlmf be a better reference than Concrete Mathematics?
I think that ( http://dlmf.nist.gov/26.8.E17)
stirling2(n,2) = 2^(n-1)-1, n >= 1
is correct. Further,
(%i18) makelist(stirling2(n,2) = 2^(n-1)-1,n,1,6);
(%o18) [0=0,1=1,3=3,7=7,15=15,31=31]
The user documentation gives the bogus stirling1(n + 1, 2) = 2^n - 1 . Here I think it's only the
user documentation that needs fixing.
As for
(%i36) assume(n>0)$
(%i37) stirling1(n+1,1);
(%o37) n!
(%i38) stirling1(6,1);
(%o38) -120
The code and user documentation are incorrect. (see http://dlmf.nist.gov/26.8.E14 )
Finally, I wouldn't necessarily think that
m!*stirling2(n,m) --> sum(binomial(m,k)*k^n*(-1)^(m-k),k,0,m)
is a simplification. Likely it should be deleted from the user documentation.
Thanks for your interest in the stirling code--I'll see what I can do to fix the code and the user
documentation. If you have more suggestions, please send them to the list. To report a bug
on sourceforge, you'll need an account...sigh.
I'm not sure that the Stirling code has been used all that much--likely there are more bugs.
--Barton
________________________________________
From: maxima-bounces at math.utexas.edu <maxima-bounces at math.utexas.edu> on behalf of Bernhard Marx <b.w.marx at gmx.de>
Sent: Monday, December 16, 2013 16:53
To: maxima at math.utexas.edu
Subject: bugs in function stirling1() in version 5.21.1 (and up?)
Because i can make neither head nor tail
from the "bug reporting" at sourceforge,
i write to this list.
For the rest of this text "You" adresses persons
documenting. maintaining or developing Maxima.
That said:
To whom it may concern!
Maxima (as do other programs. e.g. PARI/gp) computes
integers (as values of stirling1()) with alternating signs,
whereas Concrete Math 2nd ed defines them non-negative.
This should be stressed in the documentation, where it is
now hidden (a bit) by
"the magnitude of stirling1 (n, m) is the number of permutations of
a set with n members that have m cycles".
This is not a bug but a nuisance -- at least to me.
The bugs are the following, consistently in the program and its documentation:
stirling1(n+1,2) simplifies to 2^n-1,
which is simply not true, even when disregarding the signs
(with H(n):=sum(1/k,k,1,n); it should be
stirling1(n+1,2) simplifies to H(n)*n!*(-1)^(n-1)
). although the numbers computed for instantiated
n are correct (modulo the previous remark).
The simplifications
stirling1(n+1,1) to n! and
stirling1(n+1,n) to binomial(n,2)
would only be true, had you defined the function stirling1()
to return non-negative values (which you don't)
and thus should be
stirling1(n+1,1) to (-1)^n*n! and
stirling1(n+1,n) to -binomial(n,2)
Furthermore there are some typos in the documentation of the function
stirling2().
Concrete Math 2nd ed eqn. (6.19) states for m,n >= 0
m!*stirling2(n,m) = sum(binomial(m,k)*k^n*(-1)^(m-k),k,0,m)
but for this to work also for stirling2(0,0), 0^0 would have to be
defined as 1, which is not the standart with Maxima.
I couldn't provoke this simplification anyway in the program,
so it might as well be taken out of the documentation.
Maxima version: 5.21.1
Maxima build date: 8:13 4/26/2010
Host type: i686-pc-mingw32
Lisp implementation type: GNU Common Lisp (GCL)
Lisp implementation version: GCL 2.6.8
With best regards,
Bernhard W. Marx
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima