3
$\begingroup$

I have read several websites trying to explain finite-differential equations, but I haven't been able to find one that explains how it's put into the matrix form.

$f(x) = -\frac{d^2u}{dx^2}$ where $u(0) = 0$ and $u(1) = 0$ becomes

$\begin{bmatrix} 2 & -1 & 0 & 0 & 0 \\ -1 & 2 & -1 & 0 & 0 \\ 0 & -1 & 2 & -1 & 0 \\ 0 & 0 & -1 & 2 & -1 \\ 0 & 0 & 0 & -1 & 2 \end{bmatrix}$

multiplied by one column of values between $u_1$ to $u_5$ is equal to

$h^2$$\begin{bmatrix} f(h) \\ f(2h) \\ f(3h) \\ f(4h) \\ f(5h) \end{bmatrix}$

Looking at the equation that causes this matrix, it confuses me. The difference equation is $$-u_{j+1}+2u_j-u_{j-1}=h^2f(jh)$$

The initial term, when $j=1$, should make it so that the equation is:

$$u_2+2u_1-u_0$$

Would this not cause the first row to become $(-1, 2, 0, 0, 0)$ because $u_0$ has been defined as 0? I know that my thinking is wrong, since the book tells me so, but I don't understand how the first and last row is determined.


On a related note, how does the matrix equation if the boundaries are changed? For an example, if $u_0 = 1$ and $u_1 = 2$ on the original equation. Will the answer become

$\begin{bmatrix} 2 & 0 & 0 & 0 & 0 \\ -1 & 2 & -1 & 0 & 0 \\ 0 & -1 & 2 & -1 & 0 \\ 0 & 0 & -1 & 2 & -1 \\ 0 & 0 & 0 & -1 & 2 \end{bmatrix}$

$\endgroup$
  • 1
    $\begingroup$ You might want to learn more about the finite difference methods. I am sure there are enough textbooks on the same that explain the process in detail. $\endgroup$ – user14082 Sep 22 '12 at 18:08
1
$\begingroup$

The first and last row are determined by boundary conditions. For instance, the matrix you've described arises if $u_0$ and $u_6$ are taken to be zero (though other BC might give rise to the same matrix).

As for your second question, we don't get to set the values of $u_1,\ldots,u_5$. Your matrix is multiplying the vector ${\bf u}$ to give the set of finite difference equations. However, $u_0=0$ gives a constraint $$h^2 f(h)=-u_0+2u_1-u_2=2u_1-u_2$$ which is correctly reproduced by the first matrix in your post.

$\endgroup$
  • $\begingroup$ do u have a reference? $\endgroup$ – Charlie Parker Feb 1 '18 at 20:00
0
$\begingroup$

Just adding to the answer, summarizing Jonathan.

\begin{eqnarray} \begin{pmatrix} 2 & 0 & 0 & 0 & 0 \\ -1 & 2 & -1 & 0 & 0 \\ 0 & -1 & 2 & -1 & 0 \\ 0 & 0 & -1 & 2 & -1 \\ 0 & 0 & 0 & -1 & 2 \end{pmatrix} \begin{pmatrix} u_1 \\ u_2 \\ u_3 \\ u_4 \\ u_5 \end{pmatrix} = \begin{pmatrix} f(h) \\ f(2h) \\ f(3h) \\ f(4h) \\ f(5h) \\ \end{pmatrix} \end{eqnarray}

Only $ u_1 $ to $u_5$ goes in the matrix due the Boundary Condition $u_0=u_6=0$, that explains why your logic about the first and last rows were wrong. Just remember the multiplication logic for matrix/array.

$\endgroup$
  • $\begingroup$ do u have a reference? $\endgroup$ – Charlie Parker Feb 1 '18 at 20:01

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.