[Bit a long question]
Here in this question, I need to know clear my doubts on Gravity, more precisely Work done by a Conservative Force(here, gravitational force).
Ok, suppose there is an object lying. Neglect any damping force like friction, etc.
Now, suppose a force(it could be consevative or non-conservative force) acts on the object. It displaces from it's position.
Now, if the displacement is in the direction of that force, then the work done by the force is Positive.
And, if the displacement is in opposite direction of that force, then the work done by the force is Negative.
I think the above statements are true for any kind of force(conservative/non-conservative).
Now, we'll come to the main part of the question.
1st Part
Suppose a mass m is at point P, r distance away from another mass M.
The mass m will experience gravitational force, $\vec{F_g}$ towards mass M.
Now , an external force $\vec{F}$ acts on the object of mass m which moves it to $\infty$.
Assume a small displacement vector $d\vec{r}$ in directon of external force $\vec{F}$ for which there is no change in the gravitational force, $\vec{F_g}$. Also, consider a unit vector $\hat{r}$ in the direction of external force $\vec{F}$.
Let dWg be the work done by gravitation for this little displacement, $d\vec{r}$.
dWg = $\vec{F_g}\cdot d\vec{r}$ = Fg dr cos 180°
dWg = - Fgdr -----------Eq.(1)
So, I think the gravitational force, $\vec{F_g}$ is doing negative work and the external force, $\vec{F}$ is doing the same positive work due to the sole reason that the displacement of object is in the direction of external force and opposite to gravitational force.
Now, $\vec{F_g}$ = - $\vec{F}$ = $\frac{GMm}{r^2}$$\hat{r}$
So, in equation (1)
$$\int \, dW_g = \int_r^\infty - F_g \, dr$$
$$W_g= \int_r^\infty \frac{-GMm}{r^2} \, dr$$
$$W_g= -GMm \int_r^\infty \frac{1}{r^2} \, dr$$
$$W_g= -GMm \biggl[\frac{-1}{r}\biggr]_r^\infty$$
$$W_g= -GMm \biggl[\frac{-1}{\infty}-\frac{-1}{r}\biggr]$$
$$W_g= \frac{-GMm}{r}$$
So, $$W_g = {\color{red}{\int_r^\infty - F_g \, dr}} = {\color{green}{\frac{-GMm}{r}}}$$
The above 2 equations are in agreement. Both equations, one in red and another in green colour will give negative work done by the gravitational force.
2nd Part
Now, we'll consider that the object of mass m is at $\infty$.
Also, the object is taken from $\infty$ to point P which is again, at distance r from mass, M.
This time, the little displacement vector $d\vec{r}$ will be in the direction of gravitational force $\vec{F_g}$. Also, the unit vector $\hat{r}$ is in the same direction as well.Thus,
$\vec{F_g} = \frac{GMm}{r^2}\hat{r}$
So, the work done by gravitational force will be
dWg = $\vec{F_g}\cdot d\vec{r}$ = Fg dr cos 0°
dWg = Fgdr -----------Eq.(2)
Here, the gravtational force, $\vec{F_g}$ will do positive work because the displacement of object is in the direction of gravitational force.
So , in equation (2),
$$\int \, dW_g = \int_\infty^r F_g \, dr$$
$$W_g = \int_\infty^r \frac{GMm}{r^2} \, dr$$
$$W_g = GMm \int_\infty^r \frac{1}{r^2} \, dr$$
$$W_g = GMm \biggl[\frac{-1}{r}\biggr]_\infty^r$$
$$W_g = GMm \biggl[\frac{-1}{r}-\frac{-1}{\infty}\biggr]$$
$$W_g = \frac{-GMm}{r}$$
So, $$W_g = {\color{blue}{\int_\infty^r F_g \, dr}} = {\color{green}{\frac{-GMm}{r}}}$$
So, finally my doubt:-
The blue equation tells that the work done by gravitational force is postive(beacuse the displacement vector is in same direction as that of gravitational force).
But, after integrating it, we have the same green equation which we derived it earlier which tells us that the work done by gravitational force is negative.
Now, if we look at the red and blue equations, both are same, just integrating the term in opposite order.
And we know that the gravitational force is a conservative force so whether it is the blue one or red one, the work by gravity will be same which is given by the green equation.
But at the end, my doubt is why the blue and green equations are inconsistent to each other (blue saying work by gravity is positive whereas green saying work by gravity is negative) ?