3
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ This is simply because $D_+ D_+ \neq D^2$ you need the information before and behind (to get the same stencil). Try multiplying $D_+ D_-$ (the forward diff operator and backward). $\endgroup$ – Gregory Jul 20 '17 at 18:29
  • $\begingroup$ Thanks, however, I am wondering something like the following: $\frac{d}{dx} \frac{df}{dx} = \frac{d^2f}{dx^2}$, so why does $D(Df) \neq D^2f$? You are taking the derivative of the derivative of $f$, so why do you not get the second derivative of $f$? $\endgroup$ – islanss Jul 20 '17 at 18:37
  • 1
    $\begingroup$ You do get D^2, just not the approximation you're thinking of. Try expanding these operators in a taylor series to see. $\endgroup$ – Gregory Jul 20 '17 at 18:43
  • 2
    $\begingroup$ It would probably be better if you didn't think of your second matrix in the question as the FD matrix, but rather a FD matrix. $\endgroup$ – Gregory Jul 20 '17 at 18:48
  • 2
    $\begingroup$ That's exactly the point. Just like there is a forward and a backward first derivative matrix, there are multiple choices to compute second derivatives. $D_+D_+$ happens to be one of them, just not the one you've seen before. $\endgroup$ – Wolfgang Bangerth Jul 20 '17 at 20:29
5
$\begingroup$

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.

$\endgroup$
-1
$\begingroup$

Your matrices are not well defined. The second derivative operator for example, takes three consecutive data values and outputs one second derivative value. That is not expressed by writing a square matrix.

There is a well-recognised Calculus of Finite Differences. You can find books with that phrase in the title, and you will find everything to be consistent and useful

$\endgroup$
  • $\begingroup$ Would the downvoter care to explain?? $\endgroup$ – Philip Roe Jul 21 '17 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.