At any instant of time let x1 and x2 be the displacements of 1 and 2 from a fixed line (shown as dotted).
Then, x1+x2= constant
or x1+x2=l (length of string)
Differentiating with respect to time, we have
v1+v2=0 or v1=v2
Again differentiating with respect to time, we get
a1+a2=0 or a1=−a2
This is the required relation between a1 and a2, i.e., accelerations of 1 and 2 are equal but in opposite directions.