Line integrals

Last time, we started doing an example of calculating work

\[ \begin{aligned} W = \int_{\vec{r}_1}^{\vec{r}_2} \vec{F} \cdot d\vec{r}. \end{aligned} \]

using a particular force of the form

\[ \begin{aligned} \vec{F} = Fx\hat{x} + 2F\hat{y}, \end{aligned} \]

from \( \vec{r}_1 = (0,0) \) to \( \vec{r}_2 = (2,1) \). We observed that there are multiple possible paths that define the line integral with the given endpoints:

Notice that these are directed paths, hence the arrows; just like a regular integral, if we go backwards (reverse the limits of integration so we move from \( \vec{r}_2 \) to \( \vec{r}_1 \)), then we get an extra minus sign.

Let's pick one of the curves above and try to evaluate the integral. I'll start with the straight line path, \( \mathcal{C}_1 \). If we think about it for a moment, the way a path is mathematically defined is an equation relating our coordinates to each other. In this case, we can write simply

\[ \begin{aligned} y = \frac{1}{2}x \end{aligned} \]

along \( \mathcal{C}_1 \). This relationship is true as long as we follow the curve. But we can use this to collapse our two differentials together: we have

\[ \begin{aligned} dx = 2dy \end{aligned} \]

so we can rewrite the line integral as

\[ \begin{aligned} W_1 = \int_{\mathcal{C}_1} (F xdx + 2F dy) \\ = \int_0^1 (F (2y) (2 dy) + 2F dy) \\ = F \left( \left. 4 \frac{y^2}{2} \right|_0^1 + \left. 2y \right|_0^1 \right) \\ = 4F. \end{aligned} \]

This shows the basic idea of evaluating a line integral: although it looks like it has multiple coordinate differentials in it, when we move along a specific line, we can relate our coordinates together and collapse down to a single differential. Then we just have a normal integral to do! (It will always be a single integral, because a line is one-dimensional; we can always describe the distance along a line using a single number, whether the line is curved or not.)

An important feature of this method is that the way in which we collapse our multiple coordinates down to one is not unique. For example, we could have replaced \( dy \) instead of \( dx \), and we'll get the same answer:

\[ \begin{aligned} W_1 = \int_{\mathcal{C}_1} (Fx dx + 2F (dx/2)) \\ = \int_0^2\ F(1+x) dx \\ = F \left. x \right|_0^2 + F \left. \frac{1}{2} x^2 \right|_0^2 \\ = 4F. \end{aligned} \]

We don't even have to stick to \( x \) and \( y \)! Another way to describe \( \mathcal{C}_1 \) is using a parametric equation: if we call our parameter \( s \), then

\[ \begin{aligned} x(s) = 2s \\ y(s) = s \\ \end{aligned} \]

is another way to describe the line \( y=x/2 \); looking at the endpoints, we start at \( s=0 \) and end at \( s=1 \). Now we replace both coordinates, using \( dx = 2ds \) and \( dy = ds \):

\[ \begin{aligned} W_1 = \int_{\mathcal{C}_1} (F (2s) (2 ds) + 2F ds) \\ = \int_0^1\ 2F (2s+1) ds = 4F. \end{aligned} \]

We can even do a more interesting parametrization, like this:

\[ \begin{aligned} x(u) = 1-u\\ y(u) = (1-u)/2 \end{aligned} \]

where \( u \) runs from \( +1 \) to \( -1 \). I'll leave it as an exercise for you to verify that this gives the same answer once again.

No matter how we parameterize the curve, the result will always be the same - we're not changing anything except how we choose to describe it. Finding a good parameterization can be kind of an art (like choosing a good set of coordinates!) But the good news is that in physics applications, the parameterization is usually done for us: whenever we solve for the motion \( \vec{r}(t) \), the time \( t \) is already a parameter that describes the whole path.

What will change the result of our curve, however, is taking a different path! We can try it out for the given force and endpoints. Suppose we went from \( (0,0) \) to \( (1,2) \) along the half-square path \( \mathcal{C}_2 \) sketched above. We can do that integral by just splitting the integral in half: first we have \( y=0 \) fixed (so \( dy=0 \)), and then \( x=2 \) fixed (so \( dx=0 \)). Thus,

