class_docstr: Represents unevaluated summation.
  
  Explanation
  ===========
  
  ``Sum`` represents a finite or infinite series, with the first argument
  being the general form of terms in the series, and the second argument
  being ``(dummy_variable, start, end)``, with ``dummy_variable`` taking
  all integer values from ``start`` through ``end``. In accordance with
  long-standing mathematical convention, the end term is included in the
  summation.
  
  Finite sums
  ===========
  
  For finite sums (and sums with symbolic limits assumed to be finite) we
  follow the summation convention described by Karr [1], especially
  definition 3 of section 1.4. The sum:
  
  .. math::
  
      \sum_{m \leq i < n} f(i)
  
  has *the obvious meaning* for `m < n`, namely:
  
  .. math::
  
      \sum_{m \leq i < n} f(i) = f(m) + f(m+1) + \ldots + f(n-2) + f(n-1)
  
  with the upper limit value `f(n)` excluded. The sum over an empty set is
  zero if and only if `m = n`:
  
  .. math::
  
      \sum_{m \leq i < n} f(i) = 0  \quad \mathrm{for} \quad  m = n
  
  Finally, for all other sums over empty sets we assume the following
  definition:
  
  .. math::
  
      \sum_{m \leq i < n} f(i) = - \sum_{n \leq i < m} f(i)  \quad \mathrm{for} \quad  m > n
  
  It is important to note that Karr defines all sums with the upper
  limit being exclusive. This is in contrast to the usual mathematical notation,
  but does not affect the summation convention. Indeed we have:
  
  .. math::
  
      \sum_{m \leq i < n} f(i) = \sum_{i = m}^{n - 1} f(i)
  
  where the difference in notation is intentional to emphasize the meaning,
  with limits typeset on the top being inclusive.
  
  Examples
  ========
  
  >>> from sympy.abc import i, k, m, n, x
  >>> from sympy import Sum, factorial, oo, IndexedBase, Function
  >>> Sum(k, (k, 1, m))
  Sum(k, (k, 1, m))
  >>> Sum(k, (k, 1, m)).doit()
  m**2/2 + m/2
  >>> Sum(k**2, (k, 1, m))
  Sum(k**2, (k, 1, m))
  >>> Sum(k**2, (k, 1, m)).doit()
  m**3/3 + m**2/2 + m/6
  >>> Sum(x**k, (k, 0, oo))
  Sum(x**k, (k, 0, oo))
  >>> Sum(x**k, (k, 0, oo)).doit()
  Piecewise((1/(1 - x), Abs(x) < 1), (Sum(x**k, (k, 0, oo)), True))
  >>> Sum(x**k/factorial(k), (k, 0, oo)).doit()
  exp(x)
  
  Here are examples to do summation with symbolic indices.  You
  can use either Function of IndexedBase classes:
  
  >>> f = Function('f')
  >>> Sum(f(n), (n, 0, 3)).doit()
  f(0) + f(1) + f(2) + f(3)
  >>> Sum(f(n), (n, 0, oo)).doit()
  Sum(f(n), (n, 0, oo))
  >>> f = IndexedBase('f')
  >>> Sum(f[n]**2, (n, 0, 3)).doit()
  f[0]**2 + f[1]**2 + f[2]**2 + f[3]**2
  
  An example showing that the symbolic result of a summation is still
  valid for seemingly nonsensical values of the limits. Then the Karr
  convention allows us to give a perfectly valid interpretation to
  those sums by interchanging the limits according to the above rules:
  
  >>> S = Sum(i, (i, 1, n)).doit()
  >>> S
  n**2/2 + n/2
  >>> S.subs(n, -4)
  6
  >>> Sum(i, (i, 1, -4)).doit()
  6
  >>> Sum(-i, (i, -3, 0)).doit()
  6
  
  An explicit example of the Karr summation convention:
  
  >>> S1 = Sum(i**2, (i, m, m+n-1)).doit()
  >>> S1
  m**2*n + m*n**2 - m*n + n**3/3 - n**2/2 + n/6
  >>> S2 = Sum(i**2, (i, m+n, m-1)).doit()
  >>> S2
  -m**2*n - m*n**2 + m*n - n**3/3 + n**2/2 - n/6
  >>> S1 + S2
  0
  >>> S3 = Sum(i, (i, m, m-1)).doit()
  >>> S3
  0
  
  See Also
  ========
  
  summation
  Product, sympy.concrete.products.product
  
  References
  ==========
  
  .. [1] Michael Karr, "Summation in Finite Terms", Journal of the ACM,
         Volume 28 Issue 2, April 1981, Pages 305-350
         https://dl.acm.org/doi/10.1145/322248.322255
  .. [2] https://en.wikipedia.org/wiki/Summation#Capital-sigma_notation
  .. [3] https://en.wikipedia.org/wiki/Empty_sum
