Particle in a 1D Box with Symmetric potential: How find solutions? I am working on a problem in which I shall find the normalised solution to the 1D particle in a box. Solving for the particle in an asymmetric potential is quite straight forward, but I run into trouble when the potential is symmetric:
$$
V(x) = \begin{cases} \infty & x < -\tfrac{L}{2} \\ 0 & - \frac{L}{2} \leq x \leq \frac{L}{2} \\ \infty & x > \frac{L}{2} \end{cases}
$$
The problems arise with the boundary conditions. We have
$$
\frac{d^2\Psi (x)}{dx^2} = -k^2 \Psi (x)
$$
where $k^2 = \frac{2mE}{\hbar ^2}$. The general solution is
$$
\Psi (x) = Ae^{ikx} + Be^{-ikx}
$$
Due to continuity and the nature of the potential, we must have
$$
\psi (-\tfrac{L}{2}) = \Psi (\tfrac{L}{2}) = 0
$$
Plugging in:
$$
\psi (-\tfrac{L}{2}) = Ae^{-ikL/2} + Be^{ikL/2} = 0 \\
\psi (\tfrac{L}{2}) = Ae^{ikL/2} + Be^{-ikL/2} = 0
$$
I know that when the potential is symmetric, we will find even ($A=B$) and odd ($A=-B$) wave functions. We will see that for even functions, $n$ has to be odd whole numbers, and for odd functions $n$ has to be even whole numbers. This leads to a sequence of sine and cosine curves as $n$ increases by 1.
I am trouble getting there, however, from those boundary conditions, and I would really appreciate pointers and help.
 A: Giorgi Butbala's answer in terms of sines and cosines is perfectly correct.  But just to prove that it can be done, here's how you'd proceed from your two equations in terms of $A$ and $B$:  
The first equation shows that you must have
$$
B = - e^{-ikL} A
$$
and plugging this in to the second equation yields
$$
A e^{ikL/2} - A e^{-3 ikL/2} = 0 \quad \Rightarrow \quad  A e^{ikL/2} (1 - e^{-2ikL}) = 0.
$$
Here's the important part:  the only way for this equation to hold is for either $A = 0$ (which means $B = 0$ and we have no wavefunction at all), or for $e^{-2iKL} = 1$.  This latter condition implies that $2 i k L = 2 i n \pi$, where $n$ is an integer.  Thus, we get that $k = n\pi/L$ as before, and $B = - e^{-in\pi}A$.   In the cases where $n$ is even, we have $B = - A$, and 
$$
\psi(x) = A (e^{ikx} - e^{-ikx}) = 2 i A \sin kx;
$$
in the cases where $n$ is odd, we have $B = A$, and
$$
\psi(x) = A (e^{ikx} + e^{-ikx}) = 2 A \cos kx.
$$
The normalization of the wave functions then proceeds as before.
Oh, and if you want to look at this in even more generality:  You can rewrite your equations above in terms of a matrix equation:
$$
\begin{bmatrix} e^{-ikL/2} & e^{ikL/2} \\ e^{ikL/2} & e^{-ikL/2} \end{bmatrix} \begin{bmatrix} A \\ B \end{bmatrix} = 0.
$$
Now, if this matrix were invertible, you would be able to multiply both left-hand and right-hand side by the inverse and get $A = B = 0$.  It follows then that if we want to have a non-zero solution, the matrix must not be invertible, i.e., its determinant must be zero.  This works out to be
$$
e^{-ikL} - e^{ikL} = 0
$$
and so we must have $kL = n\pi$, as before.  Again, we're using the fact that we want our wavefunction coefficients to be non-zero to constrain the possible values of $k$.
A: So our wavefuction is $\Psi\left(0\right)=e^{ikx}=C\cos\left(kx\right)+D\sin\left(kx\right)$, and potential barrier is: 
$$
V\left(x\right) = \begin{cases} \infty & x < -\tfrac{L}{2} \\ 0 & - \frac{L}{2} \leq x \leq \frac{L}{2} \\ \infty & x > \frac{L}{2} \end{cases}
$$
 We know that wavefuction is zero when $x=-\frac{L}{2}$ or $x=\frac{L}{2}$, 
$$
\Psi\left(\frac{L}{2}\right)=C\cos\left(k\frac{L}{2}\right)+D\sin\left(k\frac{L}{2}\right)=\Psi\left(-{L\over 2}\right)=0\tag{1.1}
$$
Solving for even $n$:
And in that case $k=\frac{n\pi}{L}$, (when we use that $k$ and and $D=0$ it satisfies the equation). So we have $\Psi\left(x\right)=C\cos\left(\frac{n\pi x}{L}\right)$. So now we have to calculate constant $C$. We can use this equation:
$$
\int_{-\frac{L}{2}}^{{L\over 2}}|\Psi\left(x\right)|^2dx=1
$$
So now lets apply it to equation:
$$
\int_{-\frac{L}{2}}^{{L\over 2}}C^2\cos^2\left(\frac{n\pi x}{L}\right)dx=\frac{1}{2}\left(\frac{L\sin\left(n\pi\right)}{\pi n}+L\right)C^2=\frac{C^2L}{2}=1
$$
So constant $C=\sqrt{\frac{2}{L}}$. So wavefunction is $\Psi_{even}\left(x\right)=\sqrt{\frac{2}{L}}\cos\left(\frac{n\pi x}{L}\right)$
Solving for odd $n$:
in that case $k=\frac{2n\pi}{L}$ (this $k$ and setting $C=0$ satisfies equation $(1.1)$) and we get wavefunction $\Psi=Dsin(\frac{2n\pi x}{L})$. So now lets integrate:
$$
\int_{-\frac{L}{2}}^{\frac{L}{2}}D^2sin^2(\frac{2n\pi x}{L}) dx= \frac{1}{4}L\left(2-\frac{sin(2\pi n)}{\pi n}\right)D^2=\frac{D^2L}{2}=1
$$
So $D=\sqrt{\frac{2}{L}}$ ans wavefunction for odd $n$ is $\Psi_{odd}(x)=\sqrt{\frac{2}{L}}sin(\frac{2n\pi x}{L})$
Conclusion(Answers):
So now we have calculated two wavefunctions, one for odd $n$'s and one for even $n$'s
$$
\Psi_{even}(x)=\sqrt{\frac{2}{L}}cos(\frac{n\pi x}{L})
$$
and
$$
\Psi_{odd}(x)=\sqrt{\frac{2}{L}}sin(\frac{2n\pi x}{L})
$$
