The finite difference matrix for the first derivative is$\begin{bmatrix} -1 & 1 & 0 \\ 0 & -1 & 1 \\ 0 & 0 & -1 \end{bmatrix}$.The finite difference matrix for the second derivative is$\begin{bmatrix} -2 & 1 & 0 \\ 1 & -2 & 1 \\ 0 & 1 & -2 \end{bmatrix}$.$\begin{bmatrix} -1 & 1 & 0 \\ 0 & -1 & 1 \\ 0 & 0 & -1 \end{bmatrix}\begin{bmatrix} -1 & 1 & 0 \\ 0 & -1 & 1 \\ 0 & 0 & -1 \end{bmatrix} = \begin{bmatrix} 1 & -2 & 1 \\ 0 & 1 & -2 \\ 0 & 0 & 1 \end{bmatrix}$.Why does multiplying together two first derivative matrices not give the second derivative matrix?
Why does multiplying two first derivative finite difference matrices not give the matrix for the second derivative?
finite difference
Look at the operators $$D_+^2 u = \frac{u_{n+2} - 2 u_{n+1} + u_n}{\Delta x^2}.$$If you taylor expand this for small $\Delta x$ you arrive at$$D_+^2 u = u_{xx} - \Delta x u_{xxx} + O(\Delta x^2)$$.Thus $D_+^2 = D^2$ in the limit as $\Delta x \to 0$ (as it should), but note the error is first order in $\Delta x$ and so it is not a great approximation.Consider instead, the one you are thinking of$$D_- D_+ u = \frac{u_{n+1} - 2 u_n + u_{n-1}}{\Delta x^2}.$$Again taking a taylor expansion we have$$D_- D_+ u = u_{xx} + \frac{\Delta x^2}{12} u_{xxxx} + O(\Delta x^4).$$Thus this approximation is actually better since the error goes down quadratically rather than linearly.However in the limit they are equivalent.