### 13.3.3 Discrete summation

The sum command can evaluate sums, series, and find discrete antiderivatives. A discrete antiderivative of a sum ∑nf(n) is an expression G such that G|x=n+1−G|x=n=f(n), which means that ∑n=MNf(n)=G|x=N+1−G|M.

- To evaluate a sum or series, sum takes four arguments:
  - expr, an expression.
  - k, the name of the variable.
  - n0 and n1, integers (the bounds of the sum).
- sum(expr,k,n0,n1) returns the sum ∑k=n0n1expr.
- To find a discrete antiderivative, sum takes two arguments:
  - expr, an expression.
  - x, the name of the variable.
- sum(expr,x) returns a discrete antiderivative.

#### Examples

sum(1,k,-2,n)

n+1+2 |  |  |  |  |  |  |  |  |  |

normal(sum(2*k-1,k,1,n))

n2 |  |  |  |  |  |  |  |  |  |

sum(1/(n^2),n,1,10)

1968329
1270080

sum(1/(n^2),n,1,+(infinity))

1
6
| π 2

sum(1/(n^3-n),n,2,10)

27
110

sum(1/(n^3-n),n,2,+(infinity))

1
4

This result comes from the decomposition of 1/(n^3-n) (see Section 11.6.9).

partfrac(1/(n^3-n))

− |
1
n
| + |
1
2 | ⎛ ⎝ | n−1 | ⎞ ⎠
| + |
1
2 | ⎛ ⎝ | n+1 | ⎞ ⎠

Hence:

N
∑
n=2
| − |
1
n
=− |
N−1
∑
n=1
1
n+1
| =− |
1
2
| − |
N−2
∑
n=2
1
n+1
| − |
1
N
1
2
N
∑
n=2
1
n−1
= |
1
2
| ⎛ ⎜ ⎜ ⎝ |
N−2
∑
n=0
1
n+1
| )= |
1
2
| (1+ |
1
2
| + |
N−2
∑
n=2
1
n+1
| ⎞ ⎟ ⎟ ⎠
1
2
N
∑
n=2
1
n+1
= |
1
2
| ⎛ ⎜ ⎜ ⎝ |
N−2
∑
n=2
1
n+1
| + |
1
N
| + |
1
N+1
| ⎞ ⎟ ⎟ ⎠

After simplification by ∑n=2N−2, it remains:

− |
1
2
| + |
1
2
| ⎛ ⎜ ⎜ ⎝ | 1+ |
1
2
| ⎞ ⎟ ⎟ ⎠ | − |
1
N
| + |
1
2
| ⎛ ⎜ ⎜ ⎝ |
1
N
| + |
1
N+1
| ⎞ ⎟ ⎟ ⎠ | = |
1
4
| − |
1
2N(N+1)

Therefore:

- for N=10 the sum is equal to 1/4−1/220=27/110,
- for N=+∞ the sum is equal to 1/4 because 1/2N(N+1) approaches zero when N approaches infinity.

sum(1/(x*(x+1)),x)

− |
1
x