(self, old, new)
return self.func(func, *limits)
Perform substitutions over non-dummy variables
        of an expression with limits.  Also, can be used
        to specify point-evaluation of an abstract antiderivative.

        Examples
        ========

        >>> from sympy import Sum, oo
        >>> from sympy.abc import s,n
        >>> Sum(1/n**s, (n, 1, oo)).subs(s, 2)
        Sum(n**(-2), (n, 1, oo))

        >>> from sympy import Integral
        >>> from sympy.abc import x,a
        >>> Integral(a*x**2,x).subs(x,4)
        Integral(a*x**2, (x, 4))

        See Also
        ========

        variables : Lists the integration variables
        transform : Perform mapping on the dummy variable for intgrals
        change_index : Perform mapping on the sum and product dummy variables
Perform substitutions over non-dummy variables
        of an expression with limits.  Also, can be used
        to specify point-evaluation of an abstract antiderivative.
Perform substitutions over non - dummy variables of an expression with limits . Also can be used to specify point - evaluation of an abstract antiderivative .
def _eval_subs(self, old, new):
        """
        Perform substitutions over non-dummy variables
        of an expression with limits.  Also, can be used
        to specify point-evaluation of an abstract antiderivative.

        Examples
        ========

        >>> from sympy import Sum, oo
        >>> from sympy.abc import s,n
        >>> Sum(1/n**s, (n, 1, oo)).subs(s, 2)
        Sum(n**(-2), (n, 1, oo))

        >>> from sympy import Integral
        >>> from sympy.abc import x,a
        >>> Integral(a*x**2,x).subs(x,4)
        Integral(a*x**2, (x, 4))

        See Also
        ========

        variables : Lists the integration variables
        transform : Perform mapping on the dummy variable for intgrals
        change_index : Perform mapping on the sum and product dummy variables

        """
        func, limits = self.function, list(self.limits)

        # If one of the expressions we are replacing is used as a func index
        # one of two things happens.
        #   - the old variable first appears as a free variable
        #     so we perform all free substitutions before it becomes
        #     a func index.
        #   - the old variable first appears as a func index, in
        #     which case we ignore.  See change_index.

        # Reorder limits to match standard mathematical practice for scoping
        limits.reverse()

        if not isinstance(old, C.Symbol) or \
                old.free_symbols.intersection(self.free_symbols):
            sub_into_func = True
            for i, xab in enumerate(limits):
                if 1 == len(xab) and old == xab[0]:
                    xab = (old, old)
                limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
                if len(xab[0].free_symbols.intersection(old.free_symbols)) != 0:
                    sub_into_func = False
                    break
            if isinstance(old,C.AppliedUndef) or isinstance(old,C.UndefinedFunction):
                sy2 = set(self.variables).intersection(set(new.atoms(Symbol)))
                sy1 = set(self.variables).intersection(set(old.args))
                if not sy2.issubset(sy1):
                    raise ValueError(
                        "substitution can not create dummy dependencies")
                sub_into_func = True
            if sub_into_func:
                func = func.subs(old, new)
        else:
            # old is a Symbol and a dummy variable of some limit
            for i, xab in enumerate(limits):
                if len(xab) == 3:
                    limits[i] = Tuple(xab[0], *[l._subs(old, new) for l in xab[1:]])
                    if old == xab[0]:
                        break
        # simplify redundant limits (x, x)  to (x, )
        for i, xab in enumerate(limits):
            if len(xab) == 2 and (xab[0] - xab[1]).is_zero:
                limits[i] = Tuple(xab[0], )

        # Reorder limits back to representation-form
        limits.reverse()

        return self.func(func, *limits)
def _eval_subs ( self , old , new ) : func , limits = self . function , list ( self . limits ) # If one of the expressions we are replacing is used as a func index # one of two things happens. #   - the old variable first appears as a free variable #     so we perform all free substitutions before it becomes #     a func index. #   - the old variable first appears as a func index, in #     which case we ignore.  See change_index. # Reorder limits to match standard mathematical practice for scoping limits . reverse ( ) if not isinstance ( old , C . Symbol ) or old . free_symbols . intersection ( self . free_symbols ) : sub_into_func = True for i , xab in enumerate ( limits ) : if 1 == len ( xab ) and old == xab [ 0 ] : xab = ( old , old ) limits [ i ] = Tuple ( xab [ 0 ] , * [ l . _subs ( old , new ) for l in xab [ 1 : ] ] ) if len ( xab [ 0 ] . free_symbols . intersection ( old . free_symbols ) ) != 0 : sub_into_func = False break if isinstance ( old , C . AppliedUndef ) or isinstance ( old , C . UndefinedFunction ) : sy2 = set ( self . variables ) . intersection ( set ( new . atoms ( Symbol ) ) ) sy1 = set ( self . variables ) . intersection ( set ( old . args ) ) if not sy2 . issubset ( sy1 ) : raise ValueError ( "substitution can not create dummy dependencies" ) sub_into_func = True if sub_into_func : func = func . subs ( old , new ) else : # old is a Symbol and a dummy variable of some limit for i , xab in enumerate ( limits ) : if len ( xab ) == 3 : limits [ i ] = Tuple ( xab [ 0 ] , * [ l . _subs ( old , new ) for l in xab [ 1 : ] ] ) if old == xab [ 0 ] : break # simplify redundant limits (x, x)  to (x, ) for i , xab in enumerate ( limits ) : if len ( xab ) == 2 and ( xab [ 0 ] - xab [ 1 ] ) . is_zero : limits [ i ] = Tuple ( xab [ 0 ] , ) # Reorder limits back to representation-form limits . reverse ( ) return self . func ( func , * limits )