Legendre expansion of the Dirac delta function
As I understood you start from the completeness relation $$\sum_{\ell=0}^\infty \frac{2\ell + 1}{2} P_\ell(x)P_\ell(y) = \delta(x-y)$$ and use that $$ P_n(0) = \begin{cases} \frac{(-1)^{m}}{4^m} \tbinom{2m}{m} = \frac{(-1)^{m}}{2^{2m}} \frac{(2m)!}{\left(m!\right)^2} & \text{for} \quad n = 2m \\ 0 & \text{for} \quad n = 2m+1 \,. \end{cases}$$
The convergence is, however, not uniform
d[x_,n_]:=Sum[(-1)^k (4 k + 1) (2 k)! LegendreP[2 k, x]/(2^(2 k + 1) k! k!), {k, 0,n}]
Plot[d[x,#],{x,-1,1},PlotRange->All]&/@Range[5,25,5]
I think you're misinterpreting Mathematica output. First of all, notice that the first output you get from Mathematica is a message that precludes the subsequent numerical results being sensible (or at the very least must make you very cautious of them):
Sum::div
: Sum does not converge.
If you omit the N[]
wrapper, you'll get the actual sum simplified to take into account that $P_n(1)\equiv1$:
$$\sum\limits_{k=0}^\infty \frac{(-1)^k 2^{-1-2k}(1+4k)(2k)!}{(k!)^2}.\tag1$$
Plotting the terms of this sum, you'll see that they increase indefinitely in magnitude and alternate in sign. This should already make it obvious that it can't converge.
Now, with your N[]
wrapper you also get another message:
NumericalMath`NSequenceLimit::seqlim
: The general form of the sequence could not be determined, and the result may be incorrect.
What you get after this (on my system it's about $1.82\times10^{-14}$) is a result of an attempt at numerical summation of the divergent series.
While trying to naively sum this series, hoping that after a large enough value of $k$ changes will become negligible, is futile (since the sum is divergent), one may take a different approach, and use a resummation, e.g. the following scheme (known as Abel summation): define
$$S(a)=\sum\limits_{k=0}^\infty \frac{(-1)^k 2^{-1-2k}(1+4k)(2k)!}{(k!)^2}e^{-ak}=\frac{e^a-1}{2\sqrt{e^{-a}+1}(e^a+1)}.\tag2$$
Then eliminate the $a$ by an operation that would, if taken on the terms of the series, yield $(1)$:
$$\lim\limits_{a\to0} S(a)=0.\tag3$$
This is one of the possible values that could be "assigned" to the series $(1)$. I suppose the N[]
function was also trying to evaluate the series using some kind of regulator to speedup convergence. This would indeed work for a convergent sum, since resummation schemes normally preserve the values of convergent sums, only supplying additional values for divergent ones. But in this case, since the series is divergent, you got a resummation, which may or may not be useful to you.