\[ \begin{aligned} W_2 = \int_{\mathcal{C}_2} (F x dx + 2F dy) \\ = \int_0^2 F x dx + \int_0^1 2F dy \\ = 2F + 2F = 4F. \end{aligned} \]

In this particular case, we got the same answer again! In fact, you'll get the same answer for any path and this force - which seems mysterious at the moment, but there is a deeper reason for it that we'll see soon.

By the way, it's often useful to visualize what's going on in these line integrals before we just do the math out. Sketching the paths is only half of the visualization, because the direction and size of the force also matters. However, while the path is just a single line through space, the force \( \vec{F} \) is generally defined everywhere in space. As a result, we visualize it by drawing a force field plot. (A vector field is just a set of vectors that exist everywhere in space, whose values and directions are functions of position.)

This makes it simpler to understand the work resulting from certain paths. (In particular, if we move perpendicular to the force field, then \( \vec{F} \cdot d\vec{r} \) is always zero and the work will be zero. More on that later...)

Since it's often useful to sketch vector fields, it's worth knowing that Mathematica has a function to do it for us, the VectorPlot[] function. Here's an example:

In Mathematica, vectors are denoted using curly braces {,}. You can see the input notation for VectorPlot above: the first argument is the vector field as a function, i.e. we enter {F_x, F_y} = {x, 2} for the vector field we've been working with. The last two arguments define the variable names and range to plot over, first x and then y.


Example: polar force field

Let's do another example. Suppose we have a force which is proportional to the polar unit vector \( \hat{\phi} \),

\[ \begin{aligned} \vec{F} = F\hat{\phi} \end{aligned} \]

and we're interested in the work done along a counterclockwise half-circle path from \( (1,0) \) to \( (-1,0) \).

Sketching vector fields makes my hand hurt, so here's another Mathematica plot:

(I converted from polar to Cartesian for the plot - more on that below.) Think about it - does this match what you expected the plot to look like?

Next, we need \( d\vec{r} \) so we can find the dot product. Since we have \( \vec{F} \) in polar coordinates, we should use \( d\vec{r} \) in the same coordinates. We'll assume \( z=0 \), but in full 3-d cylindrical coordinates, we know that

\[ \begin{aligned} \vec{r} = \rho \hat{\rho} + z \hat{z} \end{aligned} \]

To find \( d\vec{r} \), one way would just be to start with the Cartesian version

\[ \begin{aligned} d\vec{r} = dx\ \hat{x} + dy\ \hat{y} + dz\ \hat{z} \end{aligned} \]

and apply our coordinate change. More directly, we can just calculate the derivative of \( \vec{r} \) with respect to some parameter, like \( t \), and then cancel off the \( dt \)'s. Let's try it that way:

\[ \begin{aligned} \frac{d\vec{r}}{dt} = \dot{\rho} \hat{\rho} + \rho \frac{d\hat{\rho}}{dt} + \dot{z} \hat{z} \\ = \frac{d\rho}{dt} \hat{\rho} + \rho \frac{d\phi}{dt} \hat{\phi} + \frac{dz}{dt} \hat{z} \end{aligned} \]

using the result for \( d\hat{\rho}/dt \) that we worked out back at the start of the semester. Cancelling off the \( dt \)'s,

\[ \begin{aligned} d\vec{r} = d\rho\ \hat{\rho} + \rho d\phi\ \hat{\phi} + dz\ \hat{z}. \end{aligned} \]

In case you ever need it, I'll save you some trouble and give you the result for spherical coordinates:

\[ \begin{aligned} d\vec{r} = dr\ \hat{r} + r d\theta\ \hat{\theta} + r\sin \theta d\phi\ \hat{\phi}. \end{aligned} \]

Using our result, we have the simple result

\[ \begin{aligned} dW = \vec{F} \cdot d\vec{r} = F \rho d\phi \end{aligned} \]

Next, we parameterize the half-circular path. Any time we have a path like a circle or a spiral, an angle is a natural parameter to use. In fact, since this is just a section of the unit circle, we can easily write the path in the trivial-looking form

\[ \begin{aligned} \rho = 1, \\ \phi = \phi, \end{aligned} \]

