As the pan is of negligible mass, there is no loss of kinetic energy even though the collision is inelastic. The meachanical energy of the body `m` in the fiels generated by the joing action of both the gravity force and the elastic force is conserved `i.e.,DeltaE=0`. During the motion of the body `m` from the initial to the final ( positon of maxiumu compression of the spring) position `DeltaT=0`, and therefore` DeltaU=DeltaU_(gr)+DeltaU_(sp)=0`
or `-mg(h+x)+(1)/(2)kx^(2)=0`
On solving the quadratic equation `:`
`x=(mg)/(k)+-sqrt((m^(2)g^(2))/(k^(2))+(2mgh)/(k))`
As minus sign is not acceptable
`x=(mg)/(k)+sqrt((m^(2)g^(2))/(k^(2))+(2mgh)/(k))`
If the body `m` were at rest on the spring, the corresponding position of `m` will be its equilibrium position and at this position the resultant force on the body `m` will be zero. Therefore the equilibrium compression `Deltax` (say ) due to the body `m` will be given by
`k Deltax= mg ` or `Deltax=mg//k`
Therefore separation betweent the equilibrium position and one of the extremen position i.e. the sought amplitude lt brgt `a=x-Deltax+sqrt((m^(2)g^(2))/(k^(2))+(2mgh)/(k))`
The mechanical energy of oscillation which is conserved equals `E=U_(extreme)`, because at the extreme position kinetic energy becomes zero .
Althought the weight of body `m` is a conservative force, it is not restoring in this problem, hence `U_(extreme)` is only concerned with the spring force. Therefore
`E=U_(extreme)=(1)/(2)ka^(2)=mgh+(m^(2)g^(2))/(2k)`