My code uses `ClebschGordan` but `Mathematica` is using `ThreeJSymbol`

I’m using a function that calculate CG coefficients with the function
ClebschGordan but instead, I’ve got the following error because Mathematica is using ThreeJSymbol:

ClebschGordan::phy: “ThreeJSymbol[{1/2,1/2},{0,0},{1/2,1/2}] is not physical.

I know that this 3JSymbols isn’t physical but is a valid value for a CG coefficient:

ClebschGordan[{1/2, 1/2}, {0, 0}, {1/2, 1/2}]

gives 1 as result.

Edit: Here is all the code and the actual code that I’m running.

GeneradorQs[M_] :=
Module[{l = Length[M], q, i}, q = {M[[l]] + M[[l – 1]]};
Table[AppendTo[q, q[[i]] + M[[l – (i + 1)]]], {i, 1, l – 3}];

RangoAngular[j_] := Table[m, {m, -j, j}]

QVD[k_, q_] :=
Module[{i, total = 0},
For[i = 1, i <= Length[k], i++, If[MemberQ[RangoAngular[k[[i]]], q[[i]]], total += 1]]; If[total == Length[k], True, False]] Mexico[k_, q_, M_, j_, m_] := Module[{l = Length[M], prod = 0, i}, prod = ClebschGordan[{1/2, M[[l - 1]]}, {1/2, M[[l]]}, {k[[1]], q[[1]]}]; For[i = 1, i <= l - 3, i++, prod *= ClebschGordan[{1/2, M[[l - i]]}, {k[[i]], q[[i]]}, {k[[i + 1]], q[[i + 1]]}]]; prod *= ClebschGordan[{1/2, M[[1]]}, {k[[l - 2]], q[[l - 2]]}, {j, m}]] Lapiz[K_, M_, j_, m_] := If[Total[M] == m && QVD[K, GeneradorQs[M]], {Mexico[K, GeneradorQs[M], M, j, m], M}, {0, M}] And I'm calling the function Lapiz with: Lapiz[{0, 1/2}, {1/2, -(1/2), 1/2, -(1/2)}, 0, 0] Edit22{}^2: The snippet: For[i = 1, i <= l - 3, i++, prod *= ClebschGordan[{1/2, M[[l - i]]}, {k[[i]], q[[i]]}, {k[[i + 1]], q[[i + 1]]}]]; have to be changed for For[i = 1, i <= l - 3, i++, prod *= ClebschGordan[{1/2, M[[l - (i-1)]]}, {k[[i]], q[[i]]}, {k[[i + 1]], q[[i + 1]]}]]; ================= ================= 1 Answer 1 ================= You probably entered ClebschGordan[{1/2,1/2},{0,0},{1/2,-1/2}] and got the warning message. This happens when you use angular-momentum quantum numbers that don't satisfy the conservation laws. In this case, the rule m1+m2=mm1+m2=mm_1+m_2=m is not met, see the documentation for ClebschGordan. However, Mathematica still produces the correct result, i.e., 0. This just says that the product state with individual angular-momentum z momenta 000 and 12\frac12 does not occur in the total-angular-momentum state with z angular momentum −12-\frac12. All you have to do is turn off the warning message, and everything will be fine: Off[ClebschGordan::phy]; See also here. In your function Mexico, you do indeed call ClebschGordan[{1/2,1/2},{0,0},{1/2,-1/2}] as I suspected. This is easily confirmed by modifying the definition of Mexico by replacing ClebschGordan by ClebschGordan1 to see what arguments the functions are getting.      Sorry but it isn't the case. The message that Mathematica shows me says that I'm doing: ClebschGordan[{1/2, 1/2}, {0, 0}, {1/2, 1/2}]. I'm thinking that the problem is somewhere else because, I've written CG[a_, b_, c_] := If[a == {1/2, 1/2} && c == {1/2, 1/2} && b == {0, 0}, 1, ClebschGordan[a, b, c]] but still giving me the same error. – David Jun 26 at 16:30      I don't understand. You'd have to post the actual input that gives rise to the warning. I get the warning you quote when I input the values I stated above. What happens if you type ClebschGordan[{1/2,1/2},{0,0},{1/2,1/2}]? You don't get any warning, or do you? If you do, what version of Mathematica are you using? – Jens Jun 26 at 16:40      I don't get any warning, just 1. But when ClebschGordan is called with the same arguments inside my functions* gives me the error that I put in the post. My functions is ``` – David Jun 26 at 16:43 1   As I said, you would have to post valid code to reproduce the problem before I can say anything else. – Jens Jun 26 at 16:44 1   You may be misunderstanding something. Probably something in your loops is wrong, but I can't guess what their purpose is. CG invokes ThreeJSymbol but that has the rule that the m indices add up to minus the total m. The error corresponds exactly to the incorrect invocation I mentioned, and everything is the way it should be. The warning does deserve to be turned off when you know what you're doing. In your case, the warning probably points to a separate error that is specific to your loop. – Jens Jun 26 at 17:24