Problem regarding friction

I require a clarification on some steps in the solution of the following problem.

Problem: The coefficient of static friction between two blocks shown in figure is μ and the table is smooth.What maximum horizontal force can be applied to the block of mass M so that the blocks move together? (M1=4kg, M2=5kg)

As the blocks should move together, they should both move with same acceleration. And the acceleration should be w.r.t the same reference point(origin). However I found a solution as shown below:

Acceleration of M1 is equal to frictional force only if x1 is a coordinate w.r.t the mass M2. x2 is a coordinate w.r.t some arbitrary origin. How can these two accelerations be equated?

• If the bodies move together their relative acceleration with respect to each other must be zero ( condition for no relative slipping ). – Aditya Garg May 18 at 3:51