def residcomp(z1, z0, linelength=1):
    """
    Residual Compensation Factor Function.

    Evaluates the residual compensation factor based on the line's positive and
    zero sequence impedance characteristics.

    Parameters
    ----------
    z1:         complex
                The positive-sequence impedance
                characteristic of the line, specified in
                ohms-per-unit where the total line length
                (of same unit) is specified in
                *linelength* argument.
    z0:         complex
                The zero-sequence impedance characteristic
                of the line, specified in ohms-per-unit
                where the total line length (of same unit)
                is specified in *linelength* argument.
    linelength: float, optional
                The length (in same base unit as impedance
                characteristics) of the line. default=1

    Returns
    -------
    k0:         complex
                The residual compensation factor.
    """
    # Evaluate Z1L and Z0L
    Z1L = z1 * linelength
    Z0L = z0 * linelength
    # Calculate Residual Compensation Factor (k0)
    k0 = (Z0L - Z1L) / (3 * Z1L)
    return k0