The infinite box well, $0 \leq x\leq L$, has the following potential function:
$$V(x)=\begin{cases}
\infty,&x < 0\\
0,&0 < x < L\\
\infty,& x > L
\end{cases}$$
Solving the energy eigenvalue equation, we get the following equations:
Outside well: $\phi_E(x)=0$
Inside well: $\frac{d^2}{dx^2}\phi_E(x)=-\frac{2mE}{\hbar^2}\phi_E
(x)=-k^2\phi_E(x),\quad k^2=\frac{2mE}{\hbar^2}\geq 0\text{ since }E\geq 0$
The general solution to the wavefunction is:
$$\phi_E(x)=A\sin kx + B\cos kx$$
We fix the coefficients, $A$ and $B$, by imposing the following boundary conditions:
Wavefunction has to be continuous
Wavefunction must go to $0$ at the walls
At $x=0$, $B=0\implies \phi_E(x)=A\sin kx$
At $x=L$, $\sin kL=0\implies kL=n\pi\implies k_n=\frac{n\pi}{L}$
$$E_n=\frac{n^2\pi^2\hbar^2}{2mL^2}$$
To get $A$, we normalize the wavefunction $1=\int_{-\infty}^\infty\phi_n^*(x)\phi_n(x)dx$ to get $A=\sqrt{\frac{2}{L}}$
Thus, for a particle in an infinite box well, $$\phi_n(x)=\sqrt{\frac{2}{L}}\sin\frac{n\pi x}{L}$$
Finite Square Well
The potential energy function for a finite square well, $-a \leq x \leq a$, is:
$$V(x)=\begin{cases}
V_0,&x< -a\\
0,& -a\leq x\leq a\\
V_0,&x>a
\end{cases}$$
Once again solving the energy eigenvalue equation, we obtain:
Thus, we get the general solution:
$$\phi_E(x)=\begin{cases}
Ae^{qx}+B^{-qx},&x< -a\\
C\sin kx +D\cos kx,& -a\leq x\leq a\\
Fe^{qx}+Ge^{-qx},& x > a
\end{cases}$$
We eliminate some of these coefficients by imposing the following conditions:
Wavefunction must be normalizable (must go to $0$ at the endpoints). So, $B=F=0$.
Wavefunction is continuous.
Wavefunction is differentiable (or $\frac{d\phi_E(x)}{dx}$ is continuous).
We split the problem into the odd and even cases of the wavefunction:
$$\phi_{E,\text{ even}}(x)=\begin{cases}
Ae^{qx},&x < -a\\
D\cos kx,&-a\leq x\leq a\\
Ae^{-qx},&x > a
\end{cases},\quad\phi_{E,\text{ odd}}(x)=\begin{cases}
Ae^{qx},&x < -a\\
C\sin kx,&-a\leq x\leq a\\
-Ae^{-qx},&x > a
\end{cases},$$
Ex 1: A particle in an infinte square well has an initial state of $\psi(x)=\sqrt{\frac{30}{a^5}}x(1-x)$. Calculate $\angle{H}$.
Use the SE recipe.
We find the eigenvalues and eigenstates.
$E_n=\frac{n^2\pi^2\hbar^2}{2mL^2},\quad\phi_n(x)=\sqrt{\frac{2}{L}}\sin\frac{n\pi x}{L}$
Write $\psi(x)$ as a superposition of eigenstates $\phi_n(x)$.
$$\begin{align*}c_n&=\int_0^L\phi_n^*\psi(x)dx\\&=\frac{4\sqrt{15}(1-\cos n\pi)}{n^3\pi^3}\\&=\begin{cases}0,&n\text{ even}\\\frac{8\sqrt{15}}{n^3\pi^3},&n\text{ odd}\end{cases}\end{align*}$$
$$\psi(x)=\sum_n c_n\phi_n(x)$$
Add time dependence.
$$\psi(x,t)=\sum_{n\text{ odd}}\frac{8\sqrt{15}}{n^3\pi^3}\sqrt{\frac{2}{L}}\sin\frac{n\pi x}{L}e^{-\frac{in^2\pi^2\hbar t}{2mL^2}}$$