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 
 A: 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.
