next up previous contents
Next: References Up: Mathematica for the Heisenberg Previous: Finding the coupled spin

Distribution of measured states

The distribution of the measured states of tex2html_wrap_inline15403 is found using getDistribution[].

getDistribution[order_,vecs_,probs_] :=
  (* finds the distribution in the +/- basis *)
  Block[ {tbl,dist,numVecs,numBasis,phase,probVal,vecProb,
          index,i,j,k,vec} ,
          dist=Table[0,{2^order}] ;
          numVecs=Length[vecs] ;
          For[ i=1,i<=numVecs,i++,
               vec=vecs[[i]] ;
               numBasis=Length[vec] ;
               vecProb=probs[[2]][[i]]/probs[[1]] ;
               For[ j=1,j<=numBasis,j++,
                    phase=vec[[j]][[3]] ;
                    probVal=phase*phase ;
                    index=0 ;
                    For[ k=0,k<order,k++,
                         index=index+2^k*
                           If[vec[[j]][[1]][[2(k+1)]]<0,0,1] ;
                       ] ;
                    dist[[index+1]]+=probVal*vecProb ;
                  ] ;
             ] ;
          Return[dist] ;
       ] ;

The arguments are order, which must be less than or equal to the number of spins, a list of vectors vecs in the tex2html_wrap_inline18047 basis like that produced by transVecs, and probs, which is the list of probabilites produced by the output of getProbabilites of the energy eigenvectors produced by genVecs.

The same distribution of the measured states of tex2html_wrap_inline15403 can be produced in polynomial form using getDistributionPoly[].

getDistributionPoly[order_,vecs_,probs_] :=
  Block[ {tbl,dist,numVecs,numBasis,phase,probVal,vecProb,poly,
          spin,i,j,k,vec},
         numVecs=Length[vecs] ;
         dist=0 ;
         For[ i=1,i<=numVecs,i++,
              vec=vecs[[i]] ;
              numBasis=Length[vec] ;
              vecProb=probs[[2]][[i]]/probs[[1]] ;
              For[ j=1,j<=numBasis,j++,
                   phase=vec[[j]][[3]] ;
                   probVal=phase*phase ;
                   poly=1 ;
                   For[ k=1,k<=order,k++,
                        spin=vec[[j]][[1]][[2k]] ;
                        poly*=If[spin<0,(1/2-x[k]),(1/2+x[k])] ;
                      ] ;
                   dist+=probVal*vecProb*poly ;
                 ] ;
            ] ;
         Return[Simplify[dist]] ;
       ] ;

The output is a polynomial in order variables, specific to spin one-half for the routine above. Inserting a vector of spins in the resulting expression produces the probability of that measurement.



David Wolf
Tue Mar 25 08:11:49 CST 1997