### 2.6 Wave PDE with inhomogeneous boundary conditions, 1D (string)

Analytical solution

\begin{align} \frac{\partial ^{2}u\left ( x,t\right ) }{\partial t^{2}} & =c\frac{\partial ^{2}u\left ( x,t\right ) }{\partial x^{2}}\tag{1}\\ u\left ( 0,t\right ) & =0\nonumber \\ \frac{\partial u\left ( L,t\right ) }{\partial x} & =C\nonumber \\ u\left ( x,0\right ) & =0\nonumber \\ \frac{\partial u\left ( x,0\right ) }{\partial t} & =0\nonumber \end{align}

Let $$u\left ( x,t\right ) =v\left ( x,t\right ) +u_{E}\left ( x\right ) \tag{2}$$ $$u_{E}\left ( x\right )$$ is the steady state solution which only needs to satisfy the non-homogeneous boundary conditions. At equilibrium $$\frac{\partial ^{2}u\left ( x,t\right ) }{\partial t^{2}}=0$$ and the PDE becomes $$\frac{\partial ^{2}u_{E}\left ( x,t\right ) }{\partial t^{2}}=0$$ or the ODE $$\frac{d^{2}u_{E}\left ( x,t\right ) }{dx^{2}}=0$$ with B.C. $$u_{E}\left ( 0\right ) =0,u_{E}^{\prime }\left ( L\right ) =C$$. The solution to this ODE is$u_{E}\left ( x\right ) =c_{1}x+c_{2}$ At ﬁrst B.C.$0=c_{2}$ Solution becomes $$u_{E}\left ( x\right ) =c_{1}x$$. At second B.C. $$u_{E}^{\prime }\left ( x\right ) =c_{1}=C$$. Therefore solution is$u_{E}\left ( x\right ) =Cx$ Hence$u\left ( x,t\right ) =v\left ( x,t\right ) +Cx$ $$v\left ( x,t\right )$$ is the solution to the PDE but with homogeneous B.C. Plugging (2) into (1) gives$\frac{\partial ^{2}v\left ( x,t\right ) }{\partial t^{2}}+\frac{\partial ^{2}u_{E}\left ( x,t\right ) }{\partial t^{2}}=c\left ( \frac{\partial ^{2}v\left ( x,t\right ) }{\partial x^{2}}+\frac{\partial ^{2}u_{E}\left ( x,t\right ) }{\partial x^{2}}\right )$ But $$\frac{\partial ^{2}u_{E}\left ( x,t\right ) }{\partial x^{2}}=0$$ and also $$\frac{\partial ^{2}u_{E}\left ( x,t\right ) }{\partial t^{2}}=0$$, hence above becomes$\frac{\partial ^{2}v\left ( x,t\right ) }{\partial t^{2}}=c\frac{\partial ^{2}v\left ( x,t\right ) }{\partial x^{2}}$ With $$v\left ( x,t\right )$$ having now homogeneous B.C.\begin{align*} v\left ( 0,t\right ) & =0\\ \frac{\partial v\left ( L,t\right ) }{\partial x} & =0 \end{align*}

And initial conditions given by\begin{align*} v\left ( x,0\right ) & =u\left ( x,0\right ) -u_{E}\left ( x\right ) \\ & =0-Cx\\ & =-Cx \end{align*}

And\begin{align*} \frac{\partial v\left ( x,0\right ) }{\partial t} & =\frac{\partial u\left ( x,0\right ) }{\partial t}-\frac{\partial u_{E}\left ( x\right ) }{\partial t}\\ & =0 \end{align*}

In summary, the PDE to solve for $$v\left ( x,t\right )$$ is\begin{align} \frac{\partial ^{2}v\left ( x,t\right ) }{\partial t^{2}} & =c\frac{\partial ^{2}v\left ( x,t\right ) }{\partial x^{2}}\tag{3}\\ v\left ( 0,t\right ) & =0\nonumber \\ \frac{\partial v\left ( L,t\right ) }{\partial x} & =0\nonumber \\ v\left ( x,0\right ) & =-Cx\nonumber \\ \frac{\partial v\left ( x,0\right ) }{\partial t} & =0\nonumber \end{align}

