**1.5.4 Sums and Products**

This constructs the sum

.
In[1]:= **Sum[x^i/i, {i, 1, 7}]**

Out[1]=

You can leave out the lower limit if it is equal to 1.
In[2]:= **Sum[x^i/i, {i, 7}]**

Out[2]=

This makes increase in steps of

, so that only odd-numbered values are included.
In[3]:= **Sum[x^i/i, {i, 1, 5, 2}]**

Out[3]=

Products work just like sums.
In[4]:= **Product[x + i, {i, 1, 4}]**

Out[4]=

Sums and products.

This sum is computed symbolically as a function of

.
In[5]:= **Sum[i^2, {i, 1, n}]**

Out[5]=

Mathematica can also give an exact result for this infinite sum.
In[6]:= **Sum[1/i^4, {i, 1, Infinity}]**

Out[6]=

As with integrals, simple sums can lead to complicated results.
In[7]:= **Sum[1/(i^4 + 2), {i, 1, Infinity}]**

Out[7]=

This sum cannot be evaluated exactly using standard mathematical functions.
In[8]:= **Sum[1/(i! + (2i)!), {i, 1, Infinity}]**

Out[8]=

You can nevertheless find a numerical approximation to the result.
In[9]:= **N[%]**

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 . 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 i

is given first, just as in the mathematical notation.
In[10]:= **Sum[x^i y^j, {i, 1, 3}, {j, 1, i}]**

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 (Section 1.8.2), and when we describe Do loops (Section 1.7.3).

*Mathematica* iterator notation.