Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

**MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.**

**MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.**

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.

The function
is
called the indefinite sum of * x_{i}* 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)

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); expand(S):

Was this topic helpful?