How would one write a formula to find the average speed if one knows the distance traveled and the rate of speed for each portion of the trip?

20 miles at m speed
40 miles at n speed