starting at \( \phi=0 \) and ending at \( \phi=\pi \). Thus, the integral can be written simply as

\[ \begin{aligned} W = \int_0^\pi F d\phi = \pi F. \end{aligned} \]

(Don't be confused by units! Remember, our path has units of distance, so this is something like "pi meters times the constant force \( F \).")

Note that the length of the path can also be found by a line integral, which amounts to adding up a bunch of infinitesmal length segments:

\[ \begin{aligned} \ell = \int |d\vec{r}| = \int \sqrt{d\vec{r} \cdot d\vec{r}} = \int \sqrt{\rho^2 d\phi^2} = \int_0^\pi \rho\ d\phi = \pi \end{aligned} \]

(this is also easy to find geometrically as just half the circumference of a circle, of course.) So in this case, just like in our one-dimensional examples, we have simply \( W = F \ell \). This happens because for this particular path and force, \( \vec{F} \) and \( d\vec{r} \) point in the same direction as one another along the entire path.

By the way, in this problem it was sort of obvious to choose polar coordinates, because of how we were given the force. But we could have been given \( \vec{F} \) in Cartesian coordinates instead:

\[ \begin{aligned} \vec{F} = -\frac{y}{\sqrt{x^2 + y^2}} \hat{x} + \frac{x}{\sqrt{x^2 + y^2}} \hat{y} \end{aligned} \]

You might be able to spot the fact that this is just \( \hat{\phi} \) from the expression, but a more reliable way to see that polar coordinates might be the way to go would be to plot the force field (this is one reason plotting vector fields is useful!)

Another important note on coordinate dependence: it's generally a better idea to let the force field dictate the coordinate choice, rather than the path. For example, suppose we had this same circular force, but the straight-line path \( y = x/2 \) from our previous example. It's actually not so hard to parametrize that path in polar coordinates: remembering how polar and Cartesian are related, the line equation above becomes

\[ \begin{aligned} \rho \sin \phi = \frac{1}{2} \rho \cos \phi \Rightarrow \tan \phi = \frac{1}{2}. \end{aligned} \]

So this is a path with constant \( \phi \) and constant \( z \), giving \( d\vec{r} = d\rho \hat{\rho} \). We don't have to go any further, since \( \vec{F} \cdot d\vec{r} = 0 \) and the work is just zero.

That was too easy, since a straight line through the origin is just in the \( \hat{\rho} \) direction and therefore still nice in cylindrical coordinates. What about this path, the fixed vertical line \( x=1 \) from \( (1,1) \) to \( (1,-1) \)?

We can still write this in polar coordinates. In fact, since \( x = \rho \cos \phi \), the equation for this line is

\[ \begin{aligned} x = 1 \Rightarrow \rho(\phi) = \frac{1}{\cos \phi} \end{aligned} \]

The work integral still takes the same form we found above,

\[ \begin{aligned} W = \int \vec{F} \cdot d\vec{r} = \int F \rho d\phi \\ = F \int_{\pi/4}^{-\pi/4} \frac{d\phi}{\cos \phi} \\ \approx (-1.76\ {\rm m}) F \end{aligned} \]

where I used Mathematica to do the integral numerically - it ends up being a complicated combination of logs and trig functions. I'm just reading the \( \phi \) limits of integration off the plot geometrically, but in general we get them by solving the equation of our line at the given points.

This method will work for even more complicated paths. Here's a more interesting line, \( y = 1 + x/2 \) from \( (0,1) \) to \( (2,2) \):

Now if we substitute in the conversion for both \( x \) and \( y \), the equation for the line becomes

\[ \begin{aligned} \rho \sin \phi = 1 + \frac{1}{2} \rho \cos \phi \\ \rho (2\sin \phi - \cos \phi) = 2 \\ \rho(\phi) = \frac{2}{2\sin \phi - \cos \phi}. \end{aligned} \]

This will be a slightly messier integral over \( \phi \) (feel free to try it for practice!), but there's no change to \( \vec{F} \cdot d\vec{r} \). The moral of these examples is that the force is the most important factor in your choice of coordinate system for a line integral, because we have to deal with the vector components of the force. Once that's out of the way, it's easy to make our path conform to whatever coordinates we've chosen.