def thrust_coef(p_c, p_e, gamma, p_a=None, er=None):
    """Nozzle thrust coefficient, :math:`C_F`.

    The thrust coefficient is a figure of merit for the nozzle expansion process.
    See :ref:`thrust-coefficient-label` for a description of the physical meaning of the
    thrust coefficient.

    Reference: Equation 1-33a in Huzel and Huang.

    Arguments:
        p_c (scalar): Nozzle stagnation chamber pressure [units: pascal].
        p_e (scalar): Nozzle exit static pressure [units: pascal].
        gamma (scalar): Exhaust gas ratio of specific heats [units: dimensionless].
        p_a (scalar, optional): Ambient pressure [units: pascal]. If None,
            then p_a = p_e.
        er (scalar, optional): Nozzle area expansion ratio [units: dimensionless]. If None,
            then p_a = p_e.

    Returns:
        scalar: The thrust coefficient, :math:`C_F` [units: dimensionless].
    """
    if p_a is None and er is not None or er is None and p_a is not None:
        raise ValueError('Both p_a and er must be provided.')
    C_F = (2 * gamma ** 2 / (gamma - 1) * (2 / (gamma + 1)) ** ((gamma + 1) /
        (gamma - 1)) * (1 - (p_e / p_c) ** ((gamma - 1) / gamma))) ** 0.5
    if p_a is not None and er is not None:
        C_F += er * (p_e - p_a) / p_c
    return C_F
