Discrete summation: sum

### 5.20.3 Discrete summation: sum

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.

#### Examples.

- Input:
  sum(1,k,-2,n)
  Output:

  n+1+2

- Input:
  normal(sum(2*k-1,k,1,n))
  Output:

  n2

- Input:
  sum(1/(n^2),n,1,10)
  Output:

  1968329
  1270080

- Input:
  sum(1/(n^2),n,1,+(infinity))
  Output:

  1
  6
  | π 2

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

  27
  110

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

  1
  4

  This result comes from the decomposition of 1/(n^3-n) (see Section 5.32.9).
  Input:
  partfrac(1/(n^3-n))
  Output:

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

  Hence:
  ∑n=2N −1/n=−∑n=1N−1 1/n+1=−1/2−∑n=2N−2 1/n+1−1/N
  1/2∑n=2N 1/n−1=1/2(∑n=0N−2 1/n+1)=1/2(1+1/2+∑n=2N−21/n+1)
  1/2∑n=2N 1/n+1=1/2(∑n=2N−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.

To find a discrete antiderivative:

- sum takes two arguments:
  - expr, an expression.
  - k, the name of the variable.
- sum(expr,x) returns a discrete antiderivative.

#### Example.

Input:

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

Output:

− |
1
x