This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Wolfram Research, Inc.

Numerical IntegrationNumerical Solution of Polynomial Equations

3.9.4 Numerical Evaluation of Sums and Products

Numerical sums and products.

This gives a numerical approximation to .

In[1]:= NSum[1/(i^3 + i!), {i, 1, Infinity}]


There is no exact result for this sum, so Mathematica leaves it in a symbolic form.

In[2]:= Sum[1/(i^3 + i!), {i, 1, Infinity}]


You can apply N explicitly to get a numerical result.

In[3]:= N[%]


The way NSum works is to include a certain number of terms explicitly, and then to try and estimate the contribution of the remaining ones. There are two approaches to estimating this contribution. The first uses the Euler-Maclaurin method, and is based on approximating the sum by an integral. The second method, known as the Wynn epsilon method, samples a number of additional terms in the sum, and then tries to fit them to a polynomial multiplied by a decaying exponential.

Options for NSum.

If you do not explicitly specify the method to use, NSum will try to choose between the methods it knows. In any case, some implicit assumptions about the functions you are summing have to be made. If these assumptions are not correct, you may get inaccurate answers.

The most common place to use NSum is in evaluating sums with infinite limits. You can, however, also use it for sums with finite limits. By making implicit assumptions about the objects you are evaluating, NSum can often avoid doing as many function evaluations as an explicit Sum computation would require.

This finds the numerical value of by extrapolation techniques.

In[4]:= NSum[Exp[-n], {n, 0, 100}]


You can also get the result, albeit much less efficiently, by constructing the symbolic form of the sum, then evaluating it numerically.

In[5]:= Sum[Exp[-n], {n, 0, 100}] //N


NProduct works in essentially the same way as NSum, with analogous options.

Numerical IntegrationNumerical Solution of Polynomial Equations