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 increase in steps of 2, so that only oddnumbered 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
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
Product[f,{i,imin,imax}]the product

Sums and products.

This sum is computed symbolically as a function of .
In[5]:=
Click for copyable input
Out[5]=
The Wolfram System 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]=

The Wolfram Language 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 . Notice that in Wolfram Language notation, as in standard mathematical notation, the range of the outermost variable is given first.

This is the multiple sum . Notice that the outermost sum over 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 the Wolfram Language 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 times, without incrementing any variables
{i,imax}i goes from to in steps of
{i,imin,imax}i goes from to in steps of
{i,imin,imax,di}i goes from to in steps of di
{i,imin,imax},{j,jmin,jmax}, i goes from to , and for each such value, j goes from to , etc.

Wolfram Language iterator notation.