(aa, bb, cc, dd, ee, ff, prec=None)
return res
r"""
    Calculate the Racah symbol `W(a,b,c,d;e,f)`.

    INPUT:

    -  ``a``, ..., ``f`` - integer or half integer

    -  ``prec`` - precision, default: ``None``. Providing a precision can
       drastically speed up the calculation.

    OUTPUT:

    Rational number times the square root of a rational number
    (if ``prec=None``), or real number if a precision is given.

    Examples
    ========

    >>> from sympy.physics.wigner import racah
    >>> racah(3,3,3,3,3,3)
    -1/14

    NOTES:

    The Racah symbol is related to the Wigner 6j symbol:

    .. math::

       Wigner6j(j_1,j_2,j_3,j_4,j_5,j_6)
       =(-1)^{j_1+j_2+j_4+j_5} W(j_1,j_2,j_5,j_4,j_3,j_6)

    Please see the 6j symbol for its much richer symmetries and for
    additional properties.

    ALGORITHM:

    This function uses the algorithm of [Edmonds74]_ to calculate the
    value of the 6j symbol exactly. Note that the formula contains
    alternating sums over large factorials and is therefore unsuitable
    for finite precision arithmetic and only useful for a computer
    algebra system [Rasch03]_.

    AUTHORS:

    - Jens Rasch (2009-03-24): initial version
r"""
    Calculate the Racah symbol `W(a,b,c,d;e,f)`.
r Calculate the Racah symbol W ( a b c d ; e f ) .
def racah(aa, bb, cc, dd, ee, ff, prec=None):
    r"""
    Calculate the Racah symbol `W(a,b,c,d;e,f)`.

    INPUT:

    -  ``a``, ..., ``f`` - integer or half integer

    -  ``prec`` - precision, default: ``None``. Providing a precision can
       drastically speed up the calculation.

    OUTPUT:

    Rational number times the square root of a rational number
    (if ``prec=None``), or real number if a precision is given.

    Examples
    ========

    >>> from sympy.physics.wigner import racah
    >>> racah(3,3,3,3,3,3)
    -1/14

    NOTES:

    The Racah symbol is related to the Wigner 6j symbol:

    .. math::

       Wigner6j(j_1,j_2,j_3,j_4,j_5,j_6)
       =(-1)^{j_1+j_2+j_4+j_5} W(j_1,j_2,j_5,j_4,j_3,j_6)

    Please see the 6j symbol for its much richer symmetries and for
    additional properties.

    ALGORITHM:

    This function uses the algorithm of [Edmonds74]_ to calculate the
    value of the 6j symbol exactly. Note that the formula contains
    alternating sums over large factorials and is therefore unsuitable
    for finite precision arithmetic and only useful for a computer
    algebra system [Rasch03]_.

    AUTHORS:

    - Jens Rasch (2009-03-24): initial version
    """
    prefac = _big_delta_coeff(aa, bb, ee, prec) * \
        _big_delta_coeff(cc, dd, ee, prec) * \
        _big_delta_coeff(aa, cc, ff, prec) * \
        _big_delta_coeff(bb, dd, ff, prec)
    if prefac == 0:
        return 0
    imin = max(aa + bb + ee, cc + dd + ee, aa + cc + ff, bb + dd + ff)
    imax = min(aa + bb + cc + dd, aa + dd + ee + ff, bb + cc + ee + ff)

    maxfact = max(imax + 1, aa + bb + cc + dd, aa + dd + ee + ff,
                 bb + cc + ee + ff)
    _calc_factlist(maxfact)

    sumres = 0
    for kk in range(int(imin), int(imax) + 1):
        den = _Factlist[int(kk - aa - bb - ee)] * \
            _Factlist[int(kk - cc - dd - ee)] * \
            _Factlist[int(kk - aa - cc - ff)] * \
            _Factlist[int(kk - bb - dd - ff)] * \
            _Factlist[int(aa + bb + cc + dd - kk)] * \
            _Factlist[int(aa + dd + ee + ff - kk)] * \
            _Factlist[int(bb + cc + ee + ff - kk)]
        sumres = sumres + Integer((-1) ** kk * _Factlist[kk + 1]) / den

    res = prefac * sumres * (-1) ** int(aa + bb + cc + dd)
    return res
def racah ( aa , bb , cc , dd , ee , ff , prec = None ) : prefac = _big_delta_coeff ( aa , bb , ee , prec ) * _big_delta_coeff ( cc , dd , ee , prec ) * _big_delta_coeff ( aa , cc , ff , prec ) * _big_delta_coeff ( bb , dd , ff , prec ) if prefac == 0 : return 0 imin = max ( aa + bb + ee , cc + dd + ee , aa + cc + ff , bb + dd + ff ) imax = min ( aa + bb + cc + dd , aa + dd + ee + ff , bb + cc + ee + ff ) maxfact = max ( imax + 1 , aa + bb + cc + dd , aa + dd + ee + ff , bb + cc + ee + ff ) _calc_factlist ( maxfact ) sumres = 0 for kk in range ( int ( imin ) , int ( imax ) + 1 ) : den = _Factlist [ int ( kk - aa - bb - ee ) ] * _Factlist [ int ( kk - cc - dd - ee ) ] * _Factlist [ int ( kk - aa - cc - ff ) ] * _Factlist [ int ( kk - bb - dd - ff ) ] * _Factlist [ int ( aa + bb + cc + dd - kk ) ] * _Factlist [ int ( aa + dd + ee + ff - kk ) ] * _Factlist [ int ( bb + cc + ee + ff - kk ) ] sumres = sumres + Integer ( ( - 1 ) ** kk * _Factlist [ kk + 1 ] ) / den res = prefac * sumres * ( - 1 ) ** int ( aa + bb + cc + dd ) return res