Homework 3 Handout:  Illustrative Example
                             
 The above graphic summarizes the method used in the calculation below.

Let Q be a two qubit quantum system with state given by the ket |ψ>, where
      |ψ> = ( |00 > +i|01 > - |11 > )/Sqrt[3]

(* Question:  What is the result of measuring  Q  with respect to the observable  Ω, where  *)
Ω=(({{0, 0, 1, -I}, {0, 0, I, -1}, {1, -I, 0, 0}, {I, -1, 0, 0}}))

(* To save type from repeatingly typing MatrixForm, we define function MF *)
MF[x_]=MatrixForm[x];

(* Hence,  *)
ψ=(1/Sqrt[3]) (({{1}, {I}, {0}, {-1}})); MF[ψ]

Question:  What is the result of measuring  Q  with respect to the observable  Ω, i.e., w.r.t.

Ω=(({{0, 0, 1, -I}, {0, 0, I, -1}, {1, -I, 0, 0}, {I, -1, 0, 0}})); MF[Ω]

{eigenval,eigenvec}=Eigensystem[Ω]

(* λ = List of eigenvalues written as a column vector *)
λ=Transpose[{{eigenval[[3]],eigenval[[4]],eigenval[[1]],eigenval[[2]]}}]; MatrixForm[λ]
(* VPlus = Basis of Eigen Space for eingenvalue  +Sqrt[2] *)
(* VMinus = Basis of Eigen Space for eingenvalue -Sqrt[2] *)
VPlus= {eigenvec[[3]],eigenvec[[4]]}; MF[VPlus]
VMinus={eigenvec[[1]],eigenvec[[2]]}; MF[VMinus]

(* Caveate:  Please keep in mind that, if an eigen space is of dimension greater than 1,          
then its orthonormal basis is not unique.                                                 *)

(* Problem:  Then each of the two bases may not be orthonormal bases. *)
(* So we need to use the GrammSchmidt orthogonalization algorithm to *)
(* transform each basis to an orthogonal basis and then we need to   *)
(* normaize each basis vector in each of the two bases. *)

VPlusPerp=Orthogonalize[VPlus]
VMinusPerp=Orthogonalize[VMinus]

w1=Transpose[{VPlusPerp[[1]]}]; MF[w1]
w2=Transpose[{VPlusPerp[[2]]}]; MF[w2]

w3=Transpose[{VMinusPerp[[1]]}]; MF[w3]
w4=Transpose[{VMinusPerp[[2]]}]; MF[w4]

(* Check to se if above kets are of unit length *)
w1\[ConjugateTranspose] . w1;
w2\[ConjugateTranspose] . w2;
w3\[ConjugateTranspose] . w3;
w4\[ConjugateTranspose] . w4;

(* Check to see if above kets are orthonal *)
w1\[ConjugateTranspose] . w2;
w1\[ConjugateTranspose] . w3;
w1\[ConjugateTranspose] . w4;
w2\[ConjugateTranspose] . w3;
w2\[ConjugateTranspose] . w4;
w3\[ConjugateTranspose] . w4;

(* Computation of the corresponding projections *)

P1=w1 . w1\[ConjugateTranspose];MF[P1]
P2=w2 . w2\[ConjugateTranspose];MF[P2]
P3=w3 . w3\[ConjugateTranspose];MF[P3]
P4=w4 . w4\[ConjugateTranspose];MF[P4]

(* Verification that above operatours are projectors *) 
(P1.P1)==P1;
(P2.P2)==P2;
(P3.P3)==P3;
(P4.P4)==P4;

(* Verification that above projectors are orthogonal *)

(* Verification that the four projectors for a complete set of projectors *)
P1+P2+P3+P4==IdentityMatrix[4];

(* Verification of the spectral decomposition of Ω *)
Ω==(λ[[1,1]]*P1)+(λ[[2,1]]*P2)+(λ[[3,1]]*P3)+(λ[[4,1]]*P4)

(* There are two distinct eigenvalues, hence two distinct eigen spaces VPlus and VMinus *)
λPlus=+Sqrt[2]
λMinus=-Sqrt[2]

(* The projectors for the two eingen spaces VPlus and VMinus are respectively: *)
PPlus = P1+P2; MF[PPlus]
PMinus=P3+P4; MF[PMinus]

(* Verification that PPlus & PMinus form a complete set of orthogonal projectors *)
PPlus . PPlus== PPlus
PMinus.PMinus==PMinus
(* PPlus.PMinus==MattrixZero[4] *)
PPlus+PMinus==IdentityMatrix[4]

(* Verification of the spectral decomposion of Ω *)
Ω== (λPlus * PPlus) +(λMinus * PMinus)

(* pPlus = Probability the measurement of ψ with respect to Ω will produce eigenvalue λPlus *)
(* pMinus = Probability the measurement of ψ with respect to Ω will produce eigenvalue λMinus *)
pPlus=Simplify[  (ψ\[ConjugateTranspose] . PPlus . ψ)[[1,1]]   ]
pMinus=Simplify[  (ψ\[ConjugateTranspose] . PMinus . ψ)[[1,1]]   ]

(* For eigenvalue λPlus= +Sqrt[2], the resulting state is ψPlus, where            *)
ψPlus = Map[Simplify,(PPlus . ψ)/(Sqrt[   (ψ\[ConjugateTranspose].PPlus.ψ)[[1,1]]   ]) ]; MF[ψPlus]

(* For eigenvalue λMinus= -Sqrt[2], the resulting state is ψMinus, where            *)
ψMinus = Map[Simplify,(PMinus . ψ)/(Sqrt[   (ψ\[ConjugateTranspose].PMinus.ψ)[[1,1]]   ]) ]; MF[ψMinus]