def complex_int_pow(a, b, n):
    """Complex integer power: computes (a+b*I)**n exactly for
    nonnegative n (a and b must be Python ints)."""
    wre = 1
    wim = 0
    while n:
        if n & 1:
            wre, wim = wre*a - wim*b, wim*a + wre*b
            n -= 1
        a, b = b*b - a*a, 2*a*b
        n //= 2
    return wre, wim
dataset/ETHPy150Open fredrik-johansson/mpmath/mpmath/libmp/libmpc.py/complex_int_pow/swapped operands of `-`