(f, x, a, b)
Integrate ``f`` over the interval [``a``, ``b``], by rewriting it as a product
    of two G functions, or as a single G function.

    Return res, cond, where cond are convergence conditions.

    >>> from sympy.integrals.meijerint import meijerint_definite
    >>> from sympy import exp, oo
    >>> from sympy.abc import x
    >>> meijerint_definite(exp(-x**2), x, -oo, oo)
    (sqrt(pi), True)

    This function is implemented as a succession of functions
    meijerint_definite, _meijerint_definite_2, _meijerint_definite_3,
    _meijerint_definite_4. Each function in the list calls the next one
    (presumably) several times. This means that calling meijerint_definite
    can be very costly.
Integrate ``f`` over the interval [``a``, ``b``], by rewriting it as a product
    of two G functions, or as a single G function.
Integrate f over the interval [ a b ] by rewriting it as a product of two G functions or as a single G function .
def meijerint_definite(f, x, a, b):
    """
    Integrate ``f`` over the interval [``a``, ``b``], by rewriting it as a product
    of two G functions, or as a single G function.

    Return res, cond, where cond are convergence conditions.

    >>> from sympy.integrals.meijerint import meijerint_definite
    >>> from sympy import exp, oo
    >>> from sympy.abc import x
    >>> meijerint_definite(exp(-x**2), x, -oo, oo)
    (sqrt(pi), True)

    This function is implemented as a succession of functions
    meijerint_definite, _meijerint_definite_2, _meijerint_definite_3,
    _meijerint_definite_4. Each function in the list calls the next one
    (presumably) several times. This means that calling meijerint_definite
    can be very costly.
    """
    # This consists of three steps:
    # 1) Change the integration limits to 0, oo
    # 2) Rewrite in terms of G functions
    # 3) Evaluate the integral
    #
    # There are usually several ways of doing this, and we want to try all.
    # This function does (1), calls _meijerint_definite_2 for step (2).
    from sympy import Integral, arg, exp, I, And, DiracDelta, count_ops
    _debug('Integrating', f, 'wrt %s from %s to %s.' % (x, a, b))

    if f.has(DiracDelta):
        _debug('Integrand has DiracDelta terms - giving up.')
        return None

    f_, x_, a_, b_ = f, x, a, b

    # Let's use a dummy in case any of the boundaries has x.
    d = Dummy('x')
    f = f.subs(x, d)
    x = d

    if a == -oo and b != oo:
        return meijerint_definite(f.subs(x, -x), x, -b, -a)

    if a == -oo:
        # Integrating -oo to oo. We need to find a place to split the integral.
        _debug('  Integrating -oo to +oo.')
        innermost = _find_splitting_points(f, x)
        _debug('  Sensible splitting points:', innermost)
        for c in sorted(innermost, key=default_sort_key, reverse=True) + [S(0)]:
            _debug('  Trying to split at', c)
            if not c.is_real:
                _debug('  Non-real splitting point.')
                continue
            res1 = _meijerint_definite_2(f.subs(x, x + c), x)
            if res1 is None:
                _debug('  But could not compute first integral.')
                continue
            res2 = _meijerint_definite_2(f.subs(x, c - x), x)
            if res2 is None:
                _debug('  But could not compute second integral.')
                continue
            res1, cond1 = res1
            res2, cond2 = res2
            cond = _condsimp(And(cond1, cond2))
            if cond == False:
                _debug('  But combined condition is always false.')
                continue
            res = res1 + res2
            return res, cond
        return

    if a == oo:
        return -meijerint_definite(f, x, b, oo)

    if (a, b) == (0, oo):
        # This is a common case - try it directly first.
        res = _meijerint_definite_2(f, x)
        if res is not None and not res[0].has(meijerg):
            return res

    results = []
    if b == oo:
        for split in _find_splitting_points(f, x):
            if (a - split >= 0) == True:
                _debug('Trying x --> x + %s' % split)
                res = _meijerint_definite_2(f.subs(x, x + split)
                                            *Heaviside(x + split - a), x)
                if res is not None:
                    if res[0].has(meijerg):
                        results.append(res)
                    else:
                        return res

    f = f.subs(x, x + a)
    b = b - a
    a = 0
    if b != oo:
        phi = exp(I*arg(b))
        b = abs(b)
        f = f.subs(x, phi*x)
        f *= Heaviside(b - x)*phi
        b = oo

    _debug('Changed limits to', a, b)
    _debug('Changed function to', f)
    res = _meijerint_definite_2(f, x)
    if res is not None:
        if res[0].has(meijerg):
            results.append(res)
        else:
            return res
    if results:
        return sorted(results, key=lambda x: count_ops(x[0]))[0]
