[Math] Numerical integration of legendre polynomials

integrationna.numerical-analysisorthogonal-polynomials

I hope that numerical questions are also permitted here.

I want to expand a smooth functions $f \in C^{\infty}$in terms of Legendre polynomials. Thus I need to calculate integrals of the form $\int_{-1}^{1} f(x) P_n(x)$, where $n$ becomes sufficiently large (between 40 and 80). In that regime, the Legendre polynomials oscillate heavily, so my question is whether you are aware of a particular method that is good for integrating such things, cause the standard MATLAB method ( probably some low-level Newton Cotes method) cannot do it sufficiently accurate.

Although this is not a pure math question, I think that this question is of some particular value in applications, so please be not to hard with me 😉

Best Answer

It seems fundamentally ill-conditioned.

Since $\int_{-1}^{+1} x^rP_n(x),dx=0$ for $r=0,1,\dots,n-1$, your integral is unchanged if you subtract a polynomial of degree $n-1$ from $f(x)$. I'm guessing that if you can do that very accurately for some polynomial that approximates $f(x)$, the resulting integral won't be so ill-conditioned as the original.

Related Question