The fly and its owner This is a related problem to Fly and Two Trains Riddle, but must not be confused for a duplicate.

A man is taking a leisurely walk with his pet fly at a pace of $v_m$. While the fly is buzzing at a speed of $v_f$. At a distance $d$ from their house, the fly starts to fly back and forth between the house and the man, while the owner walks back with speed $v_m$. 

The previous question asks for the total distance the fly traveled, which (obviously?) is given as $d_f = (v_f \cdot d)/v_m$. I had the two similar questions about this problem


*

*At which times does the fly visit home?

*Is it possible to find a function / method, which takes in a time $t \in [0,d/v_m]$ and returns the fly position?


For question 1, I cam up with the following solution
$$
\begin{align*} 
v_d \cdot ( t[n] - t[n-1] ) & = s - v_m \cdot t[n] \\ 
                     t[n-1] & = 2\cdot t[n-2] - t[n-3] \end{align*}
$$
With initial conditions
$$
t[1] = \frac{s}{v_m} \, , \ \ 
t[2] = \frac{2s}{v_m+v_f} \, , \ \
t[3] = \frac{4s}{v_m+v_f} - \frac{s}{v_m} 
$$
After some numerical tests this seems to hold, but is far from a closed solution (solving the reccurence relation leads to a gross forth order polynomial). Is there a simpler form for the answer? 
For the next part I have no idea where to start, nor if it is possible. Any ideas or help is much appreciated.
 A: Starting at the distance $d$, the time it takes the fly to return to the man is
$$
\frac{2d}{v_f+v_m}\tag{1}
$$
Thus, the distance the fly traveled is
$$
\frac{2d}{v_f+v_m}v_f\tag{2}
$$
Subtract $d$ to get the distance the fly had to fly to return from home to the man
$$
\frac{2d}{v_f+v_m}v_f-d=\frac{v_f-v_m}{v_f+v_m}\,d\tag{3}
$$
Thus, the distance of the man from home on return $n$ of the fly is
$$
d_n=\left(\frac{v_f-v_m}{v_f+v_m}\right)^n\,d\tag{4}
$$
The total distance the fly has traveled by return $n$ is
$$
\overbrace{\frac{1-\left(\frac{v_f-v_m}{v_f+v_m}\right)^n}{1-\frac{v_f-v_m}{v_f+v_m}}}^{\text{$n$ returns}}\overbrace{\vphantom{\frac{1-\left(\frac{v_f}{v_f}\right)^n}{1-\frac{v_f}{v_f}}}\left(1+\frac{v_f-v_m}{v_f+v_m}\right)\,d}^{\text{first return}}=\frac{v_f}{v_m}\left(1-\left(\frac{v_f-v_m}{v_f+v_m}\right)^n\right)\,d\tag{5}
$$
Therefore, the time of return $n$ is
$$
t_n=\frac{d}{v_m}\left(1-\left(\frac{v_f-v_m}{v_f+v_m}\right)^n\right)\tag{6}
$$
The time the fly is at home after return $n$ is
$$
\hat{t}_n=\frac{d}{v_m}\left(1-\left(\frac{v_f-v_m}{v_f+v_m}\right)^n\right)
+\frac{d}{v_f}\left(\frac{v_f-v_m}{v_f+v_m}\right)^n\tag{7}
$$
Given time $t$, the last return was 
$$
n_t=\left\lfloor\frac{\log\left(1-\frac{v_mt}{d}\right)}{\log\left(\frac{v_f-v_m}{v_f+v_m}\right)}\right\rfloor\tag{8}
$$
and the distance of the fly from home at time $t$ is
$$
v_f\left|t-\hat{t}_{\large n_t}\right|\tag{9}
$$
Equations $(7)$, $(8)$, and $(9)$ should answer both parts of the question. That is,


*

*$\hat{t}_n$ for $n=0,1,2,\dots$ are the times that the fly visits home.

*$v_f\left|t-\hat{t}_{\large n_t}\right|$ is the distance of the fly from home at time $t$.
