BD 3.1

psi[x]=(Sqrt[2/a])Sin[π x/a];

xop[psi_]:=x psi

pop[psi_]:=-I ℏ D[psi,x]

Integrate[psi[x] xop[psi[x]],{x,0,a}]

Integrate[psi[x] xop[xop[psi[x]]],{x,0,a}]

Δx=Sqrt[%-((%%)^2)]//Simplify

Integrate[psi[x] pop[psi[x]],{x,0,a}]

Δp=Sqrt[Integrate[psi[x] pop[pop[psi[x]]],{x,0,a}]]

Δx Δp//PowerExpand//Simplify

%//N

3.2

<(p^2)>=∫|φ(p)((|)^2)(p^2)dp.  Since |φ(p)((|)^2)>0 and (p^2)>0, <(p^2)>  >0

3.3

∫ψpψdx=-i ℏ ∫ψ(∂_x)ψdx(Overscript[=, by parts])-i ℏ (ψ ψ(Subscript[|, -∞]^∞)-∫ψ(∂_x)ψdx)=i ℏ ∫ψ(∂_x)ψdx=-∫ψpψdx
the first and last terms only agree if ∫ψpψdx=0

3.4

Clear[psi]

Integrate[psic[x]Exp[-I (Subscript[p, 0]) x/ℏ]pop[psi[x]Exp[I (Subscript[p, 0]) x/ℏ]],{x,-∞,∞}]//Expand//Simplify

which equals (Subscript[p, 0])+⟨p⟩=(Subscript[p, 0])+q.  Alternate solution:  The F.T. of ψ(x)(e^(i (Subscript[p, 0])x/ℏ))is φ(p-(Subscript[p, 0])).  Thus the expectation value of the momentum for the new wavefunction is just shifted by (Subscript[p, 0])to q+(Subscript[p, 0]).

3.5

op[f_]:=(x^2)f-D[f,{x,2}]

op[Exp[-(x^2)/2]]==Exp[-(x^2)/2]//Simplify