Wave Equation Non-uniform string (PDE)

The wave equation in a non-uniform string is : $$u_{tt} = c(x)^2 u_{xx}$$ $$u(x,0) = f(x) = e^\frac{(x-\mu)^2}{2 \sigma^2} , \:\:u(0,t) = 0\:,\:\:u(L,t) = 0, \:\: u_{t}(x,0) = -cf'(x)$$ with $c(x) = c_{1}$ for $0 \le x \le \frac{L}{2}$, and $c(x) = c_{2}$ for $\frac{L}{2} < x \le L$. Where $L$ is the length of the string.

I have tried using finite difference method to animate the solution and the result is quite nice, by changing the usual difference scheme $$u^{m+1} = (2I - (c\triangle t)^2A)u^{m} - u^{m-1}$$ to $$u^{m+1} = (2I - C(\triangle t^2)A)u^{m} - u^{m-1}$$ where $u(x_{i},t_{m}) \approx u_{i}^{m}$, $x_{i} = i\triangle x$, $t_{m}= m \triangle t$.

$i = 0,1,2,3,...,l$ where $x_{l} = L$ and

$m = 0,1,2,3,.....$

also : $u^{m} = \left[ \begin{array}{c} u_{1}^{m} \\ u_{2}^{m} \\ . \\ . \\ u_{l-2}^{m} \\ u_{l-1}^{m} \end{array} \right]$ , $A = \frac{1}{(\triangle x)^2} \left( \begin{array}{cccccc} 2 & -1 & 0 & 0 & 0 & 0 \\ -1 & 2 & -1 & 0 & 0 & 0 \\ 0 & . & . & . & 0 & 0 \\ 0 & 0 & . & . & . & 0 \\ 0 & 0 & 0 & -1 & 2 & -1 \\ 0 & 0 & 0 & 0 & -1 & 2 \\ \end{array} \right)$ , $C = \left( \begin{array}{cccccccc} c_{1}^2 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & c_{1}^2 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & . & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & c_{1}^2 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & c_{2}^2 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & . & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & c_{2}^2 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & c_{2}^2 \\ \end{array} \right)$

$A$ and $C$ are square matrix of same size (that is $l-2$).

The result looks good (http://www.youtube.com/watch?v=9lDRms5i0Hc). When the wave passes through the joint, some are reflected and some transmitted, but my lecturer said the numerical solution is wrong and i must add another condition for $u$ at the joint.

I wanted to prove it by comparing my numerical solution with the exact solution for the non-uniform string wave equation, can someone share their thought for the exact solution, and numerical scheme that i have done? Thank you

• What are the boundary conditions at $x=0$ and $x=L/2$? Oct 17, 2013 at 1:46
• @Ron Gordon, thanks, i forgot to write the boundary cond. There is no condition for $u(\frac{L}{2},t)$ Oct 17, 2013 at 10:59
• Thanks. You are going to have to tell us the initial conditions as well. Also, what is $A$? And are you sure those are your B.C.s? Not some non-reflecting boundary conditions to simulate plane waves from infinity? Oct 17, 2013 at 11:18
• @Ron, yes i am sure, sorry i dont understand your last question.. Oct 17, 2013 at 11:54
• Many times, when simulating reflections at an interface, we are interested in simulating a simple plane wave from infinity approaching the interface and then seeing the simulated reflected and transmitted waves. In this case, you do not want reflections from an artificial boundary in your solution, so you impose numerical conditions at the boundaries that simulate infinity, i.e., no reflections. This is well known in the literature and I have implemented this myself. Oct 17, 2013 at 12:22

Exact solution Let's first find the following solution of the equation: $u(x,t)=X(x)T(t)$

$$X(x)T''(t)=c(x)^2X''(x)T(t) \Rightarrow\frac{T''(t)}{T(t)}=c(x)^2\frac{X''(x)}{X(x)}$$

Since the left part depens only on $t$ and the right depends only on $x$, then both parts do not depend on either variable:

$$\frac{T''(t)}{T(t)}=c(x)^2\frac{X''(x)}{X(x)}=-\lambda$$

Then we get Sturm-Liouville problem $$X''(x)+\lambda c(x)^2X(x)=0, \\ X(0)=0,X(L)=0$$

Suppose that you found eigenvalues $\lambda_n$ and corresponding eigenfunctions $\mu_n(x)\ne0$.

Since $T''(t)+\lambda T(t)=0,$ then $T(t)=A_ne^t+Be^{-t}$ or $T(t)=A_n(t)\cos t+B_n\sin t$ depending on the sign of $\lambda_n$.

I suppose that $\lambda_n > 0$ here. (It should be)

Then the exact solution has the following form $u(x,t)=\sum\limits_{n=1}^\infty( A_n\sin t+B_n\cos t)\mu_n(x)$ and $u(x,0)=\sum\limits_{n=1}^\infty B_n\mu_n(x)$ and $u'_t(x,0)=\sum\limits_{n=0}^\infty A_n\mu_n(x)$.

By the way you need a boundary condition on $u'_t(x,0)$ so that the problem is correct.

• Thank you @Тимофей, i have tried the separation of variables method before but still difficult to solve the problem. In fact i never knew that the equation is called Sturm-Liouville problem, until you mentioned it. Oct 23, 2013 at 12:49