If we use ground as internal frame as we usually do, solutiona of the problem becomes quite involved. Therefore, we prefer the center of mass frame, in which mass center remains at rest.
In the adjacent figure is shown horizontal position of mass center (CM) by dashed line. It remains unchanged in center of mass frame.
Mass center of two particle system divides separation between them in reciprocal ratio of the masses, therefore displacements `x_(1)` and `x_(2)` of the blocks must also be in reciprocal ratio of their masses. The extension x is sum of displacements `x_(1)` and `x_(2)` of the blocks as shown in the figure.When extension of the spring achieves its maximum value, both the block must stop receding away from the mass center, therefore, velocities of both the blocks in center of mass must be zero, nrgative work done by spring forces becomes equal to increase in potential energy and work done by applied force evidently becomes `Fx_(1)`.
Using above fact in applying work energy theorem on the system relative to the cente of mass frame, we obtain
`K_(i)+W_(irarrf)=K_(f) rarr 0+W_(i rarr f,"springforce")+W_(i rarr f),F = 0`
`-(0-1/2kx^(2)) + (FM_(x))/(m+m) = 0`
`x=(2FM)/(k(m+m))`