<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def isothermal_work_compression(P1, P2, T, Z=1):
    r'''Calculates the work of compression or expansion of a gas going through
    an isothermal process.

    .. math::
        W = zRT\ln\left(\frac{P_2}{P_1}\right)

    Parameters
    ----------
    P1 : float
        Inlet pressure, [Pa]
    P2 : float
        Outlet pressure, [Pa]
    T : float
        Temperature of the gas going through an isothermal process, [K]
    Z : float
        Constant compressibility factor of the gas, [-]

    Returns
    -------
    W : float
        Work performed per mole of gas compressed/expanded [J/mol]

    Notes
    -----
    The full derivation with all forms is as follows:

    .. math::
        W = \int_{P_1}^{P_2} V dP = zRT\int_{P_1}^{P_2} \frac{1}{P} dP

    .. math::
        W = zRT\ln\left(\frac{P_2}{P_1}\right) = P_1 V_1 \ln\left(\frac{P_2}
        {P_1}\right) = P_2 V_2 \ln\left(\frac{P_2}{P_1}\right)

    The substitutions are according to the ideal gas law with compressibility:

    .. math:
        PV = ZRT

    The work of compression/expansion is the change in enthalpy of the gas.
    Returns negative values for expansion and positive values for compression.

    An average compressibility factor can be used where Z changes. For further
    accuracy, this expression can be used repeatedly with small changes in
    pressure and the work from each step summed.
    
    This is the best possible case for compression; all actual compresssors 
    require more work to do the compression.
    
    By making the compression take a large number of stages and cooling the gas
    between stages, this can be approached reasonable closely. Integrally 
    geared compressors are often used for this purpose.

    Examples
    --------
    >>> isothermal_work_compression(1E5, 1E6, 300)
    5743.427304244769

    References
    ----------
    .. [1] Couper, James R., W. Roy Penney, and James R. Fair. Chemical Process
       Equipment: Selection and Design. 2nd ed. Amsterdam ; Boston: Gulf
       Professional Publishing, 2009.
    '''
    return Z*R*T*log(P2/P1)