Solve the eigenvalue problem $y''=\lambda y$ numerically

I am trying to solve the eigenvalue problem $$\begin{cases} y''=\lambda y \\y(0)=y(1)=0\end{cases}$$ I use the finite difference to discretize the ODE with BVs. I get the following equation $$\frac{y_{i-1}+2y_i+y_{i+1}}{(\Delta x)^2}=\lambda_{\Delta x}y_i,$$ where $\Delta x =1/{(n+1)}.$

Then I get the following $n \times n$ tridiagonal matrix formulation

$\frac{1}{(\Delta x)^2}\begin{bmatrix}-2&1&~&~\\1&-2&1&~&~ \\~&~&\ddots\\ ~&~&1&-2&1\\~&~&~&1&-2\end{bmatrix}\begin{bmatrix}y_1 \\y_2\\\vdots\\ y_{n-1}\\y_n\end{bmatrix}=\lambda_{\Delta x}\begin{bmatrix}y_1 \\y_2\\\vdots\\ y_{n-1}\\y_n\end{bmatrix}$

I know that the ODE has infinitely many eigenvalue values and eigenfunction. We can compute the eigenvalue numerically by computing the eigenvalues of the matrix on the LHS.

I have two questions.

1. Why can I only get the approximation of the first $n$th eigenvalue ($n\times n$ matrix) instead of the kth to $(k+n-1)$th eigenvalues?

2. If I want to compute the $m$th eigenvalue, do I have to compute the eigenvalues of the $m\times m$ matrix ? When $m$ becomes very large, it needs a lot of computations. Do we have numerical method to compute the $m$th eigenvalue directively?

• I think you would benefit from finding a closed formula for the eigenvalues and the eigenvectors of your $n$by $n$ matrix. Comparing the eigenvalues of the matrix to the eigenvalues of the differential operator would help settle some of your questions. – Carl Christian Nov 29 '17 at 17:48
• I agree, and shouldn't $y = C e^{\sqrt{\lambda}x}$ work as a general solution? – I. Pittenger Jun 27 at 14:10

First, let's move the $$(\Delta x)^2$$ over to the other side. The eigenvalues of the given matrix are well-known to be $$\lambda_j=2\left(\cos\left(\frac{\pi j}{N+1}\right)-1\right).$$ So, indeed, we have an explicit formula for each eigenvalue. Note that the largest eigenvalue (in magnitude) is $$\lambda_N\approx -4,$$ and the smallest is $$\lambda_1,$$ with $$\lambda_j \approx -\left(\frac{j\pi }{N+1}\right)^2$$ for small $$j$$. We also get unit (in $$2$$ norm) eigenvectors $$z_j$$ with entries $$z_j(k)=\sqrt{\frac{2}{N+1}}\sin\left(\frac{jk\pi}{N+1}\right),$$ which you will likely notice as being a discrete analogue of the eigenfuctions for the continuous problem.
I should also note that it is common to make the diagonal entries positive by multiplying both sides of your matrix equation by $$-1$$, providing you with an SPD matrix.