Compute Symbolic Sums

    Note:   Use only in the MuPAD Notebook Interface. This functionality does not run in MATLAB.

Suppose you have an expression with a set of discrete values of a variable. Computing a sum of this expression over the set of variables is called summation. The variable over which you compute the sum is called the summation index. The function you get as a result of a symbolic summation is called antidifference. MuPAD® implicitly assumes that the summation index uses only integer values. For continuous values of a variable, summation naturally turns to integration. Similarly to integration, you can compute indefinite and definite sums including sums over roots of polynomials.

Indefinite Sums

The function is called the indefinite sum of xi over i, if the following identity holds for all values of i:


When you compute an indefinite sum, the result often involves much more complicated functions than those you use in the original expression. If the original expression consists of elementary functions, you can get the result in terms of elementary functions:

sum(x^2/(x^2 - 1), x)

Although the following expression consists of elementary functions, the result involves a special function:

sum(x/(x^2 + 1), x)

Definite Sums

When computing an indefinite sum, the sum command implicitly assumes that the integration index runs through all integer numbers. Definite summation lets you specify the range of the summation index. For example, specify the summation index range using a symbolic parameter:

sum(x/(x^2 + 1), x = a..10*a)

sum also computes definite sums with infinite boundaries:

sum(x^n/n!, n = 0..infinity);
sum((-1)^n*x^(2*n + 1)/(2*n + 1)!, n = 0..infinity)

To find a sum over two variables, use nested calls to sum:

sum(sum(x^n/n!, n = 0..infinity), x = a..100*a)

If your sum has a small finite number of terms, use the _plus command instead of sum. The sum command is slower than _plus:

_plus(x/(x^2 + 1) $ x = 0..10)

To compute a sum for a large finite number of terms, use the sum command:

sum(x/(x^2 + 1), x = 1..10^10)

If the result of a finite summation contains more than 1000 terms, the sum command returns an unexpanded symbolic sum. If you want to display all the terms explicitly, use the expand function. To get the expanded result in the following example, delete the colon at the end of the example:

S := sum(exp(x)/(x^2 + 1), x = a..a + 1000);

Sums Over Roots of a Polynomial

The sum command also computes sums for which the summation index runs over all roots of a polynomial. To specify all roots of a polynomial, use RootOf:

sum(i^10, i = RootOf(a*X^10 + b*X^8 + c*X^5 + 1, X))

Was this topic helpful?