Problem 2(a)

psiofx0=Nn Exp[-(x^2)/(4(σ^2))]Exp[I k0 x];

(* normalization *)
tonormalize=Integrate[ComplexExpand[((Abs[psiofx0])^2)]/.((Abs[Nn])^2)->(Nn^2),{x,-Infinity,Infinity},GenerateConditions->False]

Nnsols=PowerExpand[Solve[1==tonormalize,Nn]]

Nnsol=Nn/.Nnsols[[2]]

fofk=PowerExpand[Integrate[1/Sqrt[2π]psiofx0 Exp[-I k x],{x,-Infinity,Infinity},GenerateConditions->False]]/.Nn->Nnsol

psiofxt=1/Sqrt[2π]Integrate[fofk Exp[-I h (k^2)/(2m) t]Exp[I k x],{k,-Infinity,Infinity},GenerateConditions->False]

(* Simplifying the answer *)
FullSimplify[PowerExpand[Simplify[psiofxt/.t->that 2 m (σ^2)/h/.x->xshifted+2I k0 (σ^2)]]]

Problem 2(b)

psiofxtsquared=PowerExpand[Simplify[Simplify[PowerExpand[FullSimplify[ComplexExpand[Abs[(psiofxt^2)]]]]]/.t->that 2 m (σ^2)/h]]

Animate[Plot[psiofxtsquared/.k0->1/.σ->1/.that->tt,{x,-20,20},PlotRange->{0,0.4},PlotLabel->Style["that="<>ToString[tt],18]],{tt,0,10}]

Problem 2(c)

time=2m (σ^2)Sqrt[3]/hbar/.m->1 g/.σ->0.1 cm/.hbar->1.05*(10^(-27))erg s/.erg->g (cm^2)/(s^2)

time/(60 s/minute)/(60 minute/hour)/(24 hour/day)/(365 day/year)

Problem 2 extra credit

xavg=PowerExpand[Integrate[x psiofxtsquared,{x,-Infinity,Infinity},GenerateConditions->False]]/.that->hbar t/(2m (σ^2))

pavgtemp=Integrate[FullSimplify[PowerExpand[Simplify[ComplexExpand[Simplify[Conjugate[psiofxt](-I h) D[psiofxt,x]]]]]],{x,-Infinity,Infinity},GenerateConditions->False]

pavg=PowerExpand[Simplify[pavgtemp/.t->that 2 m (σ^2)/h]]

xsqavg=Simplify[PowerExpand[Integrate[(x^2) psiofxtsquared,{x,-Infinity,Infinity},GenerateConditions->False]]/.that->hbar t/(2m (σ^2))]

deltaxsqavg=Simplify[xsqavg-(xavg^2)]

(* Be patient, this step takes a while *)
psqavgtemp=Integrate[FullSimplify[PowerExpand[Simplify[ComplexExpand[Simplify[Conjugate[psiofxt](-(h^2)) D[psiofxt,x,x]]]]]],{x,-Infinity,Infinity},GenerateConditions->False]

psqavg=PowerExpand[Simplify[psqavgtemp/.t->that 2 m (σ^2)/h]]

deltapsqavg=Simplify[psqavg-(pavg^2)]