Main Content

symsum

Symbolic sum of series

Description

F = symsum(f,k,a,b) returns the symbolic definite sum of the series f with respect to the summation index k from the lower bound a to the upper bound b. If you do not specify k, symsum uses the variable determined by symvar as the summation index. If f is a constant, then the default variable is x.

symsum(f,k,[a b]) or symsum(f,k,[a; b]) is equivalent to symsum(f,k,a,b).

example

F = symsum(f,k) returns the indefinite sum (antidifference) of the series f with respect to the summation index k. The f argument defines the series such that the indefinite sum F satisfies the relation F(k+1) - F(k) = f(k). If you do not specify k, symsum uses the variable determined by symvar as the summation index. If f is a constant, then the default variable is x.

example

Examples

collapse all

Find the sum of the integer numbers 1+2+3+...+n=k=1nk.

syms k n
F1 = symsum(k,k,1,n)
F1 = 

nn+12

Find the sum of the square numbers 12+22+32+...+n2=k=1nk2.

syms k n
F2 = symsum(k^2,k,1,n)
F2 = 

n2n+1n+16

Find the sum of the cubic numbers 13+23+33+...+n3=k=1nk3.

syms k n
F3 = symsum(k^3,k,1,n)
F3 = 

n2n+124

Find the following sums of series.

F1=k=010k2F2=k=11k2F3=k=1xkk!

syms k x
F1 = symsum(k^2,k,0,10)
F1 = 385
F2 = symsum(1/k^2,k,1,Inf)
F2 = 

π26

F3 = symsum(x^k/factorial(k),k,1,Inf)
F3 = ex-1

Alternatively, you can specify summation bounds as a row or column vector.

F1 = symsum(k^2,k,[0 10])
F1 = 385
F2 = symsum(1/k^2,k,[1;Inf])
F2 = 

π26

F3 = symsum(x^k/factorial(k),k,[1 Inf])
F3 = ex-1

Find the following indefinite sums of series (antidifferences).

F1=kkF2=k2kF3=k1k2

syms k
F1 = symsum(k,k)
F1 = 

k22-k2

F2 = symsum(2^k,k)
F2 = 2k
F3 = symsum(1/k^2,k)
F3 = 

{-ψpsi(k) if  0<kψpsi(1-k) if  k0

Find the summation of the polynomial series F(x)=k=18akxk.

If you know that the coefficient ak is a function of some integer variable k, use the symsum function. For example, find the sum F(x)=k=18kxk.

syms x k
F(x) = symsum(k*x^k,k,1,8)
F(x) = 8x8+7x7+6x6+5x5+4x4+3x3+2x2+x

Calculate the summation series for x=2.

F(2)
ans = 3586

Alternatively, if you know that the coefficients ak are a vector of values, you can use the sum function. For example, the coefficients are a1,,a8=1,,8. Declare the term xk as a vector by using subs(x^k,k,1:8).

a = 1:8;
G(x) = sum(a.*subs(x^k,k,1:8))
G(x) = 8x8+7x7+6x6+5x5+4x4+3x3+2x2+x

Calculate the summation series for x=2.

G(2)
ans = 3586

Input Arguments

collapse all

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

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.

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

Upper bound of the 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 a series is defined as

k=abfk=fa+fa+1++fb.

Indefinite Sum

The indefinite sum (antidifference) of a series is defined as

F(x)=xf(x),

such that

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

Version History

Introduced before R2006a