Documentation

symsum

Syntax

Description

example

F = symsum(f,k,a,b) returns the sum of the series with terms that expression f specifies, which depend on symbolic variable k. The value of k ranges from a to b. If you do not specify the variable, symsum uses the variable that symvar determines. If f is a constant, then the default variable is x.

example

F = symsum(f,k) returns the indefinite sum F of the series with terms that expression f specifies, which depend on variable k. The f argument defines the series such that the indefinite sum F is given by F(k+1) - F(k) = f(k). If you do not specify the variable, symsum uses the variable that symvar determines. If f is a constant, then the default variable is x.

Examples

Find Sum of Series Specifying Bounds

Find the following sums of series.

S1=k=010k2S2=k=11k2S3=k=1xkk!

syms k x
S1 = symsum(k^2, k, 0, 10)
S2 = symsum(1/k^2, k, 1, Inf)
S3 = symsum(x^k/factorial(k), k, 0, Inf)
S1 =
385
S2 =
pi^2/6
S3 =
exp(x)

Alternatively, specify bounds as a row or column vector.

S1 = symsum(k^2, k, [0 10])
S2 = symsum(1/k^2, k, [1; Inf])
S3 = symsum(x^k/factorial(k), k, [0 Inf])
S1 =
385
S2 =
pi^2/6
S3 =
exp(x)

Find Indefinite Sum of Series

Find the indefinite sum of the series specified by the symbolic expressions k and k^2.

syms k
symsum(k, k)
symsum(1/k^2, k)
ans =
k^2/2 - k/2

ans =
-psi(1, k)

Difference between symsum and sum

The sum function finds the sum of elements of symbolic vectors and matrices, similar to the MATLAB® sum function.

Consider the definite sum

S=k=1101k2.

Contrast symsum and sum by summing this definite sum using both functions.

syms k
S_sum = sum(subs(1/k^2, k, 1:10))
S_symsum = symsum(1/k^2, k, 1, 10)
S_sum =
1968329/1270080
S_symsum =
1968329/1270080

For details on sum, see the information on the MATLAB sum page.

Related Examples

Input Arguments

collapse all

f — Expression defining terms of seriessymbolic expression | symbolic function | symbolic vector | symbolic matrix | symbolic number

Expression defining terms of series, specified as a symbolic expression, function, or a vector or matrix of symbolic expressions, functions, or constants.

k — Summation indexsymbolic variable

Summation index, specified as a symbolic variable. If you do not specify this variable, symsum uses the default variable determined by symvar(expr,1). If f is a constant, then the default variable is x.

a — Lower bound of summation indexnumber | symbolic number | symbolic variable | symbolic expression | symbolic function

Lower bound of summation index, specified as a number, symbolic number, variable, expression, or function (including expressions and functions with infinities).

b — Upper bound of summation indexnumber | symbolic number | symbolic variable | symbolic expression | symbolic function

Upper bound of summation index, specified as a number, symbolic number, variable, expression, or function (including expressions and functions with infinities).

More About

collapse all

Definite Sum

The definite sum of series is defined as

k=abxk=xa+xa+1++xb.

Indefinite Sum

The indefinite sum of a series is defined as

F(x)=xf(x),

such that

F(x+1)F(x)=f(x).

See Also

| | | | |

Introduced before R2006a

Was this topic helpful?