The length of hike is 5 miles.
Step-by-step explanation
Suppose, the length of the hike is
miles.
On a hike up hill, Ted climbs at 3 miles an hour and going back down, he runs at 5 miles an hour.
We know that,

So, the time taken by him to climb up
hours and the time taken by him to run down
hours.
Given that, it takes him 40 minutes longer to climb up than run down. Now, 40 minutes
hours.
So the equation will be......

So, the length of hike is 5 miles.