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]



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.

  • 1
    $\begingroup$ 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. $\endgroup$
    – Nasser
    Sep 11, 2013 at 7:57
  • $\begingroup$ 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}]. $\endgroup$ Sep 11, 2013 at 10:12
  • $\begingroup$ @Nasser Thanks for the comment, I've updated the question saying that it was tested on Mathematica 9.01 on Linux. $\endgroup$ Sep 11, 2013 at 12:12
  • 1
    $\begingroup$ On my Linux, V 9.0.1 I've got the same result as Nasser. Do you perform it on a fresh kernel? $\endgroup$
    – ybeltukov
    Sep 11, 2013 at 12:43
  • $\begingroup$ On my Linux, v8.0 the indefinite same does not evaluate either. $\endgroup$
    – Eckhard
    Sep 11, 2013 at 13:34

1 Answer 1


Maybe not a direct answer to your question, but you can simplify the coefficients and be careful in the summation :

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

1/2 + Sum[myg2[2 i + 1] x^(2 i + 1), {i, 0, Infinity}]
(* 1/2 + 1/2 Erf[x/Sqrt[2]] *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.