(*  clebsch_gordan_values.nb *)
(* *)
(*  Purpose: *)
(*    Evaluate the Clebsch-Gordan coefficient*)
(*    at selected argument values *)
(*    and write the data to a file. *)
(* *)
(*  Modified:  09 February 2007 *)
(*  Author:  John Burkardt *)

j1vec={ 1/2,1/2,1/2,1,1,1,1,1,2,2,1/2,3/2};
j2vec={ 1/2,1/2,1,3/2,3/2,3/2,1,1,2,2,2,2};
j3vec={ 1,1,3/2,3/2,3/2,3/2,2,2,2,2,5/2,7/2};
m1vec={  1/2,1/2,-1/2,0,-1,0,1,0,2,1,1/2,3/2};
m2vec={ -1/2,1/2,1,1/2,3/2,3/2,-1,0,-2,-1,1,-1};
m3vec={0,1,1/2,1/2,1/2,3/2,0,0,0,0,3/2,1/2};
fvec = {};
num = Length [ j1vec ];

Do [ { j1= j1vec[[i]], 
       j2=j2vec[[i]],
      j3 = j3vec[[i]],
      m1 = m1vec[[i]],
      m2 = m2vec[[i]],
      m3 = m3vec[[i]],
     f=ClebschGordan[{j1,m1},{j2,m2},{j3,m3}],fvec = Append [ fvec, f],
      Print["CG[{",j1,",",m1,"},{",j2,",",m2,"},{",j3,",",m3,"} = ",N[f,16]] },{i,1,num,1}]

fileout=OpenWrite["C:\\Documents and Settings\\burkardt.BURKARDTPC\\Desktop\\Misc\\mathematica\\clebsch_gordan_values.txt"];
SetOptions[fileout,FormatType->TextForm];
Write[fileout,"#  clebsch_gordan_values.txt"];today=DateList[];Write[fileout,"#  Created on ",today];Write[fileout,"#"];
Write[fileout,"#  j1  m1  j2  m2  j3  m3  f"];
Write[fileout,"#"];
Do[{j1=j1vec[[i]];m1=m1vec[[i]];j2=j2vec[[i]];m2=m2vec[[i]];j3=j3vec[[i]];m3=m3vec[[i]];f=fvec[[i]];Write[fileout,N[j1,2],"  ",N[m1,2],"  ",N[j2,2],"  ",N[m2,2],"  ",N[j3,2],"  ",N[m3,2],"  ",N[f,16]]},{i,1,num,1}];Close[fileout];