# A Finding eigenvalues with spectral technique: basis functions fail

#### joshmccraney

Hi PF!

I'm trying to find the eigenvalues of this ODE $$y''(x) + \lambda y = 0 : u(0)=u(1)=0$$ by using the basis functions $\phi_i = (1-x)x^i : i=1,2,3...n$ and taking inner products to formulate the matrix equation $$A_{ij} = \int_0^1 \phi_i'' \phi_j \, dx\\ B_{ij} = \int_0^1 \phi_i\phi_j\,dx :\\A+\lambda B = 0 .$$
Solving $A+\lambda B = 0$ is direct; it's a linear algebraic equation. We can compare our approximate solution to the exact solution $(i \pi)^2 : i=1,2,3...$ In this way, I know if a solution is correct or not.

Understanding the above, why is it if I choose the basis functions to begin at $i=2$ I do not get the correct solution? I assume in this case the basis does not span the solution's function space, but can someone elaborate? How do I know if a given basis function spans the solution space?

Last edited:

Why are Bij =0??

#### Haborix

I second hutch's question. For your question, I suggest you consider what the true eigenfunctions are for this ODE and how many functions in your basis you need to represent even one of the exact eigenfunctions.

#### joshmccraney

Why are Bij =0??

For your question, I suggest you consider what the true eigenfunctions are for this ODE and how many functions in your basis you need to represent even one of the exact eigenfunctions.
I appreciate your feedback But this doesn't answer my question. If I don't know the exact eigenfuctions, how would I know to include the first term, $\phi_1$?

#### hutchphd

Because you need a complete basis in general. What prompts the question? Frankly, I don't see the point here. Why do you think you can pick and choose?

#### joshmccraney

Because you need a complete basis in general. What prompts the question? Frankly, I don't see the point here. Why do you think you can pick and choose?
You're coming across a little rude, and I don't know why. But we all have bad days, so it's okay, and here is some background, and also why I didn't say complete (because obviously I'm out of my league if I try to use that word).

If anyone reading this I really don't think you need the background, as the actual problem I'm working on is very complicated. However, the simple one I've manufactured in the question stem should be sufficient to help me out.

Does anyone know why we need to include the $\phi_1$ term? Without knowing the exact solution, how would I know that I'm missing a term?

#### Infrared

Gold Member
I am having some trouble following. It looks like you're trying to find a solution to your ODE that is in the space of functions spanned by $\phi_1,\ldots,\phi_n$, but (unless $\lambda=0$) there won't be a nonzero solution in the span. Perhaps you don't mean to include only finite many $\phi_i$ and want to allow infinite sums? Could you clarify?

#### joshmccraney

I am having some trouble following. It looks like you're trying to find a solution to your ODE that is in the space of functions spanned by $\phi_1,\ldots,\phi_n$, but (unless $\lambda=0$) there won't be a nonzero solution in the span. Perhaps you don't mean to include only finite many $\phi_i$ and want to allow infinite sums? Could you clarify?
There is a non-zero solution though. Just using $n=1$ recovers $\lambda = 10$, which is close to $(1\cdot\pi)^2$. And if we increase the number of terms we recover higher eigenvalues and accuracy of each. Or am I not understanding you?

And yes, I'm only using finitely many $\phi_i$. If I use $i = 2:5$ I get a bad solution, but if I use $i = 1:4$ I get a good solution. I know it's good because it matches the exact. But if I didn't have the exact solution to compare, how would I know what is right?

#### hutchphd

You're coming across a little rude, and I don't know why.
Sorry about the rude (didn't intend it) but i am still not quite sure what you are asking (and I am not a mathematician).
And yes, I'm only using finitely many ϕiϕi\phi_i. If I use i=2:5i=2:5i = 2:5 I get a bad solution, but if I use i=1:4i=1:4i = 1:4 I get a good solution. I know it's good because it matches the exact. But if I didn't have the exact solution to compare, how would I know what is right?
For instance I don't know what "right" means in the above....What do you mean "matches".....not exactly surely?

#### joshmccraney

Sorry about the rude (didn't intend it) but i am still not quite sure what you are asking (and I am not a mathematician).

For instance I don't know what "right" means in the above....What do you mean "matches".....not exactly surely?
Thanks for saying that, and I'm sorry for the ambiguity. The the first four analytic eigenvalues are $$\lambda_{1-4} = { {9.8696}, {39.4784}, {88.8264}, {157.914} }.$$

When I compute the matrices using $\phi_{1-4}$ I recover $$\lambda _{1-4} = { {9.86975}, {39.5016}, {102.13}, {200.498} }$$

which looks pretty good. However, when I compute the matrices using $\phi_{2-5}$ I recover $$\lambda _{1-4} = { {10.4331}, {41.3846}, {92.123}, {244.059} }$$ which is clearly wrong. Without an analytic solution to compare to, how would I know which computed eigenvalues are correct?