## Linear Algebra and Its Applications, Exercise 1.7.2

Exercise 1.7.2. Given the differential equation $-\frac{d^2u}{dx^2} + u = x, \quad u(0) = u(1) = 0$

what is the finite difference matrix for $h = \frac{1}{4}$ (corresponding to a 3 by 3 matrix)? $-\frac{d^2u}{dx^2} + u \approx - [u(x-h) - 2u(x) + u(x+h)]/h^2 + u(x)$

so that the equation above can be expressed in finite-difference terms as $-[u_{j-1} - 2u_j + u_{j+1} + u_j]/h^2 + u_j = jh$ $\rightarrow -u_{j-1} + 2u_j - u_{j+1} + h^2 u_j = h^2 jh$ $\rightarrow -u_{j-1} + (2 + h^2)u_j - u_{j+1} = h^3 j$

replacing continuous values of $x$ by a set of discrete values $x = jh$, so tht $u_j$ is the approximation of $u(x)$ at the point $x = jh$.

In this case we have $h = \frac{1}{4}$ and are thus considering meshpoints $x = jh, 0 \le j \le 4$. The above equation can then be rewritten as $-u_{j-1} + (2 + \frac{1}{4}^2) u_j - u_{j+1} = (\frac{1}{4})^3 j$

This equation can be simplified as follows: $-u_{j-1} + (2 + \frac{1}{16})u_j - u_{j+1} = \frac{1}{64}j$ $\rightarrow -u_{j-1} + \frac{33}{16}u_j - u_{j+1} = \frac{1}{64} j$

We already know that $u(0) = u(1) = 0$ so that we have $u_0 = u_4 = 0$. For $j = 1$ the above equation becomes $-u_0 + \frac{33}{16} u_1 - u_2 = 1 \cdot \frac{1}{64} \rightarrow \frac{33}{16} u_1 - u_2 = \frac{1}{64}$ $\rightarrow 33 u_2 - 16 u_3 = \frac{1}{4}$

For $j = 2$ the above equation becomes $-u_1 +\frac{33}{16} u_2 - u_3 = 2 \cdot \frac{1}{64} \rightarrow -u_1 + \frac{33}{16} u_2 - u_3 = \frac{2}{64}$ $\rightarrow -16u_1 + 33u_2 - 16u_3 = \frac{1}{2}$

and for $j = 3$ the above equation becomes $-u_2 + \frac{33}{16} u_3 - u_4 = 3 \cdot \frac{1}{64} \rightarrow -u_2 + \frac{33}{64} u_1 = \frac{3}{64}$ $\rightarrow -16u_2 + 33u_3 = \frac{3}{4}$

The corresponding 3 by 3 finite-difference matrix is then $\begin{bmatrix} 33&-16& \\ -16&33&-16 \\ &-16&33 \end{bmatrix} \begin{bmatrix} u_1 \\ u_2 \\ u_3 \end{bmatrix} = \begin{bmatrix} \frac{1}{4} \\ \frac{1}{2} \\ \frac{3}{4} \end{bmatrix}$

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition , Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books .

This entry was posted in linear algebra. Bookmark the permalink.