def meijerint_definite ( f , x , a , b ) : # This consists of three steps: # 1) Change the integration limits to 0, oo # 2) Rewrite in terms of G functions # 3) Evaluate the integral # # There are usually several ways of doing this, and we want to try all. # This function does (1), calls _meijerint_definite_2 for step (2). from sympy import Integral , arg , exp , I , And , DiracDelta , count_ops _debug ( 'Integrating' , f , 'wrt %s from %s to %s.' % ( x , a , b ) ) if f . has ( DiracDelta ) : _debug ( 'Integrand has DiracDelta terms - giving up.' ) return None f_ , x_ , a_ , b_ = f , x , a , b # Let's use a dummy in case any of the boundaries has x. d = Dummy ( 'x' ) f = f . subs ( x , d ) x = d if a == - oo and b != oo : return meijerint_definite ( f . subs ( x , - x ) , x , - b , - a ) if a == - oo : # Integrating -oo to oo. We need to find a place to split the integral. _debug ( '  Integrating -oo to +oo.' ) innermost = _find_splitting_points ( f , x ) _debug ( '  Sensible splitting points:' , innermost ) for c in sorted ( innermost , key = default_sort_key , reverse = True ) + [ S ( 0 ) ] : _debug ( '  Trying to split at' , c ) if not c . is_real : _debug ( '  Non-real splitting point.' ) continue res1 = _meijerint_definite_2 ( f . subs ( x , x + c ) , x ) if res1 is None : _debug ( '  But could not compute first integral.' ) continue res2 = _meijerint_definite_2 ( f . subs ( x , c - x ) , x ) if res2 is None : _debug ( '  But could not compute second integral.' ) continue res1 , cond1 = res1 res2 , cond2 = res2 cond = _condsimp ( And ( cond1 , cond2 ) ) if cond == False : _debug ( '  But combined condition is always false.' ) continue res = res1 + res2 return res , cond return if a == oo : return - meijerint_definite ( f , x , b , oo ) if ( a , b ) == ( 0 , oo ) : # This is a common case - try it directly first. res = _meijerint_definite_2 ( f , x ) if res is not None and not res [ 0 ] . has ( meijerg ) : return res results = [ ] if b == oo : for split in _find_splitting_points ( f , x ) : if ( a - split >= 0 ) == True : _debug ( 'Trying x --> x + %s' % split ) res = _meijerint_definite_2 ( f . subs ( x , x + split ) * Heaviside ( x + split - a ) , x ) if res is not None : if res [ 0 ] . has ( meijerg ) : results . append ( res ) else : return res f = f . subs ( x , x + a ) b = b - a a = 0 if b != oo : phi = exp ( I * arg ( b ) ) b = abs ( b ) f = f . subs ( x , phi * x ) f *= Heaviside ( b - x ) * phi b = oo _debug ( 'Changed limits to' , a , b ) _debug ( 'Changed function to' , f ) res = _meijerint_definite_2 ( f , x ) if res is not None : if res [ 0 ] . has ( meijerg ) : results . append ( res ) else : return res if results : return sorted ( results , key = lambda x : count_ops ( x [ 0 ] ) ) [ 0 ]