### 2.18.2 Discrete summation: `sum`

`sum` takes two or four arguments :

- four arguments
  an expression, the name of the variable (for example `n`), and the bounds (for example `a` and `b`).
  `sum` returns the discrete sum of this expression with respect to the variable from a to b.
  Input :
  `sum(1,k,-2,n)`
  Output :
  `n+1+2`
  Input :
  `normal(sum(2*k-1,k,1,n))`
  Output :
  `n```^```2`
  Input :
  `sum(1/(n```^```2),n,1,10)`
  Output :
  `1968329/1270080`
  Input :
  `sum(1/(n```^```2),n,1,+(infinity))`
  Output :
  `pi```^```2/6`
  Input :
  `sum(1/(n```^```3-n),n,2,10)`
  Output :
  `27/110`
  Input :
  `sum(1/(n```^```3-n),n,1,+(infinity))`
  Output :
  `1/4`
  This result comes from the decomposition of `1/(n```^```3-n)`.
  Input :
  `partfrac(1/(n```^```3-n))`
  Output :
  `1/(2*(n+1))-1/n+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.
- two arguments
  an expression of one variable (for example f) and the name of this variable (for example x).
  `sum` returns the discrete antiderivative of this expression, i.e. an expression G such that G|x=n+1−G|x=n=f|x=n.
  Input :
  `sum(1/(x*(x+1)),x)`
  Output :
  `-1/x`