This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / The Mathematica Book / Practical Introduction / Symbolic Mathematics  /

1.5.4 Sums and Products

  • This constructs the sum

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


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


  • This makes increase in steps of

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


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


    Sums and products.

  • This sum is computed symbolically as a function of

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


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


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


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


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


    Mathematica also has a notation for multiple sums and products. Sum[f,




    ] 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}]


    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.