I have this PDE, and I need to build a 2 layer Finite Difference scheme for it.
$\frac{∂^2}{∂x^2}(k(x,t) \frac{∂^2U(x,t)}{∂t^2})=0$
k is just a parameter, which is dependent on x and t. The problem is there are second order derivatives, and I don't know how to couple them together.
First we need to define a grid for the finite difference scheme. I will be using a regular gird here, but the same approach can be used for an irregular grid if the appropriate approximations to derivatives are used. The grid is $$ x_i = x_0 + i\cdot\Delta x \quad\quad t_j = t_0 + j\cdot\Delta t $$ and for a general funciton $f(x,t)$, define $$ f_{i,j} = f(x_i,t_j) $$ which, on a uniform grid, has approximations to its (unmixed) second derivatives $$ \left(\frac{\partial^2 f}{\partial x^2}\right)_{i,j} = \frac{f_{i+1,j} - 2f_{i,j} + f_{i-1,j}}{\Delta x^2} $$ $$ \left(\frac{\partial^2 f}{\partial t^2}\right)_{i,j} = \frac{f_{i,j+1} - 2f_{i,j} + f_{i,j-1}}{\Delta t^2}. $$
For your given equation, we first define $$ F(x,t) = k(x,t) \cdot \frac{\partial^2 U}{\partial t^2}(x,t) $$ thus $$ 0 = \frac{\partial^2 F}{\partial x^2}(x,t). $$ Discretising: \begin{align} 0 &= \frac{1}{\Delta x^2}\left[F_{i+1,j} - 2F_{i,j} + F_{i-1,j}\right] \\ &= \frac{1}{\Delta x^2}\left[k_{i+1,j}\left(\frac{\partial^2 U}{\partial t^2}\right)_{i+1,j} - 2k_{i,j}\left(\frac{\partial^2 U}{\partial t^2}\right)_{i,j} + k_{i-1,j}\left(\frac{\partial^2 U}{\partial t^2}\right)_{i-1,j}\right] \\ &= \frac{1}{\Delta x^2\Delta t^2}\left[k_{i+1,j}\left(U_{i+1,j+1}-2U_{i+1,j}+U_{i+1,j-1}\right) - 2k_{i,j}\left(U_{i,j+1}-2U_{i,j}+U_{i,j-1}\right) + k_{i-1,j}\left(U_{i-1,j+1}-2U_{i-1,j}+U_{i-1,j-1}\right)\right]. \end{align} To use this in a finite difference scheme you will need to specify $U_{i,j}$ at the first two time instances, as well as the left and right endpoints.