Finding eigenvalues of tridiagonal matrix using MATLAB

896 Views Asked by At

$$\begin{bmatrix} -1 & 1 & 0 &\dots &\dots &\dots &0\\ 1 & -2 & 1 & \ddots & & & \vdots\\ 0 & 1 & -2 & \ddots & \ddots & & \vdots\\ \vdots & \ddots & \ddots & \ddots & \ddots & \ddots & \vdots\\ \vdots & & \ddots & \ddots & -2 & 1 & 0\\ \vdots & & & \ddots & 1 & -2 & 1\\ 0 & \dots & \dots & \dots & 0 & 1 & -1\\ \end{bmatrix}\in \mathbb{R}^{N\times N}$$

Is the matrix I'm trying to solve. I'm trying to figure out what to do in MATLAB, but I'm not familiar with the program to use it. What is the process one would to to solve for the eigen values for this matrix?

1

There are 1 best solutions below

4
On BEST ANSWER

Using diag you can create your matrix 1. Using eig you can determine the eigenvalues 2. Here is the code:

n = 4;
A = diag(-2*ones(n,1))+ diag(ones(n-1,1),1) + diag(ones(n-1,1),-1);
A(1,1) = -1;A(n,n) = -1;
eig(A)

You can alter $n$ to change the size of the matrix. Because we are using MATLAB we can easily visualize the eigenvalues for different $n$. With this code:

for n = 1:50
A = diag(-2*ones(n,1))+ diag(ones(n-1,1),1) + diag(ones(n-1,1),-1);
A(1,1) = -1;A(n,n) = -1;
plot(eig(A),n,’o’)
hold  on
end

We can create this picture, with the eigenvalues on the x-axis and the size of the matrix on the y-axis. You can see a pattern, you can prove why this is.

eigenvalues