Relative velocity approach
Using v2rel = u2rel + 2arel.srel, we can obtain the same result.
Substitute: vrel = v′12 = v′1 - v′2, urel = v1−v2,
arel = a12 = (-a1)−a2 = -(a1+a2) and srel = s12 = -d,
to obtain (v′1−v′2)2=(v1−v2)2−2(a1+a2)d
Since v′1<v′2 to avoid collision, we have
d=(v1−v2)2−(v′1−v′2)22(a1+a2)
Maximum distance d for collision is possible when v′1=v′2,
then, dmax=(v1−v2)22(a1+a2)