Construct the eigenvalues (Subscript[k, n])and eigenfunctions (Subscript[ψ, n])(x).  
The underscore means that you can replace n_ by any number, not just n.
To enter ψ,  type:  <ESC> psi <ESC>

k[n_]= n*Pi/a

ψ[n_,x_]=Sqrt[2/a] *Sin[k[n]*x]

Check orthonormality of the basis functions (Subscript[ψ, n])(x)

Table[Integrate[ψ[n,x]*ψ[m,x],{x,0,a}],{n,1,5},{m,1,5}]

Calculate the coefficients (Subscript[c, n]) of the constant function ψ(x)=1/√a
The asumption is necessary to simplify the formula.
You can enter superscript with <CTRL> ^  and subscripts with <CTRL> -

(Subscript[c, n_])=Assuming[Element[n,Integers],Integrate[ψ[n,x]*Sqrt[1/a],{x,0,a}]]

Show that these coefficients are normalized

Sum[(Subscript[c, n])^2, {n,1,Infinity}]

Sum[8/Pi^2/(2*n+1)^2,{n,0,Infinity}]

Calculate the expectation values <x>, <(x^2)>

Assuming[Element[n,Integers],Integrate[ψ[n,x]^2*x,{x,0,a}]]

Assuming[Element[n,Integers],Integrate[ψ[n,x]^2*x^2,{x,0,a}]]

Integrate[Sin[k x]^2*x,x]

Calculate the expectation values <p>, <(p^2)>

D[ψ[n,x],x]

Assuming[Element[n,Integers],Integrate[ψ[n,x]*D[ψ[n,x],x],{x,0,a}]]

Assuming[Element[n,Integers],Integrate[ψ[n,x]*D[ψ[n,x],{x,2}],{x,0,a}]]

Validate Heisenberg Uncertainty Principle.

Pi*Sqrt[1/12-1/2/Pi^2]//N

The expectation value of energy is infinite for this wave function!

Sum[(Subscript[c, n])^2*n^2, {n,1,Infinity}]

Show the interference between two components of a wave function.

a=1
Manipulate[Plot[Re[ψ[1,x]+Exp[I ϕ]*ψ[2,x]],{x,0,a}],{ϕ,0,2Pi}]