When the box is centered at origin, we get the wavefunction \begin{equation} \psi = \sqrt{\frac{2}{L}}\sin(\frac{n\pi x}{L}) \end{equation} But what will be the wavefunction of the particle is not centered at origin? If the box extends from $x = x_0$ to $x = x_0+l$. To solve this, I used the general solution which is \begin{equation} \psi = A\sin(\frac{\sqrt{2mE}x}{\hbar})+B\cos(\frac{\sqrt{2mE}x}{\hbar}) \end{equation} then applied boundary conditions which gave me \begin{equation} \frac{A}{B} = \tan(\frac{\sqrt{2mE}(l+2x_0)}{\hbar}) \end{equation} Now I'm stuck here. I don't know how to solve further. Any help will be appreciated
2 Answers
You can trivially obtain the solutions to the shifted problem by replacing $x$ with $x-x_0$ in the original solutions. From there, it's a matter of elementary trigonometry (i.e. the angle addition formula) to express the result in terms of $\sin([\ldots]x)$ and $\cos([\ldots]x)$.
Another general solution for the wave function is:
$$\psi = A\sin([...]x+a)$$
where $a$ is a constant. You can easily put the boundary conditions you like.