Let's define the following:
Let the speed of the second train (the one traveling north) be "x" km/h.
Then the speed of the first train (the one traveling west) will be "x + 5" km/h, since it is 5 km/h faster than the second train.
Step 1: Calculate the distance traveled by each train
Since both trains travel for 2 hours:
Distance traveled by the second train = speed × time = x × 2 = 2x km.
Distance traveled by the first train = speed × time = (x + 5) × 2 = 2(x + 5) = 2x + 10 km.
Step 2: Use the Pythagorean theorem
The two trains are traveling at right angles to each other (one going west and the other going north), so the distance between them after 2 hours forms a right-angled triangle. The distance between the two trains is the hypotenuse of the right triangle, and we can apply the Pythagorean theorem:
(distance between the two trains)^2 = (distance traveled by the first train)^2 + (distance traveled by the second train)^2.
Substitute the known values:
50^2 = (2x + 10)^2 + (2x)^2,
2500 = (2x + 10)^2 + (2x)^2.
Step 3: Expand the equation
First, expand both terms:
(2x + 10)^2 = 4x^2 + 40x + 100,
(2x)^2 = 4x^2.
Now, substitute these back into the equation:
2500 = (4x^2 + 40x + 100) + 4x^2,
2500 = 8x^2 + 40x + 100.
Step 4: Simplify and solve for x
Now, simplify the equation:
2500 = 8x^2 + 40x + 100,
Subtract 100 from both sides:
2400 = 8x^2 + 40x.
Now, divide through by 8 to simplify further:
300 = x^2 + 5x.
Rearrange this into a standard quadratic form:
x^2 + 5x - 300 = 0.
Step 5: Solve the quadratic equation
We solve the quadratic equation x^2 + 5x - 300 = 0 using the quadratic formula:
x = [-b ± √(b^2 - 4ac)] / 2a.
For the equation x^2 + 5x - 300 = 0, a = 1, b = 5, and c = -300. Substituting these values into the quadratic formula:
x = [-5 ± √(5^2 - 4(1)(-300))] / 2(1),
x = [-5 ± √(25 + 1200)] / 2,
x = [-5 ± √1225] / 2,
x = [-5 ± 35] / 2.
Thus, we have two possible solutions for x:
x = (-5 + 35) / 2 = 30 / 2 = 15,
x = (-5 - 35) / 2 = -40 / 2 = -20.
Since the speed cannot be negative, we have x = 15 km/h.
Step 6: Calculate the average speed of each train
The speed of the second train is x = 15 km/h.
The speed of the first train is x + 5 = 15 + 5 = 20 km/h.
Thus, the average speed of the second train is 15 km/h, and the average speed of the first train is 20 km/h.