Now we solve for PDE (3) for $$v\left ( x,t\right )$$ using separation of variables since the boundary conditions in space are now homogeneous. Let $$v\left ( x,t\right ) =X\left ( x\right ) T\left ( t\right )$$ and the PDE becomes$\frac{1}{c}T^{\prime \prime }X=X^{\prime \prime }T$ Dividing by $$XT\neq 0$$ gives$$\frac{1}{c}\frac{T^{\prime \prime }}{T}=\frac{X^{\prime \prime }}{X}=-\lambda \tag{4}$$ Where $$\lambda$$ is some real positive constant. The space ODE becomes\begin{align*} X^{\prime \prime }+\lambda X & =0\\ X\left ( 0\right ) & =0\\ X^{\prime }\left ( L\right ) & =0 \end{align*}

Case $$\lambda <0$$: Let The solution is$X\left ( x\right ) =c_{1}\cosh \left ( \sqrt{\lambda }x\right ) +c_{2}\sinh \left ( \sqrt{\lambda }x\right )$ At $$x=0$$$0=c_{1}$ Hence solution becomes $X\left ( x\right ) =c_{2}\sinh \left ( \sqrt{\lambda }x\right )$ Taking derivative$X^{\prime }\left ( x\right ) =\sqrt{\lambda }c_{2}\cosh \left ( \sqrt{\lambda }x\right )$ Using second boundary conditions gives$0=\sqrt{\lambda }c_{2}\cosh \left ( \sqrt{\lambda }L\right )$ Since $$\cosh$$ is zero only when its argument is zero. But we assumed $$\sqrt{\lambda }$$ not zero here, then $$c_{2}=0$$ in only other choice. Hence this gives trivial solution. Therefore $$\lambda <0$$ is not possible.

Case $$\lambda =0$$\begin{align*} X^{\prime \prime } & =0\\ X\left ( 0\right ) & =0\\ X^{\prime }\left ( L\right ) & =0 \end{align*}

Solution is $$X\left ( x\right ) =c_{1}x+c_{2}$$. First B.C. gives $$0=c_{2}$$. Solution becomes $$X\left ( x\right ) =c_{1}x$$. Second B.C. gives $$c_{1}=0$$. This gives trivial solution again. Hence $$\lambda =0$$ is not possible eigenvalue.

Case $$\lambda >0$$: The solution becomes$X\left ( x\right ) =B_{1}\cos \left ( \sqrt{\lambda }x\right ) +B_{2}\sin \left ( \sqrt{\lambda }x\right )$ AT ﬁrst B.C.$0=B_{1}$ Hence solution becomes$X\left ( x\right ) =B_{2}\sin \left ( \sqrt{\lambda }x\right )$ Taking derivative$X^{\prime }\left ( x\right ) =\sqrt{\lambda }B_{2}\cos \left ( \sqrt{\lambda }x\right )$ At second B.C.$0=\sqrt{\lambda }B_{2}\cos \left ( \sqrt{\lambda }L\right )$ To avoid trivial solution, take $$\cos \left ( \sqrt{\lambda }L\right ) =0$$ or $$\sqrt{\lambda }L=\frac{\pi }{2},\frac{3\pi }{2},\frac{5\pi }{2},\cdots$$ or \begin{align} \sqrt{\lambda } & =\frac{\pi }{2L},\frac{3\pi }{2L},\frac{5\pi }{2L},\cdots \nonumber \\ \sqrt{\lambda _{n}} & =\left ( \frac{n\pi }{2L}\right ) \qquad n=1,3,5,\cdots \nonumber \\ & =\frac{\left ( 2n+1\right ) \pi }{2L}\qquad n=0,1,2,\cdots \tag{5} \end{align}

Hence the space solution is$$X_{n}\left ( x\right ) =B_{n}\sin \left ( \sqrt{\lambda _{n}}x\right ) \qquad n=1,3,5,\cdots \tag{6}$$ Now we solve the time ODE $$T\left ( t\right )$$ from (4), which is$T^{\prime \prime }+\lambda cT=0$ The solution is$T_{n}\left ( t\right ) =D_{n}\cos \left ( \sqrt{\lambda _{n}c}t\right ) +E_{n}\sin \left ( \sqrt{\lambda _{n}c}t\right )$ Therefore\begin{align*} v\left ( x,t\right ) & =\sum _{n=0}^{\infty }T_{n}\left ( t\right ) X_{n}\left ( x\right ) \\ & =\sum _{n=0}^{\infty }\left ( D_{n}\cos \left ( \sqrt{\lambda _{n}c}t\right ) +E_{n}\sin \left ( \sqrt{\lambda _{n}c}t\right ) \right ) \sin \left ( \sqrt{\lambda _{n}}x\right ) \end{align*}

