# Wave Equation with Constant Boundary Conditions

I need to find a formal solution to

\begin{eqnarray} &u_{tt} &= c^2 u_{xx}, \;\;\;0<x<1, \mathrm{and \;}t>0\\ &u(x,0)&=x+1,\\ &u_t(x,0)&=x(1-x), \;\;\;\;0 \leq x \leq 1\\ &u(0,t) &= 1,\\ &u(1,t)&= 2, \;\;\;\;\;\;\;\;\;\;\;\;\; t\geq 0 \end{eqnarray}

I tried doing separation of variables and assuming $u(x,t)=X(x)\cdot T(t)$, but the boundary conditions are confusing me.

I get $X^{\prime\prime}(x)+\lambda X(x)=0$, so $X(x) = \alpha e^{-\sqrt{-\lambda}x}+\beta e^{\sqrt{-\lambda}x}$. When I use $X(0)=1$ and $X(1)=2$, I get,

\begin{eqnarray} \beta &=& \frac{2-e^{-\sqrt{-\lambda}}}{e^{\sqrt{-\lambda}}+e^{-\sqrt{-\lambda}}}\\ \alpha&=& \frac{2e^{-\sqrt{-\lambda}}+e^{\sqrt{-\lambda}}-2}{e^{\sqrt{-\lambda}}+e^{-\sqrt{-\lambda}}}, \end{eqnarray}

but I feel like this isn't leading me in the right direction. Any suggestions?

• Welcome to SciComp! This question is a problem that doesn't require techniques in computational science, and it's probably a better fit for Mathematics Stack Exchange. Commented Sep 25, 2014 at 22:42
• Is there a typo in the equation in the last term? Did you mean to say $u_{xx}$ instead of $xx$? Commented Sep 26, 2014 at 1:45
• Yes that is correct. I put + instead of _. Thanks! Commented Sep 29, 2014 at 1:00

Separation of variables works only for homogeneous boundary conditions. Begin by reducing to homogeneous by subtracting off a solution of the PDE which satisfies the boundary conditions. Namely, let $v(x,y) = u(x,y)-1-x$. The new function satisfies $$\begin{split} v_{tt} &= c^2 v_{xx}, \quad 0<x<1, \mathrm{and \;}t>0\\ v(x,0) &= 0,\\ v_t(x,0)&=x(1-x), \quad 0 \leq x \leq 1\\ v(0,t) &= 0,\\ v(1,t) &= 0, \qquad t\geq 0 \end{split}$$ The rest is standard: solve $X''+\lambda X=0$, getting $X_n(x) = \sin \pi nx$ and $\lambda = (\pi n)^2$. Then look for the coefficients in $$u(x,t)= (A_n \cos \pi n t+B_n \sin \pi n t) \sin \pi n x$$ that match the initial conditions.