Experimenting with Uncertainty

Consider a single qubit in a given state |ψ ⟩. We perform measurements with the spin-1/2 operators

({{({{(Subscript[S, x])}})= (ℏ/2) (({{0, 1}, {1, 0}}))  ,  and   ({{(Subscript[S, y])}})= (ℏ/2) (({{0, -i}, {i, 0}})) }})

Define an arbitrary qubit state vector

ClearAll["Global`*"]
θ=Random[Real,{0,2Pi}];
ϕ=Random[Real,{0,2Pi}];
β=Random[Real,{0,2Pi}];

psi=Exp[I β]{Cos[θ/2],Exp[I ϕ] Sin[θ/2]}

We use the Born rule to calculate the probability that a measurement with (Subscript[S, x]) yields ±ℏ/2 (below we set ℏ=1, in order to simplify the arithmetic)

ℏ=1;

Eigenstate for (Subscript[S, x])= ℏ/2

psixplus={1,1}/Sqrt[2];

Eigenstate for (Subscript[S, x])= -ℏ/2

psixminus={1,-1}/Sqrt[2];

pxplus=Abs[psixplus.psi]^2;
pxminus=Abs[psixminus.psi]^2;
pxplus+pxminus==1

Define measurement device (Subscript[S, x])

SXmeasurement:=RandomChoice[{pxplus,pxminus}->{ℏ/2,-ℏ/2}];

Let’s take a set of 10 independent measurements with  (Subscript[S, x]) (assuming for each measurement the system is in state |ψ⟩).

Table[SXmeasurement,{i,1,10}]

As expected, because state |ψ ⟩ is not necessarily an eigenstate of  (Subscript[S, x]), and the result of a measurement is probabilistic. In order to attain a higher quality of statistics we need to make more that just 10 measurements. Lets construct a sample space with 100 elements,

sample=100;

Sxsamples=Table[SXmeasurement,{i,1,sample}];

Let’s take the average, or mean, value ⟨(Subscript[S, x])⟩

?Mean

xmean=Mean[Sxsamples]

We also find the variance of this distribution

?Variance

varx=Simplify[Variance[Sxsamples],Assumptions->ℏ ∈ Reals]

By definition, the uncertainty (the square-root of the variance), can be calculated using the relation
({{(Subscript[ΔS, x])≡(Sqrt[({{⟨((Subscript[S, x])^2)⟩  - ((⟨  (Subscript[S, x]) ⟩)^2)}})])}})
But the Mathematica command Variance evaluates it directly from the distribution of values

deltaSx=Sqrt[varx]

Now repeat the above steps to calculate (Subscript[ΔS, y])
Eigenstate for (Subscript[S, y])=ℏ/2

psiyplus={1,I}/Sqrt[2];

Eigenstate for (Subscript[S, y])=-ℏ/2

psiyminus={1,-I}/Sqrt[2];

pyplus=Abs[Conjugate[psiyplus].psi]^2;
pyminus=Abs[Conjugate[psiyminus].psi]^2;
pyplus+pyminus==1

SYmeasurement:=RandomChoice[{pyplus,pyminus}->{ℏ/2,-ℏ/2}];

Sysamples=Table[SYmeasurement,{i,1,sample}];

vary=Simplify[Variance[Sysamples],Assumptions->ℏ ∈ Reals]

deltaSy=Sqrt[vary]

Finally, in order to check the validity of the uncertainty    relations

({{({{(Subscript[ΔS, x])}}) (Subscript[ΔS, y]) ≥ 1/2 ⟨[(Subscript[S, x]),(Subscript[S, y])]⟩=ℏ/2 ⟨(Subscript[S, z])⟩}})
We need to evaluate ⟨(Subscript[S, z])⟩

Eigenstate for (Subscript[S, z])= ℏ/2

psizplus={1,0};

Eigenstate for (Subscript[S, z])= -ℏ/2

psizminus={0,1};

pzplus=Abs[psizplus.psi]^2;
pzminus=Abs[psizminus.psi]^2;
pzplus+pzminus==1

SZmeasurement:=RandomChoice[{pzplus,pzminus}->{ℏ/2,-ℏ/2}];

zsamples=Table[SZmeasurement,{i,1,sample}];

Evaluate the left hand side of the uncertainty relation

lefthandside=N[deltaSx deltaSy/ℏ^2 ]

Evaluate the right hand side of the uncertainty relation

righthandside=N[Abs[Mean[zsamples]/ℏ/2]]

Check if the uncertainty relation holds

lefthandside > righthandside

Exercises

(1) Repeat the calculations for various states |ψ⟩, chosen, as above randomly. For every experiment you perform, does the above equality always hold. If not, why ? If you find the latter does that invalidate the uncertainty relation ?  (Hint: try using a larger value for the sample size)

(2) Instead of operators (Subscript[S, x]),(Subscript[S, y])perform measurements with the operator  (Subscript[S, x])(Subscript[S, y])  and (Subscript[S, y])(Subscript[S, x]).  Derive an uncertainty relation for this pair of measurements.