# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# symsum

## Syntax

• ``F = symsum(f,k,a,b)``
example
• ``F = symsum(f,k)``
example

## 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.

`$\begin{array}{l}S1=\sum _{k=0}^{10}{k}^{2}\\ S2=\sum _{k=1}^{\infty }\frac{1}{{k}^{2}}\\ S3=\sum _{k=1}^{\infty }\frac{{x}^{k}}{k!}\end{array}$`
```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=\sum _{k=1}^{10}\frac{1}{{k}^{2}}.$`

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.

## Input Arguments

collapse all

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

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 summation index, specified as a number, symbolic number, variable, expression, or function (including expressions and functions with infinities).

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

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

### Indefinite Sum

The indefinite sum 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).$`