class_docstr_tok: ["Represents","unevaluated","summation",".","Explanation","===========","``","Sum","``","represents","a","finite","or","infinite","series",",","with","the","first","argument","being","the","general","form","of","terms","in","the","series",",","and","the","second","argument","being","``","(","dummy_variable",",","start",",","end",")","``",",","with","``","dummy_variable","``","taking","all","integer","values","from","``","start","``","through","``","end","``",".","In","accordance","with","long-standing","mathematical","convention",",","the","end","term","is","included","in","the","summation",".","Finite","sums","===========","For","finite","sums","(","and","sums","with","symbolic","limits","assumed","to","be","finite",")","we","follow","the","summation","convention","described","by","Karr","[","1","]",",","especially","definition","3","of","section","1.4",".","The","sum",":","..","math",":",":","\\sum_","{","m","\\leq","i","<","n","}","f","(","i",")","has","*","the","obvious","meaning","*","for","`","m","<","n","`",",","namely",":","..","math",":",":","\\sum_","{","m","\\leq","i","<","n","}","f","(","i",")","=","f","(","m",")","+","f","(","m+1",")","+","\\ldots","+","f","(","n-2",")","+","f","(","n-1",")","with","the","upper","limit","value","`","f","(","n",")","`","excluded",".","The","sum","over","an","empty","set","is","zero","if","and","only","if","`","m","=","n","`",":","..","math",":",":","\\sum_","{","m","\\leq","i","<","n","}","f","(","i",")","=","0","\\quad","\\mathrm","{","for","}","\\quad","m","=","n","Finally",",","for","all","other","sums","over","empty","sets","we","assume","the","following","definition",":","..","math",":",":","\\sum_","{","m","\\leq","i","<","n","}","f","(","i",")","=","-","\\sum_","{","n","\\leq","i","<","m","}","f","(","i",")","\\quad","\\mathrm","{","for","}","\\quad","m",">","n","It","is","important","to","note","that","Karr","defines","all","sums","with","the","upper","limit","being","exclusive",".","This","is","in","contrast","to","the","usual","mathematical","notation",",","but","does","not","affect","the","summation","convention",".","Indeed","we","have",":","..","math",":",":","\\sum_","{","m","\\leq","i","<","n","}","f","(","i",")","=","\\sum_","{","i","=","m","}","^","{","n","-","1","}","f","(","i",")","where","the","difference","in","notation","is","intentional","to","emphasize","the","meaning",",","with","limits","typeset","on","the","top","being","inclusive",".","Examples","========",">",">",">","from","sympy.abc","import","i",",","k",",","m",",","n",",","x",">",">",">","from","sympy","import","Sum",",","factorial",",","oo",",","IndexedBase",",","Function",">",">",">","Sum","(","k",",","(","k",",","1",",","m",")",")","Sum","(","k",",","(","k",",","1",",","m",")",")",">",">",">","Sum","(","k",",","(","k",",","1",",","m",")",")",".doit","(",")","m","*","*","2\/2","+","m\/2",">",">",">","Sum","(","k","*","*","2",",","(","k",",","1",",","m",")",")","Sum","(","k","*","*","2",",","(","k",",","1",",","m",")",")",">",">",">","Sum","(","k","*","*","2",",","(","k",",","1",",","m",")",")",".doit","(",")","m","*","*","3\/3","+","m","*","*","2\/2","+","m\/6",">",">",">","Sum","(","x","*","*","k",",","(","k",",","0",",","oo",")",")","Sum","(","x","*","*","k",",","(","k",",","0",",","oo",")",")",">",">",">","Sum","(","x","*","*","k",",","(","k",",","0",",","oo",")",")",".doit","(",")","Piecewise","(","(","1\/","(","1","-","x",")",",","Abs","(","x",")","<","1",")",",","(","Sum","(","x","*","*","k",",","(","k",",","0",",","oo",")",")",",","True",")",")",">",">",">","Sum","(","x","*","*","k\/factorial","(","k",")",",","(","k",",","0",",","oo",")",")",".doit","(",")","exp","(","x",")","Here","are","examples","to","do","summation","with","symbolic","indices",".","You","can","use","either","Function","of","IndexedBase","classes",":",">",">",">","f","=","Function","(","'","f","'",")",">",">",">","Sum","(","f","(","n",")",",","(","n",",","0",",","3",")",")",".doit","(",")","f","(","0",")","+","f","(","1",")","+","f","(","2",")","+","f","(","3",")",">",">",">","Sum","(","f","(","n",")",",","(","n",",","0",",","oo",")",")",".doit","(",")","Sum","(","f","(","n",")",",","(","n",",","0",",","oo",")",")",">",">",">","f","=","IndexedBase","(","'","f","'",")",">",">",">","Sum","(","f","[","n","]","*","*","2",",","(","n",",","0",",","3",")",")",".doit","(",")","f","[","0","]","*","*","2","+","f","[","1","]","*","*","2","+","f","[","2","]","*","*","2","+","f","[","3","]","*","*","2","An","example","showing","that","the","symbolic","result","of","a","summation","is","still","valid","for","seemingly","nonsensical","values","of","the","limits",".","Then","the","Karr","convention","allows","us","to","give","a","perfectly","valid","interpretation","to","those","sums","by","interchanging","the","limits","according","to","the","above","rules",":",">",">",">","S","=","Sum","(","i",",","(","i",",","1",",","n",")",")",".doit","(",")",">",">",">","S","n","*","*","2\/2","+","n\/2",">",">",">","S.subs","(","n",",","-4",")","6",">",">",">","Sum","(","i",",","(","i",",","1",",","-4",")",")",".doit","(",")","6",">",">",">","Sum","(","-i",",","(","i",",","-3",",","0",")",")",".doit","(",")","6","An","explicit","example","of","the","Karr","summation","convention",":",">",">",">","S1","=","Sum","(","i","*","*","2",",","(","i",",","m",",","m+n-1",")",")",".doit","(",")",">",">",">","S1","m","*","*","2","*","n","+","m","*","n","*","*","2","-","m","*","n","+","n","*","*","3\/3","-","n","*","*","2\/2","+","n\/6",">",">",">","S2","=","Sum","(","i","*","*","2",",","(","i",",","m+n",",","m-1",")",")",".doit","(",")",">",">",">","S2","-m","*","*","2","*","n","-","m","*","n","*","*","2","+","m","*","n","-","n","*","*","3\/3","+","n","*","*","2\/2","-","n\/6",">",">",">","S1","+","S2","0",">",">",">","S3","=","Sum","(","i",",","(","i",",","m",",","m-1",")",")",".doit","(",")",">",">",">","S3","0","See","Also","========","summation","Product",",","sympy.concrete.products.product","References","==========","..","[","1","]","Michael","Karr",",","``","Summation","in","Finite","Terms","''",",","Journal","of","the","ACM",",","Volume","28","Issue","2",",","April","1981",",","Pages","305-350","https",":","\/\/dl.acm.org\/doi\/10.1145\/322248.322255","..","[","2","]","https",":","\/\/en.wikipedia.org\/wiki\/Summation","#","Capital-sigma_notation","..","[","3","]","https",":","\/\/en.wikipedia.org\/wiki\/Empty_sum"]
code: def __new__(cls, function, *symbols, **assumptions):
      obj = AddWithLimits.__new__(
          cls, function, *symbols, **assumptions
      )
      if not hasattr(obj, "limits"):
          return obj
      if any(len(l) != 3 or None in l for l in obj.limits):
          raise ValueError(
              "Sum requires values for lower and upper bounds."
          )
  
      return obj
  
