import math


def rho2_rho1(M, beta, gamma):
    """Density ratio across an olique shock (eq. 4.8)

    :param <float> M: Mach # upstream
    :param <float> Beta: Shock angle w.r.t initial flow direction (radians)
    :param <float> gamma: Specific heat ratio

    :return <float> Density ratio r2/r1
    """

    m1sb = M * math.sin(beta)

    n1 = (gamma + 1.0) * m1sb ** 2
    d1 = 2.0 + (gamma - 1.0) * m1sb ** 2

    return n1 / d1