Particle in 1D box. Different solutions for wavefunction

For a particle in a box $$x$$ ranging from $$0$$ to $$L$$ you get a solution of $$\sqrt{2/L}\sin (n \pi x/L)$$. But if you have a particle in a box $$x$$ ranging from $$-L/2$$ to $$L/2$$ infinite square well potential, I have seen odd and even solutions as: \begin{align} & \sqrt{2/L}\cos(n \pi x/L) \quad \text{ for odd }n, \ \ \text{and} \\ & \sqrt{2/L}\sin(n \pi x/L) \quad \text{ for even solutions,} \end{align} which I understand and get.

However, I have seen analogy solutions for second case based on first where $$x$$ is replaced with $$x+L/2$$ and solutions now become \begin{align} \sqrt{2/L}\cos( \pi x/L)& \text{ for }n=1,\\ -\sqrt{2/L}\sin(2 \pi x/L)& \text{ for } n=2,\\ -\sqrt{2/L}\cos(3 \pi x/L)& \text{ for } n=3. \end{align} I am wondering whether the latter case is a valid approach and if so, why doesn't sign matter.

If $\psi(x)$ is solution to $$-\frac{\hbar^2}{2m}\frac{d^2}{dx^2}\psi(x)+V(x)\psi(x)=E\psi(x)$$ then so is any multiple $A\psi(x)$, where $A$ is an arbitrary non-zero complex number. This is easy to verify: just replace $\psi(x)$ by $A\psi(x)$ above and note that, since every term now has a common $A$ factor: $$-\frac{\hbar^2}{2m}\frac{d^2}{dx^2}A\psi(x)+V(x)A\psi(x)=EA\psi(x)$$ this factor (which by assumption is $\ne 0$) can be cancelled out.

Thus, $\psi(x)$ and $-\psi(x)$ are equally good solution, as would be $\sqrt{2}\psi(x)$.

Because the quantity $\psi^*(x)\psi(x)$ is a probability density, changing $\psi(x)$ to $A\psi(x)$ changes the probability density to $AA^*\,\psi^*(x)\psi(x)$. To guarantee the probability of finding the system described by $\psi(x)$ is $1$, one usually chooses $A$ so that $$AA^* \int dx \psi(x)^*\psi(x) =1$$ This is enough to pin down the $\vert A\vert$, but even if we have this "right-sized" $A$, $e^{i\phi}A$ would still work: it is only possible to find the magnitude of $A$, not its sign or more generally its phase.

This is not a problem because, in evaluating physically measurable quantities, only $AA^* \psi(x)^*\psi(x)$ ever enters, so this overall sign or phase does not have any consequence on the physics described by $\psi(x)$.

As a heads up, I did this roughly in my head, but it should be simple to work out:

For starters, the reason you have sine and cosine solutions that differ from odd/even "n", is because you have $\sin(kx)$ solution where $k = n\pi/L$ for the case where the well is between $x = [0,L]$ and where $x = [-L/2, L/2]$ you have $k = (n\pi/L+\pi/L)$ so where n is odd, there's a $\pi/2$ phase shift, which is why we have cosines in that case.

For the second point, that is also valid. Sign doesn't matter because it adds an overall phase shift to the equation, and we are only concerned with relative phases of the wave equation. Just choose a consistent basis.