imports: from typing import Tuple
  from sympy.calculus.singularities import is_decreasing
  from sympy.calculus.accumulationbounds import AccumulationBounds
  from .expr_with_intlimits import ExprWithIntLimits
  from .expr_with_limits import AddWithLimits
  from .gosper import gosper_sum
  from sympy.core.expr import Expr
  from sympy.core.add import Add
  from sympy.core.containers import Tuple
  from sympy.core.function import Derivative, expand
  from sympy.core.mul import Mul
  from sympy.core.numbers import Float, _illegal
  from sympy.core.relational import Eq
  from sympy.core.singleton import S
  from sympy.core.sorting import ordered
  from sympy.core.symbol import Dummy, Wild, Symbol, symbols
  from sympy.functions.combinatorial.factorials import factorial
  from sympy.functions.combinatorial.numbers import bernoulli, harmonic
  from sympy.functions.elementary.exponential import exp, log
  from sympy.functions.elementary.piecewise import Piecewise
  from sympy.functions.elementary.trigonometric import cot, csc
  from sympy.functions.special.hyper import hyper
  from sympy.functions.special.tensor_functions import KroneckerDelta
  from sympy.functions.special.zeta_functions import zeta
  from sympy.integrals.integrals import Integral
  from sympy.logic.boolalg import And
  from sympy.polys.partfrac import apart
  from sympy.polys.polyerrors import PolynomialError, PolificationFailed
  from sympy.polys.polytools import parallel_poly_from_expr, Poly, factor
  from sympy.polys.rationaltools import together
  from sympy.series.limitseq import limit_seq
  from sympy.series.order import O
  from sympy.series.residues import residue
  from sympy.sets.sets import FiniteSet, Interval
  from sympy.utilities.iterables import sift
  import itertools
label_desc: Use image node_id 1 for calling the Sum obj's underlying member method code with example usage: obj.__new__(cls, function) and returns: obj, obj