Mathematica Technical FAQs Services & Resources / Mathematica / Kernels & Programming
-----
 /
Symbols
*Mathematica
*Network Mathematica
*webMathematica
*gridMathematica
*Personal Grid Edition
*Wolfram Workbench
*Wolfram Education Group
*Application Packages
*Mathematica for Students
*Mathematica CalcCenter
*Publicon
*A New Kind of Science Explorer
*Mathematical Explorer
*Mathematica Teacher's Edition
*Calculus WIZ
*Mathematica Player
*Ask about this page
*Print this page
*Email this page
*Give us feedback
*
Sign up for our newsletter:

Sum


Usage Message:

Sum[f, {i, imax}] evaluates the sum of the expressions f as evaluated for each i from 1 to imax. Sum[f, {i, imin, imax}] starts with i = imin. Sum[f, {i, imin, imax, di}] uses steps di. Sum[f, {i, imin, imax}, {j, jmin, jmax}, ... ] evaluates a sum over multiple indices.

Attributes[Sum] = {HoldAll, Protected, ReadProtected}


Notes:

The Sum function typically assumes that symbolic limits are integers with values such that the sum is non-trivial, as in
In[1]:= Sum[1, {k, 0, n}]

Out[1]= 1 + n
which effectively assumes that n is a non-negative integer.

Known Bugs:

Since the limit of summation is assumed to be an integer, the following result could be automatically simplified to (x+y)^n.

In[1]:= Sum[Binomial[n, k] x^k y^(n-k), {k, 0, n}]

         n  x + y n
Out[1]= y  (-----)
              y

The singular term in this sum is ignored.

In[2]:= Sum[1/(2 - x)^2, {x,1,Infinity}]

              2
        6 + Pi
Out[2]= -------
           6
Global values for the index of summation can sometimes interfere with the behavior of Sum.
In[3]:= Sum[nn^-3, {nn, Infinity}]

Out[3]= Zeta[3]

In[4]:= nn = 5; Sum[nn^-3, {nn, Infinity}]

Sum::div: Sum does not converge.

              -3
Out[4]= Sum[nn  , {nn, Infinity}]
The result from Sum is sometimes given in a form which is singular for normal values of the parameters. For example, the following result has a removeable singularity for integer values of n, and so is correct only as a limit.
In[5]:= Sum[Pochhammer[-n,j]/j! (1/2)^j ,{j,0,n}]

                Pi Csc[n Pi]
Out[5]= -(-------------------------)
           n
          2  Gamma[-n] Gamma[1 + n]
Some results are incorrect for symbolic values of the parameters. You can normally get correct results by including explicit integer values for the parameters.

For example, the following result is is wrong if the upper limit of summation is infinite, and the result includes removeable singularities if the upper limit of summation is symbolic.

In[6]:= Sum[Binomial[5, k], {k, 0, Infinity}]

Out[6]= 0

In[7]:= result = Sum[Binomial[5, k], {k, 0, n}]      

             120 Hypergeometric2F1[1, -4 + n, 2 + n, -1] Sin[n Pi]
Out[7]= 32 - -----------------------------------------------------
               (-4 + n) (-3 + n) (-2 + n) (-1 + n) n (1 + n) Pi

In[8]:= result /. n -> 3

                                 1
Power::infy: Infinite expression - encountered.
                                 0

                                          0 ComplexInfinity
Infinity::indet: Indeterminate expression ----------------- encountered.
                                                 Pi

Out[8]= Indeterminate
You can get correct results for both sums using an integer as the upper limit of summation.
In[9]:= Sum[Binomial[5, k], {k, 0, 100}]

Out[9]= 32

In[10]:= Sum[Binomial[5, k], {k, 0, 3}]

Out[10]= 26
Some results involving Zeta and LerchPhi use definitions of these functions that are different than the definitions that are used for numerical evaluation. These results will typically be correct only for limited ranges of the parameters.

For example, the result

In[11]:= Sum[1/(k + a)^s, {k, 0, Infinity}]

Out[11]= Zeta[s, a]
uses Sum[1/(k + a)^s, {k, 0, Infinity}] as the definition of Zeta[s, a]. A different definition, Sum[1/((k + a)^2)^(s/2), {k, 0, Infinity}], is used for computing numerical values of Zeta[s, a]. One consequence of this conflict is that numerical approximations to this result will be correct only when the two definitions coincide, such as when Re[a] is positive.

Similar remarks apply to sums expressed in terms of LerchPhi . The following result uses Sum[z^k/(a+k)^s,{k,0,Infinity}] as the definition of LerchPhi[z,s,a], while numerical evaluation uses the definition Sum[z^k/((a+k)^2)^(s/2),{k,0,Infinity}]. You can get a correct result by inserting the intended definition of LerchPhi , and you can check the result using NSum .

In[12]:= result = Sum[2^-k/(k^2 - 3), {k, 0, Infinity}]

                          1                                  1
         Sqrt[3] LerchPhi[-, 1, -Sqrt[3]] - Sqrt[3] LerchPhi[-, 1, Sqrt[3]]
                          2                                  2
Out[12]= ------------------------------------------------------------------
                                         6

In[13]:= N[result]

Out[13]= 0.422149

In[14]:= result /. LerchPhi[z_, s_, a_] :>
                              NSum[z^k/(k + a)s, {k, 0, Infinity}]

Out[14]= -0.305522

In[15]:= NSum[2^-k/(k^2 - 3), {k, 0, Infinity}]

Out[15]= -0.305522
Some inputs to Sum will incorrectly report that the sum does not converge. For example:
In[16]:= Sum[1/((-1)^n*n^2), {n, 1, Infinity}]

Sum::div: Sum does not converge.

                1
Out[16]= Sum[--------, {n, 1, Infinity}]
                 n  2
             (-1)  n
In this particular example it is possible to get a correct result with a simple rearrangment of the summand:
In[17]:= Sum[(-1)^n/n^2, {n, 1, Infinity}]

            2
         -Pi
Out[17]= ----
          12
Questions about these or other behaviors of Sum can be sent to the Technical Support group at Wolfram Research.


Additional Online Documentation:

Mathematica 3.0
http://documents.wolfram.com/v3/RefGuide/Sum.html

Mathematica 4.0
http://documents.wolfram.com/v4/RefGuide/Sum.html




 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy