Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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. – Nasser 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}]. – Jacob Akkerboom 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. – Joel Bosveld 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? – ybeltukov Sep 11 '13 at 12:43
On my Linux, v8.0 the indefinite same does not evaluate either. – Eckhard Sep 11 '13 at 13:34
up vote 1 down vote accepted

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]] *)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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