A heavy chain with a mass per unit length $\rho$ is pulled by the constant force $F$ along a horizontal surface consisting of a smooth section and a rough section. The chain is initially at rest on the rough surface with $x=0$. If the coefficient of kinetic friction between the chain and rough surface is $\mu$, determine the velocity of the chain when $x=L$.
I am applying work energy theorem. Work done by constant Force will be Force × displacement of centre of mass i.e $FL$ but not able to find work done by friction. The friction force at an instant when chain length $x$ lies on the rough surface should be $\mu\rho x g$. This force is continuously decreasing. I feel calculus is involved here but I am unable to apply it. Please help me.