Suppose we have a eigenvalue problem:
\begin{array}{c}
y^{\prime \prime}+\lambda y=0,0<x<l \\
y(0)=0, y(l)=0
\end{array}
and we know the eigenvalue is $\lambda =\frac{n^{2}\pi ^{2} }{l^{2}} $, and eigenfunction $y\left ( x \right ) =C\sin \frac{n\pi x}{l} $. But if I want to calculate the eigenvalue numerically, I think first I should choose basis for the funtion, and then represent the linear operator in ODE as a matrix. My question is what basis should I pick for this problem? Can I choose basis such as $\left \{1,x,x^{2} , x^{3},... \right \}$ ?

The eigenvalue for this problem is also determined by the boundary conditons, but how does the boundary conditons affect the matrix?

I also found people with related question:([Solve the eigenvalue problem $y''=\lambda y$ numerically](https://math.stackexchange.com/questions/2542976/solve-the-eigenvalue-problem-y-lambda-y-numerically)), and he numerically calculate the problem using finite difference. It seems that his method do not need to find basis. Is this a trick to solve this problem or still related to some kind of basis I am not aware of?