(*  three_j_values.nb *)
(* *)
(*  Purpose: *)
(*    Evaluate the Wigner 3j coefficient*)
(*    at selected argument values *)
(*    and write the data to a file. *)
(* *)
(*  Modified:  07 February 2007 *)
(*  Author:  John Burkardt *)

j1vec={ 1, 2, 3,4,5,6,7, 8};
j2vec={ 9/2, 9/2, 9/2, 9/2, 9/2, 9/2, 9/2, 9/2};
j3vec={ 7/2, 7/2, 7/2, 7/2, 7/2, 7/2, 7/2, 7/2};
m1vec={  2/2, 2/2, 2/2, 2/2, 2/2, 2/2, 2/2, 2/2};
m2vec={ -7/2, -7/2, -7/2, -7/2, -7/2, -7/2, -7/2, -7/2};
m3vec={ 5/2, 5/2, 5/2, 5/2, 5/2, 5/2, 5/2, 5/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=ThreeJSymbol[{j1,m1},{j2,m2},{j3,m3}],fvec = Append [ fvec, f],
      Print["3J[{",j1,",",m1,"},{",j2,",",m2,"},{",j3,",",m3,"} = ",N[f,16]] },{i,1,num,1}]

fileout=OpenWrite["C:\\Documents and Settings\\burkardt.BURKARDTPC\\Desktop\\Misc\\mathematica\\three_j_values.txt"];
SetOptions[fileout,FormatType->TextForm];
Write[fileout,"#  three_j_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];