Let the total distance be $x$. For the first part, distance $=\frac{x}{2},$ velocity $=v_1$ and time taken $=t_1.$ Then, \[t_1=\frac{x/2}{v_1}\]
For the second part, distance $=\frac{x}{2},$ velocity $=v_2$ and time taken $=t_2.$ Then, \[t_2=\frac{x/2}{v_2}\]
Now, total time is given by, \[t=t_1+t_2=\frac{x/2}{v_1}+\frac{x/2}{v_2}\] \[=\frac{x}{2}\left(\frac{1}{v_1}+\frac{1}{v_2}\right)=\frac{x}{2}\left(\frac{v_1+v_2}{v_1v_2}\right)\]
The average velocity is given by, \[v_{\text{av}}=\frac{x}{t}=\frac{x}{\frac{x}{2}\left(\frac{v_1+v_2}{v_1v_2}\right)}=\frac{2v_1v_2}{v_1+v_2}\]
[Read: Motion in a Straight Line]
Try Yourself: A body travels one fourth of a distance with uniform velocity $v_1$ and the remaining with uniform velocity $v_2.$ Find the magnitude of the average velocity. [Ans: $\frac{4v_1v_2}{v_2+3v_1}$]