(* Definicoes das Funcoes da caixa *)

u=Function[{x,n,a},Sqrt[2/a] Sin[n Pi x/a] ]
up=Function[{x,m,a},Sqrt[2/a] Cos[(2 m -1) Pi x/a]]
um=Function[{x,m,a},Sqrt[2/a] Sin[2 m  Pi x/a]]

(* Calculo dos Coeficientes pares e impares *)

Apaux = Function[{n,a}, Integrate[Sqrt[2/a] up[x, n, a], {x, -a/2, 0}, 
      Assumptions -> n \[Element] Integers]]

Ap=Function[n,(2*(-1)^n)/(Pi - 2*n*Pi)]

Amaux = Function[{n,a}, Integrate[Sqrt[2/a] um[x, n, a], {x, -a/2, 0}, 
      Assumptions -> n \[Element] Integers]]

Am=Function[n, (-1 + (-1)^n)/(n*Pi)]

(* Energias dos estados pares e impares *)

Ep = Function[{n,a}, (2 n-1)^2/a^2]
Em = Function[{n,a}, (2 n)^2/a^2]


(* Funcao de onda para um instante t *)

psi=Function[{x,t,a,m},Sum[Ap[n] up[x,n,a] E^(-I t Ep[n,a]),{n,1,m}] + 
  Sum[Am[n] um[x,n,a] E^(-I t Em[n,a]),{n,1,m}] ]
