import math


def shock_speed(p2, d1, p1, g):

	"""
	Calculates the shock speed in the upstream reference frame
	Input:
	p2 - Downstream pressure
	d1 - Upstream density
	p1 - Upstream pressure
	g - Adiabatic index
	"""
	
	
	return math.sqrt(-p1 + g*p1 + p2 + g*p2)/(math.sqrt(2)*math.sqrt(d1))