$\sin$ and $\cos$ components in symmetric infinite potential well problem Consider an infinite potential well in one dimension with boundaries at $\pm a/2$.
Can $\psi(x) = A \sin(kx) + B \cos(kx)$ for this system?
The way it was answered was "mathematically acceptable but physically unacceptable" using the boundary conditions, but I want to understand more, like can't a superposition of a sine wave and a cosine wave meet the boundary conditions?
 A: You can't have a free particle in an infinite square well.  It's a bound particle for which the potential function is finite in a certain region. For example, if the problem is for a 1-dimensional system, $V=V_0$ for $a<x<b$, and $V=\infty$ everywhere else. The particle energy, $E$, is greater than $V_0$. Often, $V_0$ is set to zero, so let's do that.
When you solve the time-independent Schrodinger equation for the region $a<x<b$  you get the solution you propose:
$$\psi (x) = A \sin (kx) + B \cos (kx).$$
where $$k=\frac{2mE}{\hbar^2}$$
For the other regions, consider a very large potential, $G$, where $G>E$, and take the limit as $G\to \infty$. The SWE becomes
$$\frac{\mathrm{d^2}\psi(x)}{\mathrm{d}x^2}=\frac{2m}{\hbar^2}(G-E)\psi(x).$$
The solution for this is $$\psi(x)=Ce^{\kappa x}+De^{-\kappa x},$$
where
$$\kappa =\frac{2m}{\hbar^2}\left(G-E\right).$$
This solution must be bounded for both $x\to +\infty$ and $x\to -\infty$, as well as $G\to \infty$. The only way for this to happen is for $\psi(x\le a)=0$ and $\psi(x\ge b)=0$. That establishes the boundary conditions for the sinusoidal type solution in the $a<x<b$ region because the solutions must be continuous at the boundaries of the well.
So, for your system, because the potential is symmetric about zero, your solutions must have definite parity about zero which means that the set of solutions will have $A=0$ (positive parity) for some and $B=0$ (negative parity) for other solutions.
A: This is a purely mathematical question. It signifies whether non-trivial wave functions $$\psi(x) = A \sin(kx) + B \cos(kx)$$ exist with $$\psi(x=\pm a/2)=0$$ This results in a homogenous system of two linear equations for $A$ and $B$ $$A \sin(ka/2) + B \cos(ka/2)=0$$ $$-A \sin(ka/2) + B \cos(ka/2)=0$$ which has nonzero solutions for $A$ and $B$ only when the coefficient determinant is zero $$\sin(ka/2)\cos(ka/2)+\sin(ka/2)\cos(ka/2)=2\sin(ka/2)\cos(ka/2)=0$$ Thus an infinite number of wavefunctions of the above form with nonzero $A$ and $B$ exists for $$ka/2=\pm n\pi$$ or $$ka/2=\pm (n+1/2)\pi$$ The first condition gives the sine functions ($B=0$) $$\psi(x) = A \sin(kx)$$ with arbitrary $A$, the second the cosine functions ($A=0$) $$\psi(x) = B \cos(kx)$$ with arbitrary $B$. No other solutions are allowed except for the trivial mathematical solution $\psi(x) = 0$.
A: Solving from the Schrodinger equation, you have, step by step:
$$ \hat{H}\Psi = E\Psi$$
where
$$\hat{H} = K + V = \frac{-\hbar^2}{2m}\frac{\partial^2}{\partial x^2} $$
because $V_0 = 0$. Therefore, we have the differential equation
$$  \frac{-\hbar^2}{2m}\frac{\partial^2\Psi}{\partial x^2} = E\Psi $$
$$\rightarrow \frac{\partial^2\Psi}{\partial x^2} = -\frac{2mE}{\hbar^2}\Psi .$$
The superposition of sine and cosine you have suggested, $\Psi(x) = A\sin(kx) + B\cos(kx)$, is mathematically acceptable here, where $k = \frac{\sqrt{2mE}}{\hbar}$.
Let us apply the value at boundary $x = a$ and $x=-a$. Then 
$$ \Psi(a) = A\sin(\frac{\sqrt{2mE}}{\hbar}a) + B\cos(\frac{\sqrt{2mE}}{\hbar}a) = 0.$$
and
$$ \Psi(-a) = A\sin(-\frac{\sqrt{2mE}}{\hbar}a) + B\cos(-\frac{\sqrt{2mE}}{\hbar}a) = 0.$$
Invoking the odd/even natures of sines and cosines, this second equation is
$$ \Psi(-a) = -A\sin(\frac{\sqrt{2mE}}{\hbar}a) + B\cos(\frac{\sqrt{2mE}}{\hbar}a) = 0.$$
Now compute $\Psi(a) + \Psi(-a) = 0$. You get that $B = 0$. Now compute $\Psi(a) - \Psi(-a)$. You get that $A = 0$. The problem here is that the well is symmetric about zero, if you force your initial values to make either $A$ or $B$ zero, then you will get only half of the solutions.
