# Group project

## 165 days ago by liviabetti

2+2
 4 4
series?
  No object 'series' currently defined.  No object 'series' currently defined.
sum?
 File: /usr/local/sage-6.10/local/lib/python2.7/site-packages/sage/misc/functional.py Type: Definition: sum(expression, *args, **kwds) Docstring: Returns the symbolic sum \sum_{v = a}^b expression with respect to the variable v with endpoints a and b. INPUT: expression - a symbolic expression v - a variable or variable name a - lower endpoint of the sum b - upper endpoint of the sum algorithm - (default: 'maxima') one of 'maxima' - use Maxima (the default) 'maple' - (optional) use Maple 'mathematica' - (optional) use Mathematica 'giac' - (optional) use Giac EXAMPLES: sage: k, n = var('k,n') sage: sum(k, k, 1, n).factor() 1/2*(n + 1)*n  sage: sum(1/k^4, k, 1, oo) 1/90*pi^4  sage: sum(1/k^5, k, 1, oo) zeta(5)  Warning This function only works with symbolic expressions. To sum any other objects like list elements or function return values, please use python summation, see http://docs.python.org/library/functions.html#sum In particular, this does not work: sage: n = var('n') sage: list=[1,2,3,4,5] sage: sum(list[n],n,0,3) Traceback (click to the left of this block for traceback) ...  File: /usr/local/sage-6.10/local/lib/python2.7/site-packages/sage/misc/functional.py Type: Definition: sum(expression, *args, **kwds) Docstring: Returns the symbolic sum \sum_{v = a}^b expression with respect to the variable v with endpoints a and b. INPUT: expression - a symbolic expression v - a variable or variable name a - lower endpoint of the sum b - upper endpoint of the sum algorithm - (default: 'maxima') one of 'maxima' - use Maxima (the default) 'maple' - (optional) use Maple 'mathematica' - (optional) use Mathematica 'giac' - (optional) use Giac EXAMPLES: sage: k, n = var('k,n') sage: sum(k, k, 1, n).factor() 1/2*(n + 1)*n  sage: sum(1/k^4, k, 1, oo) 1/90*pi^4  sage: sum(1/k^5, k, 1, oo) zeta(5)  Warning This function only works with symbolic expressions. To sum any other objects like list elements or function return values, please use python summation, see http://docs.python.org/library/functions.html#sum In particular, this does not work: sage: n = var('n') sage: list=[1,2,3,4,5] sage: sum(list[n],n,0,3) Traceback (most recent call last): ... TypeError: unable to convert n to an integer  Use python sum() instead: sage: sum(list[n] for n in range(4)) 10  Also, only a limited number of functions are recognized in symbolic sums: sage: sum(valuation(n,2),n,1,5) Traceback (most recent call last): ... TypeError: unable to convert n to an integer  Again, use python sum(): sage: sum(valuation(n+1,2) for n in range(5)) 3  (now back to the Sage sum examples) A well known binomial identity: sage: sum(binomial(n,k), k, 0, n) 2^n  The binomial theorem: sage: x, y = var('x, y') sage: sum(binomial(n,k) * x^k * y^(n-k), k, 0, n) (x + y)^n  sage: sum(k * binomial(n, k), k, 1, n) 2^(n - 1)*n  sage: sum((-1)^k*binomial(n,k), k, 0, n) 0  sage: sum(2^(-k)/(k*(k+1)), k, 1, oo) -log(2) + 1  Another binomial identity (trac ticket #7952): sage: t,k,i = var('t,k,i') sage: sum(binomial(i+t,t),i,0,k) binomial(k + t + 1, t + 1)  Summing a hypergeometric term: sage: sum(binomial(n, k) * factorial(k) / factorial(n+1+k), k, 0, n) 1/2*sqrt(pi)/factorial(n + 1/2)  We check a well known identity: sage: bool(sum(k^3, k, 1, n) == sum(k, k, 1, n)^2) True  A geometric sum: sage: a, q = var('a, q') sage: sum(a*q^k, k, 0, n) (a*q^(n + 1) - a)/(q - 1)  The geometric series: sage: assume(abs(q) < 1) sage: sum(a*q^k, k, 0, oo) -a/(q - 1)  A divergent geometric series. Don’t forget to forget your assumptions: sage: forget() sage: assume(q > 1) sage: sum(a*q^k, k, 0, oo) Traceback (most recent call last): ... ValueError: Sum is divergent.  This summation only Mathematica can perform: sage: sum(1/(1+k^2), k, -oo, oo, algorithm = 'mathematica') # optional - mathematica pi*coth(pi)  Use Maple as a backend for summation: sage: sum(binomial(n,k)*x^k, k, 0, n, algorithm = 'maple') # optional - maple (x + 1)^n  Python ints should work as limits of summation (trac ticket #9393): sage: sum(x, x, 1r, 5r) 15  Note Sage can currently only understand a subset of the output of Maxima, Maple and Mathematica, so even if the chosen backend can perform the summation the result might not be convertable into a Sage expression.