# Why does this line integral give the wrong sign?

I've been trying to find the error in this approach to calculate the work of a uniform gravitational field on an object falling to the ground in the $$-y$$ direction. \begin{align} W &= \int_{i}^{f} \vec{F} \cdot \mathrm{d}\vec{s} \\ &= -mg \int_{i}^{f} \hat{y} \cdot \mathrm{d}\vec{s} \end{align} Because object is moving down, $$\mathrm{d}\vec{s} = -\mathrm{d}\vec{y}$$ \begin{align} &= -mg \int_{i}^{f} \hat{y} \cdot -\mathrm{d}\vec{y} \\ &= mg \int_{i}^{f} \hat{y} \cdot \mathrm{d}\vec{y} \end{align} Because $$\hat{y}$$ is parallel to $$\mathrm{d}\vec{y}$$, then the vector dot product is $$\mathrm{d}y$$ \begin{align} &= mg \int_{i}^{f} \mathrm{d}y \\ &= mg (h_f -h_i) \end{align} which is less than zero when $$h_f < h_i$$, and thus obviously wrong. Yet a simplistic approach has $$W = FD$$, with the two vectors parallel, and it is clear that the work is really positive.

Can someone point out which axiom of math or physics my math conflicts with? My instinct is that once the scalar $$\mathrm{d}y$$ is obtained, the integral "transforms" to a new coordinate system where the motion is understood to be in the positive direction, rather than the negative as the integral is set up.

Is this a common mistake? Is the lesson that when performing a dot product within an integral, the sign of the integral has to checked analytically? Or is there a simpler axiom I'm missing? I could easily envision myself, if I was writing code, to try to follow the algebra without thinking too analytically, and thus getting a wrong answer. I've studied undergrad linear algebra, vector calculus, and intermediate mechanics, but I don't recall ever seeing this issue arise.

Because object is moving down, $$\mathrm{d}\vec{s} = -\mathrm{d}\vec{y}$$

is the source of your error.

Forgetting about the integration and using the idea that the gravitational potential energy is $$mgh$$ look at what happens when a body moves from an initial height $$h_{\rm i}$$ to a final height $$h_{\rm f}$$.

The change in gravitational potential energy is $$mg(h_{\rm f} - h_{\rm i})$$

Go back one stage and write the equivalent vector equation as $$m(-\vec g)\cdot (\vec h_{\rm f} - \vec h_{\rm i}) = m(-g \,\hat y)\cdot (h_{\rm f} - h_{\rm i})\,\hat y$$

Back one more stage and then another where $$\Delta y = h_{\rm f} -h_{\rm i}$$

$$=m(-g \,\hat y)\cdot \Delta y\,\hat y=m(-g \,\hat y)\cdot \Delta \vec y$$

and in the integral form this becomes $$\displaystyle \int^{h_{\rm f}}_{h_{\rm i}}m(-g \,\hat y)\cdot d \vec y$$

Note that in all the above analysis no mention is made of the values of the components of the displacements $$h_{\rm i}\,\hat y$$ and $$h_{\rm f}\,\hat y$$.

When you wrote $$\mathrm{d}\vec{s} = -\mathrm{d}\vec{y}$$ did you really mean that the displacement was $$\Delta\vec{s} = -\Delta\vec{y} = h_{\rm i}\,\hat y-h_{\rm f}\,\hat y$$?
I think not?

In summary what you have to realise is that the sign of the increment $$ds$$ is entirely dictated by the limits of the integration and you should not prejudge the sign of $$ds$$.

Your problem is that you set $$\vec{{\rm d}s}=-\vec{{\rm d}y}$$. It doesn't matter what your path is, $$\vec{{\rm d}s}$$ is always

$$\vec{{\rm d}s}={\rm d}x\hat{x}+{\rm d}y\hat{y}+{\rm d}z\hat{z}$$

Heuristically, the sign of $${\rm d}y$$ is determined by the limits of the integration. So when you integrate on $$y_{\rm i}\rightarrow y_{\rm f}$$ with $$y_{\rm i}>y_{\rm f}$$ you have $${\rm d}y<0$$.

