Added May 2, 2021. See my HW10. Physics 3041.
Consider \(\psi \left ( x,t\right ) \) for \(0\leq x\leq L\). Given \(\psi \left ( 0,t\right ) =\psi \left ( L,t\right ) =0\) and\[ \psi \left ( x,0\right ) =\left \{ \begin {array} [c]{ccc}A\sin \left ( \frac {2\pi x}{L}\right ) & & 0\leq x\leq \frac {L}{2}\\ 0 & & \frac {L}{2}\leq x\leq L \end {array} \right . \] Find \(\psi \left ( x,t\right ) \) that satisfies the following partial differential equation\begin {equation} i\hbar \frac {\partial \psi }{\partial t}=-\frac {\hbar ^{2}}{2\mu }\frac {\partial ^{2}\psi }{\partial t^{2}} \tag {1} \end {equation} Where \(A,L,\hbar ,\mu \) are positive constants.
Mathematica ✓
ClearAll["Global`*"]; pde = I*hbar*D[w[x, t], t] == -hbar^2/(2*mu)*D[w[x, t], {x, 2}]; bc = {w[0, t] == 0, w[L, t] == 0}; ic = w[x, 0] == Piecewise[{{A*Sin[2*Pi*x/L], 0 < x < L/2}, {0, L/2 < x < L}}]; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, w[x, t], {x, t}, Assumptions -> {A > 0, L > 0, hbar > 0, mu > 0}], 60*10]]; sol = sol /. K[1] -> n;
\[\left \{\left \{w(x,t)\to \sum _{n=1}^\infty -\frac {4 A e^{-\frac {i \text {hbar} n^2 \pi ^2 t}{2 L^2 \mu }} \sin \left (\frac {n \pi }{2}\right ) \sin \left (\frac {n \pi x}{L}\right )}{\left (n^2-4\right ) \pi }\right \}\right \}\] Does not handle \(n=2\) case correctly. Division by zero
Maple ✓
restart; pde:=I*hbar*diff(w(x,t),t) = -hbar^2/(2*mu)*diff(w(x,t),x$2); bc:=w(0,t)=0,w(L,t)=0; ic:=w(x,0)=piecewise(0<x and x<L/2,A*sin(2*Pi*x/L),L/2<x and x<L, 0); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],w(x,t)) assuming L>0,A>0,mu>0,hbar>0),output='realtime'));
\[w \left (x , t\right ) = \frac {A \,{\mathrm e}^{-\frac {2 i \pi ^{2} \mathit {hbar} t}{L^{2} \mu }} \sin \left (\frac {2 \pi x}{L}\right )}{2}+\frac {4 A \,{\mathrm e}^{-\frac {i \pi ^{2} \mathit {hbar} t}{2 L^{2} \mu }} \sin \left (\frac {\pi x}{L}\right )}{3 \pi }+ \sum _{n=3}^\infty \left (-\frac {4 A \,{\mathrm e}^{-\frac {i \pi ^{2} \mathit {hbar} \,n^{2} t}{2 L^{2} \mu }} \sin \left (\frac {\pi n x}{L}\right ) \sin \left (\frac {\pi n}{2}\right )}{\pi \left (n^{2}-4\right )}\right )\]
____________________________________________________________________________________