Kaguro said:
Yes, after understanding that x = x' - L/2 will be the correct transformation, I tried it again and got everything correct except this ##(-1)^{n/2}##. Now if you say that it carries no significance and can be neglected, I have arrived at the correct answer! Thank you!
To explain this a bit more.
What you got was a specific case of:
##\psi(x') = \alpha_n \sqrt{\frac{L}{2}} \sin (\frac{n\pi x'}{L})##
Where ##\alpha_n## is a complex number of unit modulus (sometimes called the phase factor). In this case, you had ##\alpha_n = \pm 1##, depending on ##n##.
This is perfectly valid for a set of eigenfunctions. But, you are free to choose the phase factor to be simply ##1## in each case. Hence, you have the simplest set of solutions:
##\psi(x') = \sqrt{\frac{L}{2}} \sin (\frac{n\pi x'}{L})##:
Note that can always do the opposite as well, and add any phase factors you want. For example, we could take your original solution:
Kaguro said:
##\psi (x) =\begin{cases} \sqrt{ \frac{2}{L}}cos(n\pi x/L) & \text{if n is odd} \\ \sqrt{ \frac{2}{L}}sin(n\pi x/L) & \text{if n is even} \end{cases} ##
And, we could replace this with an alternative, equally valid set of eigenfunctions:
##\psi (x) =\begin{cases} i\sqrt{ \frac{2}{L}}cos(n\pi x/L) & \text{if n is odd} \\ (e^{i\theta_n})\sqrt{ \frac{2}{L}}sin(n\pi x/L) & \text{if n is even} \end{cases} ##
This has all the same properties as your original solution. The only different is that we've added a phase factor to every function.
This is an important point, because when you have a set of eigenfunctions it can be very useful to choose a phase factor in a particular way. Often that some arbitrary complex number is real.
In any case, the point to remember is that you did not find the only possible unique set of solutions. You found a set of solutions, unique only up to the phase factor. You are free, therefore, to simplify or complicate your solution by changing the phase factors any way you like.