letsimp problems



Hi,

I am just trying to get into the Maxima mindset, so bear with me if I
have missed something obvious.

I want to teach maxima to deal with spherical harmonics, especially
expanding products of spherical harmonics into a Clebsch-Gordan series
(expressing the product of two Y(n1,m1)*Y(n2,m2) as a sum of Y(n,m)).
Here is what I have done so far:

,----
| (C1) matchdeclare(m1,true)$
| (C2) matchdeclare(m2,true)$
| (C3) matchdeclare(n1,true)$
| (C4) matchdeclare(n2,true)$
| (C5) let([Y(n1,m1)*Y(n2,m2),
|   sum(sqrt((2*n1+1)*(2*n2+1)/(4*%pi*(2*n+1)))*clebsch_gordan(n1,n2,n,0,0,0)
|     *clebsch_gordan(n1,n2,n,m1,m2,m1+m2)*Y(n,m1+m2),n,abs(n1-n2),n1+n2)],
|   spher_prod)$
`----

Which works fine in general, e.g.

,----
| (C6) letsimp(Y(1,0)*Y(2,1),spher_prod);
| (D6) SQRT(15) clebsch_gordan(2, 1, 3, 0, 0, 0) clebsch_gordan(2, 1, 3, 1, 0, 1)
| 
|  Y(3, 1)/(2 SQRT(7) SQRT(%PI)) + SQRT(3) Y(2, 1)
| 
|  clebsch_gordan(2, 1, 2, 0, 0, 0) clebsch_gordan(2, 1, 2, 1, 0, 1)
| 
| /(2 SQRT(%PI)) + SQRT(5) Y(1, 1) clebsch_gordan(2, 1, 1, 0, 0, 0)
| 
|  clebsch_gordan(2, 1, 1, 1, 0, 1)/(2 SQRT(%PI))
`----

But when n1=n2 and m1=m2, the simplification does not recognize the
two Y(n1,m1) as a product, but rather as a power: 

,----
| (C7) letsimp(Y(1,0)*Y(1,0),spher_prod);
| 				    2
| (D7) 				   Y (1, 0)
`----

Any ideas how to fix this, short of writing a special rule just for
squares of Y(n,m)? Maybe letsimp is not the way to go. But the
solution should also work when the product is multiplied by some
numbers and multiple such terms occur in a sum.

Any ideas to set me going?

Thanks, Reimar