import math


def polar(x):
    """ 
        Convert a complex from rectangular coordinates to polar coordinates. 
        
        The function returns a tuple with the two elements r and phi. 
        r is the distance from 0 and phi the phase angle.
    """
    phi = math.atan2(x.imag, x.real)
    r = math.sqrt(x.real**2+x.imag**2)
    return r, phi