(f, i, a)
return f.subs(i, 0)*hyperexpand(h), h.convergence_statement
Returns (res, cond). Sums from a to oo.
Returns (res, cond). Sums from a to oo.
Returns ( res cond ) . Sums from a to oo .
def _eval_sum_hyper(f, i, a):
    """ Returns (res, cond). Sums from a to oo. """
    from sympy.functions import hyper
    from sympy.simplify import hyperexpand, hypersimp, fraction, simplify
    from sympy.polys.polytools import Poly, factor

    if a != 0:
        return _eval_sum_hyper(f.subs(i, i + a), i, 0)

    if f.subs(i, 0) == 0:
        if simplify(f.subs(i, Dummy('i', integer=True, positive=True))) == 0:
            return S(0), True
        return _eval_sum_hyper(f.subs(i, i + 1), i, 0)

    hs = hypersimp(f, i)
    if hs is None:
        return None

    numer, denom = fraction(factor(hs))
    top, topl = numer.as_coeff_mul(i)
    bot, botl = denom.as_coeff_mul(i)
    ab = [top, bot]
    factors = [topl, botl]
    params = [[], []]
    for k in range(2):
        for fac in factors[k]:
            mul = 1
            if fac.is_Pow:
                mul = fac.exp
                fac = fac.base
                if not mul.is_Integer:
                    return None
            p = Poly(fac, i)
            if p.degree() != 1:
                return None
            m, n = p.all_coeffs()
            ab[k] *= m**mul
            params[k] += [n/m]*mul

    # Add "1" to numerator parameters, to account for implicit n! in
    # hypergeometric series.
    ap = params[0] + [1]
    bq = params[1]
    x = ab[0]/ab[1]
    h = hyper(ap, bq, x)

    return f.subs(i, 0)*hyperexpand(h), h.convergence_statement
def _eval_sum_hyper ( f , i , a ) : from sympy . functions import hyper from sympy . simplify import hyperexpand , hypersimp , fraction , simplify from sympy . polys . polytools import Poly , factor if a != 0 : return _eval_sum_hyper ( f . subs ( i , i + a ) , i , 0 ) if f . subs ( i , 0 ) == 0 : if simplify ( f . subs ( i , Dummy ( 'i' , integer = True , positive = True ) ) ) == 0 : return S ( 0 ) , True return _eval_sum_hyper ( f . subs ( i , i + 1 ) , i , 0 ) hs = hypersimp ( f , i ) if hs is None : return None numer , denom = fraction ( factor ( hs ) ) top , topl = numer . as_coeff_mul ( i ) bot , botl = denom . as_coeff_mul ( i ) ab = [ top , bot ] factors = [ topl , botl ] params = [ [ ] , [ ] ] for k in range ( 2 ) : for fac in factors [ k ] : mul = 1 if fac . is_Pow : mul = fac . exp fac = fac . base if not mul . is_Integer : return None p = Poly ( fac , i ) if p . degree ( ) != 1 : return None m , n = p . all_coeffs ( ) ab [ k ] *= m ** mul params [ k ] += [ n / m ] * mul # Add "1" to numerator parameters, to account for implicit n! in # hypergeometric series. ap = params [ 0 ] + [ 1 ] bq = params [ 1 ] x = ab [ 0 ] / ab [ 1 ] h = hyper ( ap , bq , x ) return f . subs ( i , 0 ) * hyperexpand ( h ) , h . convergence_statement