# Expansion of this function in a Fourier-Legendre series

Let $f : (-1,1)\to \mathbb{R}$ be given by

$$f(x) = \begin{cases}0, & x\in (-1,0) \\ 1, & x \in [0,1)\end{cases}$$

and suppose we want to compute the Fourier-Legendre series of $f$, that is we want to write

$$f = \sum_{n}c_n P_n$$

with

$$c_n = \dfrac{\langle f,c_n\rangle }{|P_n|^2} = \dfrac{2}{2n+1}\int_{-1}^{1}f(x)P_n(x)dx.$$

This integral, though is quite complicated. Substituting $f$ we have

$$c_n = \dfrac{2}{2n+1}\int_0^1P_n(x)dx.$$

Now, I've been trying to compute the RHS but I still couldn't. I've tried writing

$$P_n(x) = \dfrac{1}{2^nn!}\dfrac{d^n}{dx^n}[(x^2-1)^n]$$

so that

$$c_n = \dfrac{2}{(2n+1)2^n n!} \left[\dfrac{d^{n-1}}{dx^{n-1}}[(x^2-1)^n]\right]_0^1,$$

but still I can't compute the boundary terms. In that case, is there an easier way to compute those coefficients? If not, how could I finish the calculation I've started?

• See formula (49) in mathworld.wolfram.com/LegendrePolynomial.html, where the answer is given. – Omran Kouba Aug 29 '15 at 17:20
• That is the answer, but how does one computes it? – Gold Aug 29 '15 at 17:28
• Anyway, the correct normalization is given by: $$c_n=\frac{2n+1}{2}\int_{0}^{1}P_n(x)\,dx.$$ – Jack D'Aurizio Aug 29 '15 at 17:51

The generating function for Legendre polynomials is given by: $$g(x,t)=\frac{1}{\sqrt{1+t^2-2xt}}=\sum_{n\geq 0}P_n(x)\, t^n\tag{1}$$ hence integrating both sides over $(0,1)$ with respect to $x$, $$\forall t\in(0,1),\qquad \frac{\sqrt{1+t^2}-1+t}{t}=\sum_{n\geq 0}\left(\int_{0}^{1}P_n(x)\,dx\right)t^n\tag{2}$$ and to compute our coefficients it is enough to compute the Taylor series of $\sqrt{1+t^2}$ around $t=0$. That proves formula $(49)$ linked by Omran Kouba and:

$$f(x) = \frac{1}{2}+\sum_{m\geq 0}\frac{4m+3}{4m+4}\cdot\frac{(-1)^m}{4^m}\binom{2m}{m}\cdot P_{2m+1}(x).\tag{3}$$

Equality has to be intended as convergence in $L^2(-1,1)$. Gibbs phenomenon arises: it would be integersting to compute the magnitude of the overshoot near zero.