def chi2eps(chi):
    """Calculate epsilon ellipticity from chi.
    
    Args:
        chi: a real or complex number, or a numpy array thereof.

    Returns:
        The epsilon ellipticity in the same shape as the input.
    """
    return chi / (1 + (1 - abs(chi)**2 + 0j)**0.5)