To approximate a function f(x) on the interval [-1,1] by a polynomial of degree n, we compute the orthogonal projection on the space spanned by Legendre polynomials L0 through Ln.
In the examples shown below, we take f(x) to be a "delta function" (which is technically a distribution rather than an actual function). The delta function f(x) is supposed to take the value f(x)=0 for all x not equal to zero, and have an "infinite" value for f(0), in such a way that for any continuous function g(x), we have f · g = Integral-11f(x)g(x) dx = g(0). You can think of f(x) as a kind of limit as a goes to zero of the function fa(x) which takes the value fa(x) = 1/(2a) for x in the interval [-a,a], and takes the value fa(x) = 0 for x outside this interval. Note that the area under the graph of fa(x) is equal to 1 for every a>0, but this graph becomes taller and narrower as a approaches zero.
Since we can compute the inner product of our delta function with the Legendre polynomials, we can go ahead and compute its best approximation in each degree n, using the usual formulas. Here are graphs of the approximating polynomials in degrees 10 through 18, computed using Mathematica, a computer algebra system.