29 January, 2010

A bug in Mathematica: Clebsch-Gordan coefficients

A technical issue for those of you using Wolfram Mathematica. Apparently there is a bug in the function furnishing Clebsch-Gordan coefficients, check it out:


These two inputs are equivalent, but the outputs are different somehow. Actually, this Clebsch-Gordan coefficient is zero, because the angular momentum j=9/2 cannot give a projection of m=0. In general, for a coefficient to be nonzero all the (j+m)'s should be nonnegative integer numbers.

The ClebschGordan[] function in Mathematica is used to test all the conditions of existence, such as the triangle rule, but as we see it fails when it comes to substitutions of parameters.

I dropped a message to the Wolfram support team, and they promised to do their best to figure out where the problem comes from. I hope to hear from them soon and I'll keep you posted about it.

Take care,

Misha

8 comments:

Sander said...

Executing ClebschGordan[{9/2, 0}, {2, 0}, {9/2, 0}] already gives an error:
ClebschGordan::phy

Look in the manual at:
ref/message/ClebschGordan/phy

Lemeshko said...

Dear Sander, thanks for the comment.

Actually that's out of discussion whether ClebschGordan[{9/2, 0}, {2, 0}, {9/2, 0}] is physical or not, it isn't.

The question is, why there is no error (and a nonzero output) in the second line.

Apparently, working with symbols (like "j" over there), Mathematica assumes that all the existence conditions are O.K., and fails upon substitution of a non-physical value.

Sander said...

I think it first evaluates the ClebschGordan assuming j is 'good', and once it found the analytic expression, you substitute an invalid value for j...

Lemeshko said...

I think so, the question is why it does it. That's a bug, isn't it?

That would be unfair to check every single Clebsch-Gordan coefficient by hands...

Sander said...

You could use something like:

Hold[ClebschGordan[{j, 0}, {2, 0}, {j, 0}]] /. j -> 9/2
Release[%]

or

With[{j = 9/2}, ClebschGordan[{j, 0}, {2, 0}, {j, 0}]]

first substitution, then evaluation...

Lemeshko said...

Sander, thanks for a tip. )

Of course, I can. I just accidentally bumped on this issue and want the support team and Mathematica users to be aware of it. )

Sander said...

Or even check the order using Trace or related functions:

Trace[ClebschGordan[{j, 0}, {2, 0}, {j, 0}] /. j -> 9/2] // Column

Lemeshko said...

Thanks again, Sander. )

Misha