import math


def p02_p01(M, beta, gamma):
    """Stagnation pressure ratio across an olique shock (eq. 4.9)

    :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> Total pressure ratio p02/p01
    """

    m1sb = M * math.sin(beta)

    t1 = (gamma + 1.0) / (2.0 * gamma * m1sb ** 2 - (gamma - 1.0))
    t2 = (gamma + 1.) * m1sb ** 2 / (2.0 + (gamma - 1.0) * m1sb ** 2)

    return t1 ** (1.0 / (gamma - 1.0)) * t2 ** (gamma / (gamma - 1.0))