1
$\begingroup$

$$\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?

$\endgroup$
1
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Thank you for the help. The figure that is generated by the 2nd code doesn't have a plot on my end. It's just the axis and blank space. Does the pattern have something to do with the Helmholtz equation? $\endgroup$ – Peetrius Nov 12 '17 at 1:53
  • 1
    $\begingroup$ Nice plot. One can also use A = toeplitz([-2 1 zeros(1,n-2)]); and then fix the top left and bottom right corners with A([1,end],[1,end]) = -1;. $\endgroup$ – Fabio Somenzi Nov 12 '17 at 7:32
  • 1
    $\begingroup$ @Peetrius I forgot to add ‘o’ in line 5. And I don’t think it has anything to do with the Helmholtz equation, why do you think it does? $\endgroup$ – Tobias Molenaar Nov 12 '17 at 10:52
  • $\begingroup$ This particular problem is part of a section of the book related to it. $\endgroup$ – Peetrius Nov 13 '17 at 4:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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