Writing systems as $Ax = b$?

44 Views Asked by At

Let's say I have the following system: $$-x_{i-1} + 2x_i - x_{i+1} = 1/(n+1)^2$$ for $i = 1, \ldots , n$ where $x_0 = 0$, $x_{n+1} = 0$, and $n = 20$

This systems happens to approximate a boundary value problem $-u'' = 1$ on $(0,1)$ with conditions $u(0) = u(1) = 0$

I want to write the system as $Ax = b$ but am slightly confused since:

  • $i = 1$ only has $x_0$, $x_1$, and $x_2$ in the equation.
  • $i = 2$ has $x_1$, $x_2$, $x_3$
  • etc...

Does this lead to a tri-diagonal matrix A with each row corresponding to a different value of $i$? I know the $\mathbf{x}$ vector needs to contain $x$ from $0 \to n+1$, which means the number of columns should match.

Thanks!