Symmetric potential well different solutions

I have solved $$H|\psi\rangle=E_{n}|\psi\rangle$$ with $$V(x)=0$$ from $$-a and $$\infty$$ otherwise. If I propose a solution of the form $$\psi(x)=A_{n}e^{ikx}+B_{n}e^{-ikx}$$ I arrive to the solution $$\psi(x) = \frac{1}{\sqrt{L}} \sin \left( \frac{n\pi}{2} \left(\frac{x}{L}-1 \right) \right)$$ for $$n$$ natural. If I propose a solution of the form $$\psi(x)=A_{n}\sin(kx)+B_{n}\cos(kx) \, .$$ I arrive to the solution $$\psi(x) =\begin{cases} \frac{1}{\sqrt{a}}\cos \left(\frac{n\pi x}{2a} \right) & \text{n odd} \\ \frac{1}{\sqrt{a}}\sin \left(\frac{n\pi x}{a} \right) & \text{n even } \end{cases}$$

Both solutions with the same energies. However, when plotting both solutions, I see they're not equal. But I cannot find any mistakes on my procedures.

• I think your L =a the width of the well.Try expanding the first solution in terms of sine and cosine function .I think it will be general solution (a combination of two solutions for n odd and even) – drvrm May 19 at 20:19
• They are equal up to a phase factor of $-1$, so they are basically equal. Or equivalently $A_n, B_n$ are only fixed by the boundary conditions and normalization up to a phase factor $e^{i\phi}$. – lomby May 19 at 20:21
• The solution for n=odd matches my solution, but for n=even, plots are not equal even if consider an extra minus sign. However, the second solution for n=2 matches the first solution for n=4 – Juan Pablo Arcila May 19 at 21:05

Solutions coincide for n=odd and an extra minus sign (wavefunctions are the same up to a phase factor, in this case $$e^{i\pi}$$). For n=even the solution from the piecewise function is the same than the first one for N=2n. Therefore they describe the same physical solution