import math


def A_Astar(M, gamma):
    """Area-Mach # relation for isentropic, quasi-1D flow (eq. 5.20)

    :param <float> M: Mach # at area A
    :param <float> gamma: Specific heat ratio

    :return <float> Area ratio A:A_star
    """

    t1 = (gamma + 1.0) / (gamma - 1.0)
    m2 = M ** 2
    t2 = 1.0 / m2 * (2.0 / (gamma + 1.0) *
                     (1.0 + (gamma - 1.0) * 0.5 * m2)) ** t1

    return math.sqrt(t2)