import cmath      # complex functions


def roots(a, b, c):
    """
    Return two roots of the quadratic algebraic equation
    ax^2 + bx + c = 0, where a, b, and c may be complex.
    """
    q = b*b - 4*a*c
    r1 = -(b - cmath.sqrt(q))/(2*a)
    r2 = -(b + cmath.sqrt(q))/(2*a)
    # r1 and r2 are complex because cmath.sqrt returns complex,
    # convert to real if possible:
    if r1.imag == 0.0:  r1 = r1.real
    if r2.imag == 0.0:  r2 = r2.real
    if r1 == r2:  r2 = None  # use r2=None to indicate double root
    return r1, r2