Trouble in Calculating Force required to pull a chain over an inclined Plane Question:- A uniform chain of length $l$ and mass $m$ is hanging vertically at edge of an inclined plane AB of length $l$ which is making an angle of $30$ degrees with horizontal. Find  work done in pulling Chain slowly to AB.

Using concept of centre of mass and gravitational potential energy I was able to find work done as $\frac {3mgl}{4}$
I also tried to find total work done by calculating differential work done and then integrating it over desired limits.
$$W=\int dw=\int Fdx$$

According to me $$F=\frac{mgx}{l}+\frac {mg(l-x)}{2l}$$
But after integrating it over limits $-l$ to $0$. I got wrong answer.
How can I calculate correct value of $F$. Also can somebody tell me what is the significance of pulling chain slowly.
 A: An infinitesimal mass element can be written as
\begin{equation}
dm=\rho dx
\end{equation}
where $\rho$ is the density, assumed to be constant. This means that a finite mass is obtained by multiplying the density with a finite length.
The total work is given by a sum of two contributions. First, we have to consider when the chain is vertical, and second, when it lies along the incline. Moreover, if a piece with length $x$ is on the incline, then obviously the other piece has length $l-x$. I also assume that there is no friction.
The works are then
\begin{equation}
W_1=\int_0^{l}dx\,\rho(l-x)g=\frac{\rho gl^2}{2}
\end{equation}
\begin{equation}
W_2=\int_0^{l}dx\, \rho x  g\sin\theta =\frac{\rho gl^2}{4}
\end{equation}
The total work done is then
\begin{equation}
W=W_1+W_2=\frac{3}{4}\rho l^2=\frac{3}{4}\left(\frac{m}{l}\right)l^2=\frac{3}{4}mlg
\end{equation}
We move the chain slowly so that we can neglect possible deformations and internal stresses that could arise during the journey. In that case, the density would be a function of $x$, $\rho(x)$ so the result would obviously change.
