def API520_F2(k, P1, P2):
    """Calculates coefficient F2 for subcritical flow for use in API 520
    subcritical flow relief valve sizing.

    .. math::
        F_2 = \\sqrt{\\left(\\frac{k}{k-1}\\right)r^\\frac{2}{k}
        \\left[\\frac{1-r^\\frac{k-1}{k}}{1-r}\\right]}

    .. math::
        r = \\frac{P_2}{P_1}

    Parameters
    ----------
    k : float
        Isentropic coefficient or ideal gas heat capacity ratio [-]
    P1 : float
        Upstream relieving pressure; the set pressure plus the allowable
        overpressure, plus atmospheric pressure, [Pa]
    P2 : float
        Built-up backpressure; the increase in pressure during flow at the
        outlet of a pressure-relief device after it opens, [Pa]

    Returns
    -------
    F2 : float
        Subcritical flow coefficient `F2` [-]

    Notes
    -----
    F2 is completely dimensionless.

    Examples
    --------
    From [1]_ example 2, matches.

    >>> API520_F2(1.8, 1E6, 7E5)
    0.8600724121105563

    References
    ----------
    .. [1] API Standard 520, Part 1 - Sizing and Selection.
    """
    r = P2 / P1
    return (k / (k - 1) * r ** (2.0 / k) * ((1 - r ** ((k - 1.0) / k)) / (
        1.0 - r))) ** 0.5