To get this right, I always go back to the correct definition of a line integral. To compute the work along some path, we first parameterize the path as $$\vec{s}(t)$$ where $$t$$ goes from $$t_i$$ to $$t_f$$. Then we evaluate the force along this path $$\vec{F}(\vec{s}(t))$$ and dot it into the $$d\vec{s}$$ and integrate, as follows: $$W = \int_{t_i}^{t_f} \vec{F}(\vec{s}(t))\cdot \frac{d\vec{s}(t)}{dt}~dt.$$ In your case, one way to parameterize the curve is $$\vec{s}(t) = ((1-t)y_i+ty_f)\hat{y},$$ where $$t$$ goes between 0 and 1, in which case $$\frac{d\vec{s}(t)}{dt} = (y_f-y_i)\hat{y},$$ and of course the force is just constant $$\vec{F}(\vec{s}(t)) = -mg\hat{y}$$.

Thus, \begin{align*} W &= \int_{t_i}^{t_f} \vec{F}(\vec{s}(t))\cdot \frac{d\vec{s}(t)}{dt}~dt\\ &= \int_{0}^{1} (-mg\hat{y})\cdot (y_f-y_i)\hat{y}~dt\\ &= -mg(y_f-y_i)\int_{0}^{1}dt\\ &=-mg(y_f-y_i), \end{align*} which is of course the correct answer!

The thing is, by choosing a $$d\vec{s}$$ and a set of limits, you are implicitly choosing a parameterization of your curve, and you have to be consistent about the choose of function and choice of limits. That is, based on your limits, it seems like you are choosing a parameterization in which the vertical position is the parameter: $$\vec{s}(y) = y\hat{y},$$ where $$y$$ goes from $$y_i$$ to $$y_f$$. Then $$d\vec{s} = \frac{d\vec{s}}{dy}dy = \hat{y}dy,$$ and you can see that you are forcing to choose the positive sign there rather than the negative.

Farcher's answer gives a nice physically intuitive picture of why you're forced to do this. I like going back to the correct mathematical definition because the correct negative signs come out in the wash.

After you have set $$d \vec {s} = - d \vec {y}$$, you Forgot to Change the Integration Limits. Let be $$\vec{s}$$ in the range from initial to final Points, say $$s_1, s_2, \dots, s_N$$, then the lower Limit is $$s_1$$ and the upper Limit is $$s_N$$. Now, according to your convention $$\vec{y} = - \vec{s}$$, the values that $$\vec{y}$$ will have are $$-s_1,-s_2, \dots, -s_N$$ and thus you have to Change (when you integrate over y) the Limits from $$-s_1$$ to $$-s_N$$. Evaluating the integral for the gravitational field, you will have a term proportional to

$$- \vec{s_N} - (- \vec{s_1}) = \vec{s_1}-\vec{s_N}$$

$$\vec s_N - \vec s_1$$ (when the Transformation of Integration Limits is forgotten).
• I thought of this, but the integration limits are represented abstractly, as "initial" to "final", and given that abstract representation it's not necessary to swap them to go from final to initial. I mean, to be a bit more precise with the notation, the question has something like $\int_{s_i}^{s_f} (\cdots)\mathrm{d}s \to \int_{y_i}^{y_f} (\cdots)\mathrm{d}y$. – David Z Nov 29 '18 at 8:31
• I don't think so... when you change variables, if you were integrating from the initial to the final value of the original variable, you integrate from the initial to final value of the new variable, without any extra sign change regardless of what the change of variables is. For example defining $z = -y$, $y_i = 0$ and $y_f = 1$, we have $\int_{y_i}^{y_f} \mathrm{d}y = y_f - y_i = 1$ and $\int_{y_i}^{y_f} \mathrm{d}y = \int_{z_i}^{z_f} \frac{\mathrm{d}z}{\mathrm{d}y} \mathrm{d}z = \int_{z_i}^{z_f} (-1) \mathrm{d}z = (-1)(z_f - z_i) = -(-1 - 0) = 1$. – David Z Nov 29 '18 at 8:46