recall your d = rt. distance = rate * time.
the person left at 8:00, driving at 40mph, it covered a distance of say d miles, then came back at 2:30, from 8am to 2:30 pm is 6½ hours or 13/2 hours, and it again covered the same d miles back.
if going took say t hours, then coming back must have taken the slack from 6½ and t, namely (13/2) - t.
[tex] \bf \begin{array}{lcccl}
&\stackrel{miles}{distance}&\stackrel{mph}{rate}&\stackrel{hours}{time}\\
&------&------&------\\
\textit{way over there}&d&40&t\\
\textit{way back}&d&25&\frac{13}{2}-t
\end{array}
\\\\\\
\begin{cases}
d=40t\implies \frac{d}{40}=t\\\\
d=25\left(\frac{13}{2}-\stackrel{\downarrow }{t} \right)\\
---------\\
d=25\left(\frac{13}{2}-\stackrel{\downarrow }{\frac{d}{40}} \right)
\end{cases} [/tex]
[tex] \bf d=25\left(\cfrac{260-d}{40} \right)\implies d=\cfrac{25}{40}(260-d)\implies d=\cfrac{5}{8}(260-d)
\\\\\\
8d=5(260-d)\implies 8d=1300-5d\implies 13d=1300
\\\\\\
d=\cfrac{1300}{13}\implies d=100 [/tex]