Where constant $$B_{n}$$ merged with the other constants. Now At $$t=0$$$-Cx=\sum _{n=0}^{\infty }D_{n}\sin \left ( \sqrt{\lambda _{n}}x\right )$ Applying orthogonality\begin{align*} -\int _{0}^{L}Cx\sin \left ( \frac{\left ( 2n+1\right ) \pi }{2L}x\right ) dx & =D_{n}\int _{0}^{L}\sin ^{2}\left ( \frac{\left ( 2n+1\right ) \pi }{2L}x\right ) dx\\ -C\int _{0}^{L}x\sin \left ( \frac{\left ( 2n+1\right ) \pi }{2L}x\right ) dx & =D_{n}\frac{L}{2}\\ -C\left ( \frac{4\left ( -1\right ) ^{n}L^{2}}{\left ( \pi +2n\pi \right ) ^{2}}\right ) & =D_{n}\frac{L}{2}\\ D_{n} & =-C\frac{8\left ( -1\right ) ^{n}L}{\left ( \pi +2n\pi \right ) ^{2}} \end{align*}

Therefore$v\left ( x,t\right ) =\sum _{n=0}^{\infty }\left ( -C\frac{8\left ( -1\right ) ^{n}L}{\left ( \pi +2n\pi \right ) ^{2}}\cos \left ( \sqrt{\lambda _{n}c}t\right ) +E_{n}\sin \left ( \sqrt{\lambda _{n}c}t\right ) \right ) \sin \left ( \sqrt{\lambda _{n}}x\right )$ Taking time derivative$\frac{\partial v\left ( x,t\right ) }{\partial t}=\sum _{n=0}^{\infty }\left ( C\frac{8\left ( -1\right ) ^{n}L}{\left ( \pi +2n\pi \right ) ^{2}}\frac{\left ( 2n+1\right ) \pi }{2L}\sin \left ( \sqrt{\lambda _{n}c}t\right ) +E_{n}\sqrt{\lambda _{n}c}\cos \left ( \sqrt{\lambda _{n}c}t\right ) \right ) \sin \left ( \sqrt{\lambda _{n}}x\right )$ At $$t=0$$$0=\sum _{n=0}^{\infty }E_{n}\sqrt{\lambda _{n}c}\sin \left ( \sqrt{\lambda _{n}}x\right )$ Hence $$E_{n}=0$$. Therefore solution becomes$v\left ( x,t\right ) =\sum _{n=0}^{\infty }-C\frac{8\left ( -1\right ) ^{n}L}{\left ( \pi +2n\pi \right ) ^{2}}\cos \left ( \sqrt{\lambda _{n}c}t\right ) \sin \left ( \sqrt{\lambda _{n}}x\right )$ Therefore, since $$u\left ( x,t\right ) =v\left ( x,t\right ) +u_{E}\left ( x\right )$$ then$$u\left ( x,t\right ) =Cx-C\sum _{n=0}^{\infty }\frac{8\left ( -1\right ) ^{n}L}{\left ( \pi +2n\pi \right ) ^{2}}\cos \left ( \frac{\left ( 2n+1\right ) \pi }{2L}\sqrt{c}t\right ) \sin \left ( \frac{\left ( 2n+1\right ) \pi }{2L}x\right ) \tag{7}$$

Animation

Code used for the above is

L=10;c=1; C0=5;
sqrtLam= (2 n +1) Pi/(2 L);
Manipulate[
mysol=C0 x-C0 Sum[(8.0(-1)^n L)/(Pi+2n \[Pi])^2 Sin[sqrtLam  x] Cos[sqrtLam  Sqrt[c] t],{n,0,numberOfTerms}%
];
Grid[{{Row[{"Solution at time = ",i}]},
{Plot[mysol/.t->i,{x,0,10},PlotRange->{{0,10},{-10,100}}%
,ImageSize->500,GridLines->Automatic,GridLinesStyle->LightGray,PlotStyle->Red]}%
}],
{{i,0,"time"},0,100,.1,Appearance->"Labeled"},
{{numberOfTerms,1,"n"},1,1000,1,Appearance->"Labeled"}
]