Start by defining the wavefunction:
> psi := (n,L,x) -> sqrt(2/L)*sin(n*Pi*x/L);
We will eventually need the following assumptions:
> assume(L,positive); assume(hbar,positive);
To verify that the Heisenberg uncertainty principle holds, we need to
compute and , which in turn require that we compute
, , and . Some of these averages are trivial so I just typed them
in.
> average_x := L/2;
> average_x2 := int(psi(2,L,x)^2*x^2,x=0..L);
> delta_x := sqrt(average_x2-average_x^2);
> average_p := 0;
We can use the answer to question 2 to cut down our work here, or we
can compute the integral. I chose to do the former.
> average_p2 := 4*h^2/(4*L^2);
Convert the h to hbar so that all of the calculations
use the same version of Planck's constant:
> h:=2*Pi*hbar;
> delta_p:= sqrt(average_p2-average_p^2);
Now verify the uncertainty principle:
> evalf(delta_p*delta_x);
> simplify(");
This is much bigger than so the uncertainty principle holds for
this state.