This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
 MATHEMATICA TUTORIAL Related Tutorials »| Functions »

# Sums and Products

This constructs the sum .
 Out[1]=
You can leave out the lower limit if it is equal to 1.
 Out[2]=
This makes i increase in steps of 2, so that only odd-numbered values are included.
 Out[3]=
Products work just like sums.
 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 .
 Out[5]=
Mathematica can also give an exact result for this infinite sum.
 Out[6]=
As with integrals, simple sums can lead to complicated results.
 Out[7]=
This sum cannot be evaluated exactly using standard mathematical functions.
 Out[8]=
You can nevertheless find a numerical approximation to the result.
 Out[9]=
Mathematica also has a notation for multiple sums and products. Sum represents a sum over i and j, which would be written in standard mathematical notation as . Notice that in Mathematica 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.
 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 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.

Mathematica iterator notation.