Function: sumformal
Section: polynomials
C-Name: sumformal
Prototype: GDn
Help: sumformal(f,{v}): formal sum of f with respect to v, or to the
 main variable of f if v is omitted.
Doc: \idx{formal sum} of the polynomial expression $f$ with respect to the
 main variable if $v$ is omitted, with respect to the variable $v$ otherwise;
 it is assumed that the base ring has characteristic zero. In other words,
 considering $f$ as a polynomial function in the variable $v$,
 returns $F$, a polynomial in $v$ vanishing at $0$, such that $F(b) - F(a)
 = sum_{v = a+1}^{b} f(v)$:
 \bprog
 ? sumformal(n)  \\ 1 + ... + n
 %1 = 1/2*n^2 + 1/2*n
 ? f(n) = n^3+n^2+1;
 ? F = sumformal(f(n))  \\ f(1) + ... + f(n)
 %3 = 1/4*n^4 + 5/6*n^3 + 3/4*n^2 + 7/6*n
 ? sum(n = 1, 2000, f(n)) == subst(F, n, 2000)
 %4 = 1
 ? sum(n = 1001, 2000, f(n)) == subst(F, n, 2000) - subst(F, n, 1000)
 %5 = 1
 ? sumformal(x^2 + x*y + y^2, y)
 %6 = y*x^2 + (1/2*y^2 + 1/2*y)*x + (1/3*y^3 + 1/2*y^2 + 1/6*y)
 ? x^2 * y + x * sumformal(y) + sumformal(y^2) == %
 %7 = 1
 @eprog
