Module ImportFrom alias alias ImportFrom alias alias alias alias ImportFrom alias ImportFrom alias alias ImportFrom alias alias alias ImportFrom alias FunctionDef arguments args NameParam NameParam defaults body Expr Str If UnaryOpNot AttributeLoad NameLoad attr body Return NameLoad Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore ListLoad Call NameLoad Num For NameStore AttributeLoad NameLoad attr body If BoolOpAnd CompareIs NameLoad NameLoad AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad body Assign NameStore NameLoad Assign NameStore AttributeLoad NameLoad attr Assign NameStore ListComp BinOpMult SubscriptLoad NameLoad Index Num NameLoad comprehension NameStore AttributeLoad NameLoad attr orelse Assign NameStore ListComp BinOpMult NameLoad NameLoad comprehension NameStore NameLoad Return Call NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str If UnaryOpNot Call NameLoad NameLoad NameLoad body Return TupleLoad NameLoad NameLoad If Call NameLoad NameLoad NameLoad body Return TupleLoad NameLoad Call NameLoad Num If UnaryOpNot AttributeLoad NameLoad attr body Raise Call NameLoad Str Assign NameStore NameLoad Assign NameStore ListLoad For NameStore AttributeLoad NameLoad attr body If BoolOpAnd CompareIs NameLoad NameLoad Call NameLoad NameLoad NameLoad body Assign NameStore NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad Return TupleLoad NameLoad Call AttributeLoad NameLoad attr NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str If Call AttributeLoad NameLoad attr NameLoad body If Call NameLoad NameLoad NameLoad body Return NameLoad If BoolOpOr AttributeLoad NameLoad attr AttributeLoad NameLoad attr body For NameStore AttributeLoad NameLoad attr body If Call NameLoad NameLoad NameLoad body Return NameLoad Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str If BoolOpAnd Call NameLoad NameLoad NameLoad Call AttributeLoad NameLoad attr NameLoad body Assign NameStore Call AttributeLoad BinOpSub SubscriptLoad AttributeLoad NameLoad attr Index Num SubscriptLoad AttributeLoad NameLoad attr Index Num attr NameLoad If NameLoad body Return CompareEq Call AttributeLoad NameLoad attr Num Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str ImportFrom alias If AttributeLoad NameLoad attr body Return Call AttributeLoad NameLoad attr Call NameLoad Call NameLoad NameLoad AttributeLoad NameLoad attr If UnaryOpNot AttributeLoad NameLoad attr body Return NameLoad Assign NameStore ListLoad Assign NameStore ListLoad For NameStore AttributeLoad NameLoad attr body If Call NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr BinOpSub SubscriptLoad AttributeLoad NameLoad attr Index Num SubscriptLoad AttributeLoad NameLoad attr Index Num orelse Expr Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot NameLoad body Return NameLoad Assign NameStore Call NameLoad NameLoad keyword NameLoad If CompareEq Call NameLoad NameLoad Num body Return AttributeLoad NameLoad attr orelse If CompareEq Call NameLoad NameLoad Num body For NameStore Call AttributeLoad SubscriptLoad NameLoad Index Num attr body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad SubscriptLoad SubscriptLoad NameLoad Index Num Index NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareNotEq NameLoad NameLoad body Return Call NameLoad NameLoad Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str ImportFrom alias If Call NameLoad NameLoad NameLoad body TryExcept body Assign NameStore Call NameLoad BinOpSub SubscriptLoad AttributeLoad NameLoad attr Index Num SubscriptLoad AttributeLoad NameLoad attr Index Num keyword NameLoad If BoolOpAnd NameLoad CompareEq Call NameLoad NameLoad Num body Return Call NameLoad ListComp Call NameLoad TupleLoad NameLoad NameLoad comprehension TupleStore NameStore NameStore Call AttributeLoad SubscriptLoad NameLoad Index Num attr handlers ExceptHandler type NameLoad body Pass Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str ImportFrom alias If CompareEq CompareLt BinOpSub SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Num NameLoad body Return AttributeLoad NameLoad attr If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Return Call NameLoad NameLoad NameLoad If AttributeLoad NameLoad attr body Assign NameStore NameLoad Assign NameStore ListLoad For NameStore Call NameLoad AttributeLoad NameLoad attr keyword NameLoad body If BoolOpAnd CompareIs NameLoad NameLoad Call NameLoad NameLoad SubscriptLoad NameLoad Index Num body Assign NameStore NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad Str keyword NameLoad If BoolOpAnd Call NameLoad SubscriptLoad NameLoad Index Num NameLoad Call NameLoad SubscriptLoad NameLoad Index Num NameLoad body Assign NameStore BinOpAdd Call NameLoad NameLoad NameLoad Call NameLoad ListComp BinOpMult BinOpMult Call NameLoad NameLoad TupleLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num BinOpSub NameLoad Num Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num NameLoad Call NameLoad NameLoad TupleLoad SubscriptLoad NameLoad Index Num BinOpAdd NameLoad Num SubscriptLoad NameLoad Index Num comprehension NameStore Call NameLoad Call NameLoad SubscriptLoad NameLoad Index Num Call NameLoad BinOpAdd SubscriptLoad NameLoad Index Num Num orelse Assign NameStore BinOpAdd Call NameLoad NameLoad NameLoad Call NameLoad BinOpMult BinOpMult Call NameLoad NameLoad TupleLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num BinOpSub NameLoad Num Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num NameLoad Call NameLoad NameLoad TupleLoad SubscriptLoad NameLoad Index Num BinOpAdd NameLoad Num SubscriptLoad NameLoad Index Num TupleLoad NameLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num keyword Call NameLoad NameLoad SubscriptLoad NameLoad Index Num Return Call NameLoad NameLoad Assign TupleStore NameStore NameStore Call NameLoad NameLoad SubscriptLoad NameLoad Index Num If UnaryOpNot NameLoad body Assign NameStore Call NameLoad NameLoad SubscriptLoad NameLoad Index Num If CompareNotEq NameLoad NameLoad body ImportFrom alias TryExcept body Return Call NameLoad Call NameLoad NameLoad NameLoad handlers ExceptHandler type NameLoad body Return Call NameLoad NameLoad NameLoad Return Call NameLoad NameLoad NameLoad ImportFrom alias Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Num BinOpSub SubscriptLoad NameLoad Index Num Num Return BinOpAdd Call NameLoad BinOpMult Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Call NameLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num BinOpMult AttributeLoad NameLoad attr Call NameLoad Call NameLoad SubscriptLoad NameLoad Index Num BinOpSub SubscriptLoad NameLoad Index Num Num decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str ImportFrom alias ImportFrom alias If CompareEq CompareLt BinOpSub SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Num NameLoad body Return AttributeLoad NameLoad attr If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Return Call NameLoad NameLoad NameLoad Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore Call NameLoad NameLoad NameLoad If AttributeLoad NameLoad attr body Return Call NameLoad Call AttributeLoad NameLoad attr ListComp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore AttributeLoad NameLoad attr Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad If UnaryOpNot NameLoad body Return Call NameLoad NameLoad NameLoad Assign NameStore Call NameLoad BinOpSub SubscriptLoad AttributeLoad NameLoad attr Index Num SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad If CompareEq Call NameLoad NameLoad Num body Return AttributeLoad NameLoad attr orelse If CompareNotEq Call NameLoad NameLoad Num body Return Call NameLoad NameLoad NameLoad Assign NameStore SubscriptLoad NameLoad Index Num If NameLoad body Return Call AttributeLoad NameLoad attr NameLoad NameLoad Return Call NameLoad TupleLoad Call AttributeLoad NameLoad attr NameLoad NameLoad Call AttributeLoad Call NameLoad SubscriptLoad NameLoad Slice Num Num attr NameLoad TupleLoad AttributeLoad NameLoad attr NameLoad decorator_list NameLoad
N/A __future__ print_function division sympy.core Add Mul S Dummy sympy.core.cache cacheit sympy.core.compatibility default_sort_key range sympy.functions KroneckerDelta Piecewise piecewise_fold sympy.sets Interval _expand_delta N/A N/A expr index N/A N/A N/A 
    Expand the first Add containing a simple KroneckerDelta.
     N/A N/A N/A expr is_Mul N/A N/A expr N/A delta None N/A func Add N/A terms N/A N/A S 1 N/A h N/A expr args N/A N/A N/A N/A delta None N/A h is_Add N/A _has_simple_delta h index N/A N/A delta True N/A func N/A h func N/A terms N/A N/A N/A terms N/A 0 t N/A t N/A h args N/A N/A terms N/A N/A t h N/A t terms N/A N/A func terms N/A cacheit _extract_delta N/A N/A expr index N/A N/A N/A 
    Extract a simple KroneckerDelta from the expression.

    Returns the tuple ``(delta, newexpr)`` where:

      - ``delta`` is a simple KroneckerDelta expression if one was found,
        or ``None`` if no simple KroneckerDelta expression was found.

      - ``newexpr`` is a Mul containing the remaining terms; ``expr`` is
        returned unchanged if no simple KroneckerDelta expression was found.

    Examples
    ========

    >>> from sympy import KroneckerDelta
    >>> from sympy.concrete.delta import _extract_delta
    >>> from sympy.abc import x, y, i, j, k
    >>> _extract_delta(4*x*y*KroneckerDelta(i, j), i)
    (KroneckerDelta(i, j), 4*x*y)
    >>> _extract_delta(4*x*y*KroneckerDelta(i, j), k)
    (None, 4*x*y*KroneckerDelta(i, j))

    See Also
    ========

    sympy.functions.special.tensor_functions.KroneckerDelta
    deltaproduct
    deltasummation
     N/A N/A N/A _has_simple_delta expr index N/A N/A N/A None expr N/A N/A isinstance expr KroneckerDelta N/A N/A N/A expr N/A S 1 N/A N/A N/A expr is_Mul N/A N/A N/A ValueError Incorrect expr N/A delta None N/A terms N/A N/A arg N/A expr args N/A N/A N/A N/A delta None N/A _is_simple_delta arg index N/A N/A delta arg N/A N/A N/A N/A terms append arg N/A N/A delta N/A N/A expr func terms N/A cacheit _has_simple_delta N/A N/A expr index N/A N/A N/A 
    Returns True if ``expr`` is an expression that contains a KroneckerDelta
    that is simple in the index ``index``, meaning that this KroneckerDelta
    is nonzero for a single value of the index ``index``.
     N/A N/A N/A expr has KroneckerDelta N/A N/A N/A _is_simple_delta expr index N/A N/A True N/A N/A N/A expr is_Add N/A expr is_Mul N/A N/A arg N/A expr args N/A N/A N/A _has_simple_delta arg index N/A N/A True N/A False N/A cacheit _is_simple_delta N/A N/A delta index N/A N/A N/A 
    Returns True if ``delta`` is a KroneckerDelta and is nonzero for a single
    value of the index ``index``.
     N/A N/A N/A isinstance delta KroneckerDelta N/A N/A delta has index N/A N/A p N/A N/A N/A N/A N/A delta args N/A 0 N/A N/A delta args N/A 1 as_poly index N/A p N/A N/A N/A N/A N/A p degree 1 N/A False N/A cacheit _remove_multiple_delta N/A N/A expr N/A N/A N/A 
    Evaluate products of KroneckerDelta's.
     sympy.solvers solve N/A N/A expr is_Add N/A N/A N/A N/A expr func N/A list N/A map _remove_multiple_delta N/A expr args N/A N/A N/A expr is_Mul N/A N/A expr N/A eqs N/A N/A newargs N/A N/A arg N/A expr args N/A N/A N/A isinstance arg KroneckerDelta N/A N/A N/A N/A eqs append N/A N/A N/A arg args N/A 0 N/A N/A arg args N/A 1 N/A N/A N/A N/A newargs append arg N/A N/A eqs N/A N/A expr N/A solns N/A solve eqs dict True N/A N/A N/A len solns 0 N/A N/A N/A S Zero N/A N/A N/A N/A len solns 1 N/A N/A key N/A N/A N/A solns N/A 0 keys N/A N/A N/A N/A newargs append N/A KroneckerDelta key N/A N/A solns N/A 0 N/A key N/A expr2 N/A N/A expr func newargs N/A N/A expr expr2 N/A N/A N/A _remove_multiple_delta expr2 N/A expr N/A cacheit _simplify_delta N/A N/A expr N/A N/A N/A 
    Rewrite a KroneckerDelta's indices in its simplest form.
     sympy.solvers solve N/A N/A isinstance expr KroneckerDelta N/A N/A N/A N/A slns N/A solve N/A N/A N/A expr args N/A 0 N/A N/A expr args N/A 1 dict True N/A N/A slns N/A N/A len slns 1 N/A N/A N/A Mul N/A N/A KroneckerDelta N/A key value N/A N/A key value N/A N/A N/A slns N/A 0 items N/A N/A N/A NotImplementedError N/A N/A N/A expr N/A cacheit deltaproduct N/A N/A f limit N/A N/A N/A 
    Handle products containing a KroneckerDelta.

    See Also
    ========

    deltasummation
    sympy.functions.special.tensor_functions.KroneckerDelta
    sympy.concrete.products.product
     sympy.concrete.products product N/A N/A N/A N/A N/A limit N/A 2 N/A limit N/A 1 0 True N/A N/A N/A S One N/A N/A N/A N/A f has KroneckerDelta N/A N/A N/A product f limit N/A N/A f is_Add N/A N/A delta None N/A terms N/A N/A arg N/A sorted N/A f args key default_sort_key N/A N/A N/A N/A delta None N/A _has_simple_delta arg N/A limit N/A 0 N/A N/A delta arg N/A N/A N/A N/A terms append arg N/A newexpr N/A N/A f func terms N/A k N/A Dummy kprime integer True N/A N/A N/A isinstance N/A limit N/A 1 int N/A isinstance N/A limit N/A 2 int N/A N/A result N/A N/A deltaproduct newexpr limit N/A sum N/A N/A N/A N/A deltaproduct newexpr N/A N/A limit N/A 0 N/A limit N/A 1 N/A ik 1 N/A N/A delta subs N/A limit N/A 0 ik N/A deltaproduct newexpr N/A N/A limit N/A 0 N/A ik 1 N/A limit N/A 2 N/A ik N/A range N/A int N/A limit N/A 1 N/A int N/A N/A limit N/A 2 1 N/A N/A result N/A N/A deltaproduct newexpr limit N/A deltasummation N/A N/A N/A deltaproduct newexpr N/A N/A limit N/A 0 N/A limit N/A 1 N/A k 1 N/A N/A delta subs N/A limit N/A 0 k N/A deltaproduct newexpr N/A N/A limit N/A 0 N/A k 1 N/A limit N/A 2 N/A k N/A limit N/A 1 N/A limit N/A 2 no_piecewise N/A _has_simple_delta newexpr N/A limit N/A 0 N/A N/A _remove_multiple_delta result N/A N/A delta _ N/A _extract_delta f N/A limit N/A 0 N/A N/A delta N/A N/A g N/A _expand_delta f N/A limit N/A 0 N/A N/A f g N/A sympy factor N/A N/A N/A N/A factor N/A deltaproduct g limit N/A N/A N/A AssertionError N/A N/A N/A deltaproduct g limit N/A N/A product f limit sympy Eq N/A c N/A Eq N/A limit N/A 2 N/A N/A limit N/A 1 1 N/A N/A N/A _remove_multiple_delta N/A N/A N/A f subs N/A limit N/A 0 N/A limit N/A 1 N/A KroneckerDelta N/A limit N/A 2 N/A limit N/A 1 N/A N/A S One N/A _simplify_delta N/A KroneckerDelta N/A limit N/A 2 N/A N/A limit N/A 1 1 N/A cacheit deltasummation N/A N/A f limit no_piecewise N/A False N/A N/A 
    Handle summations containing a KroneckerDelta.

    The idea for summation is the following:

    - If we are dealing with a KroneckerDelta expression, i.e. KroneckerDelta(g(x), j),
      we try to simplify it.

      If we could simplify it, then we sum the resulting expression.
      We already know we can sum a simplified expression, because only
      simple KroneckerDelta expressions are involved.

      If we couldn't simplify it, there are two cases:

      1) The expression is a simple expression: we return the summation,
         taking care if we are dealing with a Derivative or with a proper
         KroneckerDelta.

      2) The expression is not simple (i.e. KroneckerDelta(cos(x))): we can do
         nothing at all.

    - If the expr is a multiplication expr having a KroneckerDelta term:

      First we expand it.

      If the expansion did work, then we try to sum the expansion.

      If not, we try to extract a simple KroneckerDelta term, then we have two
      cases:

      1) We have a simple KroneckerDelta term, so we return the summation.

      2) We didn't have a simple term, but we do have an expression with
         simplified KroneckerDelta terms, so we sum this expression.

    Examples
    ========

    >>> from sympy import oo, symbols
    >>> from sympy.abc import k
    >>> i, j = symbols('i, j', integer=True, finite=True)
    >>> from sympy.concrete.delta import deltasummation
    >>> from sympy import KroneckerDelta, Piecewise
    >>> deltasummation(KroneckerDelta(i, k), (k, -oo, oo))
    1
    >>> deltasummation(KroneckerDelta(i, k), (k, 0, oo))
    Piecewise((1, 0 <= i), (0, True))
    >>> deltasummation(KroneckerDelta(i, k), (k, 1, 3))
    Piecewise((1, And(1 <= i, i <= 3)), (0, True))
    >>> deltasummation(k*KroneckerDelta(i, j)*KroneckerDelta(j, k), (k, -oo, oo))
    j*KroneckerDelta(i, j)
    >>> deltasummation(j*KroneckerDelta(i, j), (j, -oo, oo))
    i
    >>> deltasummation(i*KroneckerDelta(i, j), (i, -oo, oo))
    j

    See Also
    ========

    deltaproduct
    sympy.functions.special.tensor_functions.KroneckerDelta
    sympy.concrete.sums.summation
     sympy.concrete.summations summation sympy.solvers solve N/A N/A N/A N/A N/A limit N/A 2 N/A limit N/A 1 0 True N/A N/A N/A S Zero N/A N/A N/A N/A f has KroneckerDelta N/A N/A N/A summation f limit N/A x N/A limit N/A 0 N/A g N/A _expand_delta f x N/A N/A g is_Add N/A N/A N/A piecewise_fold N/A N/A g func N/A N/A deltasummation h limit no_piecewise N/A h N/A g args N/A N/A delta expr N/A _extract_delta g x N/A N/A delta N/A N/A N/A summation f limit N/A solns N/A solve N/A N/A N/A delta args N/A 0 N/A N/A delta args N/A 1 x N/A N/A N/A len solns 0 N/A N/A N/A S Zero N/A N/A N/A N/A len solns 1 N/A N/A N/A Sum f limit N/A value N/A solns N/A 0 N/A no_piecewise N/A N/A N/A N/A expr subs x value N/A N/A Piecewise N/A N/A N/A expr subs x value N/A N/A N/A Interval N/A limit N/A 1 3 as_relational value N/A N/A S Zero True N/A cacheit