Answer: 31.2 miles away from the station.
Explanation:
Let's define:
The position of the station is (0mi, 0mi)
North is the positive y-axis
East is the positive x-axis.
Then, we know that after some time the eastbound train is 25 miles away from the station, then the actual position of this train will be (25mi, 0mi)
And the other train was moving in the north direction, then the new position of the other train will be something like (0mi, Y)
Where Y is the number we want to find.
We know that the distance between two points (a, b) and (c, d) is:
Distance = √( (a - c)^2 + (b - d)^2)
Then the distance between the points (25mi, 0mi) and (0mi, A) is:
Distance = √( (25mi - 0mi)^2 + (0mi - A)^2)
And we know that this is equal to 40mi, then:
40mi = √( (25mi)^2 + (A)^2)
(40mi)^2 = (25mi)^2 + A^2
A = √( (40mi)^2 - (25mi)^2) = 31.2 mi
So the position of the northbound train is (0mi, 31.2mi)
And because the position of the station is (0mi, 0mi) is easy to see that the distance between this train and the station is equal to 31.2 mi