Solving the particle in a box problem considering boundaries 0 and L leads to the energy equation $$\frac{n^2\pi^2\hbar^2}{2mL^2}$$ but doing the same with center at the origin (from -L/2 to L/2) I get $$\frac{2n^2\pi^2\hbar^2}{mL^2}$$ shouldn't I get the same answer?
I used the solution $$A\sin (\frac{\sqrt{2mE}}{\hbar}x)+B\cos (\frac{\sqrt{2mE}}{\hbar}x)$$ by substituting $f(-L/2)=f(L/2)=0$ and considering symmetry for cos and sin, $$-A\sin(\frac{\sqrt{2mE}}{\hbar}\frac{L}{2})+B\cos (\frac{\sqrt{2mE}}{\hbar}\frac{L}{2})$$ $$A\sin (\frac{\sqrt{2mE}}{\hbar}\frac{L}{2})+B\cos (\frac{\sqrt{2mE}}{\hbar}\frac{L}{2})$$ subtracting both equations $$2A\sin (\frac{\sqrt{2mE}}{\hbar}\frac{L}{2})=0$$ where $$\frac{\sqrt{2mE}}{\hbar}\frac{L}{2}=n\pi$$
I saw a couple of solutions where they added both equations and used $$\frac{\sqrt{2mE}}{\hbar}\frac{L}{2}=\frac{n\pi}{2}$$
for $\cos u=0$, but for even $n$, $\cos u=\pm1$ so I think it should be $$\frac{\sqrt{2mE}}{\hbar}\frac{L}{2}=\frac{(2n-1)\pi}{2}$$