I have a question: Is't possible Mathematica doesn't plot the function when the values of l1 and l2 are the same? What should I add to the cycle?

In[1]:= Psi1[l1_,m1_,l2_,m2_]:=Sqrt[(2*l1+1)/(4*Pi)]*LegendreP[l1,m1,Cos[theta1]]*Sqrt[(2*l2+1)/(4*Pi)]*LegendreP[l2,m2,Cos[theta2]]-Sqrt[(2*l1+1)/(4*Pi)]*LegendreP[l1,m1,Cos[theta2]]*Sqrt[(2*l2+1)/(4*Pi)]*LegendreP[l2,m2,Cos[theta1]]

In[2]:= Den1[l1_,m1_,l2_,m2_]:=1/2*Psi1[l1,m1,l2,m2]^2

In[3]:= Dens1[l1_,m1_,l2_,m2_]:=Plot3D[Integrate[Den1[l1,m1,l2,m2],{phi1,0,2*Pi},{phi2,0,2*Pi}]*Sin[theta1]*Sin[theta2],{theta1,0,Pi},{theta2,0,Pi}]

In[4]:= Do[Print[{l1,l2,Dens1[l1,m1,l2,m2]}],{l1,0,5},{l2,0,5},{m1,0,0},{m2,0,0}]

Your function vanishes when l1=l2 and m1=m2 as

Psi1[l, m, l, m] $\mapsto$ 0.

If you want non-vanishing same-$l$ situations, you should distinguish $m1$ and $m2$.

Let's add all labeling to the plot just so it's clear:

Dens1[l1_, m1_, l2_, m2_] := 
    Den1[l1, m1, l2, m2], {phi1, 0, 2*Pi}, {phi2, 0, 2*Pi}]*
   Sin[theta1]*Sin[theta2], {theta1, 0, Pi}, {theta2, 0, Pi}, 
  PlotLabel -> 
   Grid[{{Subscript[l, 1] -> l1, 
      Subscript[m, 1] -> m1}, {Subscript[l, 2] -> l2, 
      Subscript[m, 2] -> m2}}]]

Now physically $m$ can only range from -$l$ to $l$. If you only want to print when it isn't uniformly zero you can add an if statement:

Do[Do[If[l1 =!= l2 || m1 =!= m2, 
   Print[{l1, l2, Dens1[l1, m1, l2, m2], m1, m2}]], {m1, -l1, 
   l1}, {m2, -l2, l2}], {l1, 0, 5}, {l2, 0, 5}]

yielding e.g.

l1l1m-1m0 plot

The logic in the if statement is probably clear, but in english, only evaluate if the $l$s are different, or if the $l$s are the same as long as the $m$s are different.

  • $\begingroup$ That's right. For this reason, I'm looking some Mathematica tool that excludes from the calculation all cases when l1=l2. $\endgroup$ – Arturo García Flores Aug 19 '17 at 3:32
  • $\begingroup$ Are you looking for the right place to put an If statement? i.e. Only do the evaluation if ls are different or if m's are different? I've updated my answer. $\endgroup$ – John Joseph M. Carrasco Aug 19 '17 at 6:04
  • $\begingroup$ Yes, man, that's what I was looking for. Since the function is antisymmetric, it makes no sense to plot the density when l1=l2, or to run another type of computation involving these cases. For a symmetric function, I'm interested in cases when l1 and l2 are the same (and different, of course) but there I have no problem. On the other hand, at this moment I'm interested in cases when m1=m2=0. Thank you very much! $\endgroup$ – Arturo García Flores Aug 19 '17 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.