(s, t, prec, rnd=round_fast)
return mpf_exp(mpf_mul(t, c), prec, rnd)
Compute s**t. Raises ComplexResult if s is negative and t is
    fractional.
Compute s**t. Raises ComplexResult if s is negative and t is
    fractional.
Compute s ** t . Raises ComplexResult if s is negative and t is fractional .
def mpf_pow(s, t, prec, rnd=round_fast):
    """
    Compute s**t. Raises ComplexResult if s is negative and t is
    fractional.
    """
    ssign, sman, sexp, sbc = s
    tsign, tman, texp, tbc = t
    if ssign and texp < 0:
        raise ComplexResult("negative number raised to a fractional power")
    if texp >= 0:
        return mpf_pow_int(s, (-1)**tsign * (tman<<texp), prec, rnd)
    # s**(n/2) = sqrt(s)**n
    if texp == -1:
        if tman == 1:
            if tsign:
                return mpf_div(fone, mpf_sqrt(s, prec+10,
                    reciprocal_rnd[rnd]), prec, rnd)
            return mpf_sqrt(s, prec, rnd)
        else:
            if tsign:
                return mpf_pow_int(mpf_sqrt(s, prec+10,
                    reciprocal_rnd[rnd]), -tman, prec, rnd)
            return mpf_pow_int(mpf_sqrt(s, prec+10, rnd), tman, prec, rnd)
    # General formula: s**t = exp(t*log(s))
    # TODO: handle rnd direction of the logarithm carefully
    c = mpf_log(s, prec+10, rnd)
    return mpf_exp(mpf_mul(t, c), prec, rnd)
def mpf_pow ( s , t , prec , rnd = round_fast ) : ssign , sman , sexp , sbc = s tsign , tman , texp , tbc = t if ssign and texp < 0 : raise ComplexResult ( "negative number raised to a fractional power" ) if texp >= 0 : return mpf_pow_int ( s , ( - 1 ) ** tsign * ( tman << texp ) , prec , rnd ) # s**(n/2) = sqrt(s)**n if texp == - 1 : if tman == 1 : if tsign : return mpf_div ( fone , mpf_sqrt ( s , prec + 10 , reciprocal_rnd [ rnd ] ) , prec , rnd ) return mpf_sqrt ( s , prec , rnd ) else : if tsign : return mpf_pow_int ( mpf_sqrt ( s , prec + 10 , reciprocal_rnd [ rnd ] ) , - tman , prec , rnd ) return mpf_pow_int ( mpf_sqrt ( s , prec + 10 , rnd ) , tman , prec , rnd ) # General formula: s**t = exp(t*log(s)) # TODO: handle rnd direction of the logarithm carefully c = mpf_log ( s , prec + 10 , rnd ) return mpf_exp ( mpf_mul ( t , c ) , prec , rnd )