By applying law of conservation of momentum,
m1v1−m2v2=0⇒m1v1=m2v2........ (i)
Where v1 and v2 are the velocities of masses m1 and m2 at a distance r from each other.
By conservation of energy,
Change in P.E= change in K.E.
Gm1m2r=12m1v21+12m2v22........ (ii)
Solving eqn. (i) and (ii) we get
v1=
⎷2Gm22r(m1+m2) and v2=
⎷2Gm21r(m1+m2)
Relative velocity of approach, vR
=|v1|+|v2|=√2Gr(m1+m2)