# symsum

## Description

example

F = symsum(f,k,a,b) returns the 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.

## Examples

collapse all

Find the following sums of series.

$\begin{array}{l}\mathrm{F1}=\sum _{\mathit{k}=0}^{10}{\mathit{k}}^{2}\\ \mathrm{F2}=\sum _{\mathit{k}=1}^{\infty }\frac{1}{{\mathit{k}}^{2}}\\ \mathrm{F3}=\sum _{\mathit{k}=1}^{\infty }\frac{{\mathit{x}}^{\mathit{k}}}{\mathit{k}!}\end{array}$

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

$\frac{{\pi }^{2}}{6}$

F3 = symsum(x^k/factorial(k),k,1,Inf)
F3 = ${\mathrm{e}}^{x}-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 =

$\frac{{\pi }^{2}}{6}$

F3 = symsum(x^k/factorial(k),k,[1 Inf])
F3 = ${\mathrm{e}}^{x}-1$

Find the following indefinite sums of series (antidifferences).

$\begin{array}{l}\mathrm{F1}=\sum _{\mathit{k}}\mathit{k}\\ \mathrm{F2}=\sum _{\mathit{k}}{2}^{\mathit{k}}\\ \mathrm{F3}=\sum _{\mathit{k}}\frac{1}{{\mathit{k}}^{2}}\end{array}$

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

$\frac{{k}^{2}}{2}-\frac{k}{2}$

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

Find the summation of the polynomial series $\mathit{F}\left(\mathit{x}\right)={\sum }_{\mathit{k}=1}^{8}{\mathit{a}}_{\mathit{k}}{\mathit{x}}^{\mathit{k}}$.

If you know that the coefficient ${a}_{k}$ is a function of some integer variable $k$, use the symsum function. For example, find the sum $\mathit{F}\left(\mathit{x}\right)={\sum }_{\mathit{k}=1}^{8}\mathit{k}{\mathit{x}}^{\mathit{k}}$.

syms x k
F(x) = symsum(k*x^k,k,1,8)
F(x) = $8 {x}^{8}+7 {x}^{7}+6 {x}^{6}+5 {x}^{5}+4 {x}^{4}+3 {x}^{3}+2 {x}^{2}+x$

Calculate the summation series for $x=2$.

F(2)
ans = $3586$

Alternatively, if you know that the coefficients ${a}_{k}$ are a vector of values, you can use the sum function. For example, the coefficients are ${\mathit{a}}_{1},\dots ,{\mathit{a}}_{8}=1,\dots ,8$. Declare the term ${x}^{k}$ 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) = $8 {x}^{8}+7 {x}^{7}+6 {x}^{6}+5 {x}^{5}+4 {x}^{4}+3 {x}^{3}+2 {x}^{2}+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).

collapse all

### Definite Sum

The definite sum of a series is defined as

$\sum _{k=a}^{b}{x}_{k}={x}_{a}+{x}_{a+1}+\dots +{x}_{b}.$

### Indefinite Sum

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

$F\left(x\right)=\sum _{x}f\left(x\right),$

such that

$F\left(x+1\right)-F\left(x\right)=f\left(x\right).$