# Sum[expr,{i,0,Infinity}] for power series of cumulative normal distribution gives exponential function?

The Taylor series (about 0) for the cumulative normal distribution has coefficients:

g[i_] := Piecewise[{{Sqrt[Pi/2], i == 0}, {(-1/2)^((i - 1)/2)/(((i - 1)/2)!*i), Mod[i, 2] == 1}}]/Sqrt[2*Pi]


However,

Sum[g[i]*x^i,{i,0,Infinity}]


gives $e^x$ and not the $\frac{1}{2} + \frac{1}{2} \operatorname{erf}\left(\frac{x}{\sqrt{2}}\right)$ expected.

When I

Plot[Sum[g[i]*x^i, {i, 0, 20}], {x, -5, 5}]


I get something looking like an exponential (not expected). But when I

Plot[Evaluate[Sum[g[i]*x^i, {i, 0, 20}]], {x, -5, 5}]


I get something looking like the cumulative normal distribution (expected). Trying to understand the different plots, I looked at

{Limit[Sum[g[i]*x^i, {i, 0, n}], n -> 3], Sum[g[i]*x^i, {i, 0, 3}]}


Which gave $\left\{\frac{e^x \Gamma (4,x)}{6},-\frac{x^3}{6 \sqrt{2 \pi }}+\frac{x}{\sqrt{2 \pi }}+\frac{1}{2}\right\}$ - the choice of n=3 is just for tidiness, similar results hold for all n (that I tried). These are clearly not equal as substituting $x\to 0$ gives $\{1,\frac{1}{2}\}$.

This, presumably, explains why I am getting the incorrect answer for the infinite sum and different plot results depending on the placement of the evaluate. Is there an explanation as to why I get different results with/without the limit and how to work around it (in the infinite sum case)?

The motivation is that I am trying to combine these coefficients in other infinite sums (corresponding to cumulative distribution of a sum of Gaussians centered at different positions) and it is giving results that differ from the series expansion I otherwise would obtain (using Series).

The above was tested on Mathematica 9.01 on Linux.

EDIT Turns out that the sum doesn't evaluate on Mathematica 9.01, there was traces of previous definitions lying around that caused it to evaluate when it shouldn't have. Solution is to avoid the piecewise definition and explicitly only sum the odd terms.

• on V 9.01 on windows, the sum does not evaluate. I copied what you had there. screen shot: !Mathematica graphics it always helps to say what version and platform you are using. Sep 11 '13 at 7:57
• Hm, strangely Mathematica does simplify Sum[Piecewise[{{1, Mod[i, 2] == 0}}], {i, 0, n}] but not Sum[Piecewise[{{i, Mod[i, 2] == 0}}], {i, 0, n}]. Sep 11 '13 at 10:12
• @Nasser Thanks for the comment, I've updated the question saying that it was tested on Mathematica 9.01 on Linux. Sep 11 '13 at 12:12
• On my Linux, V 9.0.1 I've got the same result as Nasser. Do you perform it on a fresh kernel? Sep 11 '13 at 12:43
• On my Linux, v8.0 the indefinite same does not evaluate either. Sep 11 '13 at 13:34

myg2[i_] = (-1/2)^((i - 1)/2)/(((i - 1)/2)!*i)/Sqrt[2*Pi]