Calling spherical_harmonic(l,m,theta,phi) from orthopoly does not work for m != 0:
load(orthopoly);
(%o2) /tmp/local-finken/maxima/5.16post/share/orthopoly/orthopoly.lisp
(%i3) spherical_harmonic(2,2,theta,phi);
Bad argument to `genfact'
-- an error. Entering the Maxima Debugger dbm
Enter `:h' for help
The problem is that `%genfact' is called with arguments (2m-1), (m+1/2), 2 in `assoc-leg-cos'. According to the definition of genfact, this is a product, where the last factor vanishes. I don't know the exact relation between ultraspherical polynomials and the associated legendre functions, but replacing the (m+1/2) with (m-1/2) in the call successfully reproduces the spherical harmonics up to l=2 from Mathematica (modulo the (-1)^m phase). In addition, the tests from test_orthopoly.mac now pass. The patch to orthopoly.lisp is attached.
For the record:
(%i8) build_info();
Maxima version: 5.16post
Maxima build date: 14:30 12/5/2008
host type: i686-suse-linux-gnu
lisp-implementation-type: CMU Common Lisp
lisp-implementation-version: Snapshot 2008-11 (19E)
patch to share/orthopoly/orthopoly.lisp
Thanks for the bug report and the fix; the bug should be fixed in orthopoly.lisp CVS revsion 1.12.
The bug was caused by recent changes to %genfact. Thanks for the help.