Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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}$

share|improve this question
1  
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. –  Jayesh Badwaik Sep 22 '12 at 18:08
add comment

2 Answers

up vote 1 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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