import math


def mach(M1, gamma):
    """Mach # after a normal shock (eq. 3.51)

    :param <float> M1: Mach # before the shock
    :param <float> gamma: Specific heat ratio

    :return <float> Mach # after the chock
    """

    n1 = 1.0 + (gamma - 1.0) * 0.5 * M1 ** 2
    d1 = gamma * M1 ** 2 - (gamma - 1.0) * 0.5

    return math.sqrt(n1 / d1)