How to get the inverse of this matrix
$$\begin{pmatrix} 2&-1\\-1&2&-1\\&-1&2&-1\\&&&\ddots\\&&&&\ddots\\&&&&-1&2&-1\\&&&&&-1&2 \end{pmatrix}$$
where the blank entries are all zero?
How to get the inverse of this matrix
$$\begin{pmatrix} 2&-1\\-1&2&-1\\&-1&2&-1\\&&&\ddots\\&&&&\ddots\\&&&&-1&2&-1\\&&&&&-1&2 \end{pmatrix}$$
where the blank entries are all zero?
Lets do an example using your matrix with dimension $4x4$, symmetric, tridiagonal.
We have the matrix:
$$\displaystyle A = \begin{bmatrix}2&-1&0&0\\-1&2&-1&0\\0&-1&2&-1\\0&0&-1&2\end{bmatrix}.$$
The inverse of this matrix:
$$\displaystyle A^{-1} = \frac{1}{5}\begin{bmatrix}4 & 3 & 2 & 1\\3 & 6 & 4 & 2\\2 & 4 & 6 & 3\\1 & 2 & 3 &4\\\end{bmatrix}.$$
Look at the structure of the "first and fourth" and "second and third" rows.
If you are looking for the eigenvalues and eigenvectors, we have:
$$\displaystyle \lambda_1 = \frac{1}{2} (5+\sqrt{5}), ~v_1 = (-1, \frac{1}{2} (1+\sqrt{5}), \frac{1}{2} (-1-\sqrt{5}), 1)$$
$$\displaystyle \lambda_2 = \frac{1}{2} (3+\sqrt{5}), ~v_2 = (1, \frac{1}{2} (1-\sqrt{5}), \frac{1}{2} (1-\sqrt{5}), 1)$$
$$\displaystyle \lambda_3 = \frac{1}{2} (5-\sqrt{5}), ~v_3 = (-1, \frac{1}{2} (1-\sqrt{5}), \frac{1}{2} (-1+\sqrt{5}), 1)$$
$$\displaystyle \lambda_4 = \frac{1}{2} (3-\sqrt{5}), ~v_4 = (1, \frac{1}{2} (1+\sqrt{5}) \frac{1}{2} (1+\sqrt{5}), 1)$$
That should help you follow the Wiki algorithm and @joriki provided the algorithm for using the normalized eigenvector and eigenvalue as another approach.
Let $n$ be the dimension of the matrix. It has normalized eigenvectors $v_j$ with
$$v_{jk}=\sqrt\frac2{n+1}\sin\frac{jk\pi}{n+1}$$
corresponding to eigenvalues
$$ \lambda_j=4\sin^2\frac{j\pi}{2(n+1)}, $$
so it can be represented as $V\Lambda V$, and its inverse as $V\Lambda^{-1}V$.
this matrix inverse is $A=A_{ij}$ and $$A_{ij}=\min{\{i,j\}}$$
B = Matrix(5, 5, lambda i,j: 2 if i==j else (-1 if abs(i-j)==1 else 0)); B**-1
– Rodrigo de Azevedo
May 08 '23 at 12:09