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

Sums and Products

This constructs the sum .
In[1]:=
Click for copyable input
Out[1]=
You can leave out the lower limit if it is equal to 1.
In[2]:=
Click for copyable input
Out[2]=
This makes i increase in steps of 2, so that only odd-numbered values are included.
In[3]:=
Click for copyable input
Out[3]=
Products work just like sums.
In[4]:=
Click for copyable input
Out[4]=
Sum[f,{i,imin,imax}]the sum f
Sum[f,{i,imin,imax,di}]the sum with i increasing in steps of di
Sum[f,{i,imin,imax},{j,jmin,jmax}]
the nested sum f
Product[f,{i,imin,imax}]the product f

Sums and products.

This sum is computed symbolically as a function of n.
In[5]:=
Click for copyable input
Out[5]=
Mathematica can also give an exact result for this infinite sum.
In[6]:=
Click for copyable input
Out[6]=
As with integrals, simple sums can lead to complicated results.
In[7]:=
Click for copyable input
Out[7]=
This sum cannot be evaluated exactly using standard mathematical functions.
In[8]:=
Click for copyable input
Out[8]=
You can nevertheless find a numerical approximation to the result.
In[9]:=
Click for copyable input
Out[9]=
Mathematica also has a notation for multiple sums and products. Sum[f, {i, imin, imax}, {j, jmin, jmax}] represents a sum over i and j, which would be written in standard mathematical notation as f. Notice that in Mathematica notation, as in standard mathematical notation, the range of the outermost variable is given first.
This is the multiple sum xiyj. Notice that the outermost sum over i is given first, just as in the mathematical notation.
In[10]:=
Click for copyable input
Out[10]=
The way the ranges of variables are specified in Sum and Product is an example of the rather general iterator notation that Mathematica uses. You will see this notation again when we discuss generating tables and lists using Table ("Making Tables of Values"), and when we describe Do loops ("Repetitive Operations").
{imax}iterate imax times, without incrementing any variables
{i,imax}i goes from 1 to imax in steps of 1
{i,imin,imax}i goes from imin to imax in steps of 1
{i,imin,imax,di}i goes from imin to imax in steps of di
{i,imin,imax},{j,jmin,jmax},... i goes from imin to imax, and for each such value, j goes from jmin to jmax, etc.

Mathematica iterator notation.