Line Integrals

Recall from basic calculus that if a force f(x) acts from x=a to x=b the work done is the integral from a to b of f(x). If the work is done along a path, say along C, this brings us to the concept of line integral. Break up the curve into small pieces ds and let the force act on these pieces. The total work done is the Integral along the length of the curve of the work on each piece. The component of a force which does the work is the one which acts along the curve, (in physics, the tangential component) so we can write this as f.t ds where t is the unit vector tangent to the curve. But wait! We learned that t comes from the derivative: t is really r'(t)/||r'(t)||. Also, we saw that ds = ||r'(t)|| dt. This implies f.t ds=f.r'(t) dt. So, finally, the line integral is: Integrate f(r(t)).dr, where dr=r'(t)dt.

Note that Integral ds is Integral ||r'(t)|| dt which is arc length.

Another way of writing this is if f={f1,f2,f3} (or f1 i + f2 j +f3 k), and if we write x'(t)dt as dx, y'(t)dt as dy and z'(t)dt as dz, then we can write Integal of f(r).dr as
Integral of f1dx + f2dy + f3dz.

Let's try f(x,y)=2xy i+x^3 j on an upper semicircular path with radius 1.


  Clear[f,r]
  f[x_,y_]:={2 x y,x^3}
  r[t_]:={Cos[t],Sin[t]}


  D[r[t],t]


  arc=ParametricPlot[r[t],{t,0,Pi},AspectRatio->Automatic];


  f[r[t][[1]],r[t][[2]]].D[r[t],t]


  Integrate[f[r[t][[1]],r[t][[2]]].D[r[t],t],{t,0,Pi}]

It should be clear that if you follow the curve backwards, the integral is the negative of the integral following the curve forwards.


  Integrate[f[r[t][[1]],r[t][[2]]].D[r[t],t],{t,Pi,0}]

If your curve is made up of two or more curves pieced together, simply do each piece separately and add them up. Let's try the semicircle along with the "bottom line".


  r2[t_]:={t,0}
  bottomline=ParametricPlot[r2[t],{t,-1,1},
  PlotStyle->{RGBColor[1,0,0]}];


  Show[arc,bottomline];

Be careful. When integrating around this curve, we follow the semicircle counterclockwise (t from 0 to Pi) and the bottom line from -1 to 1.


  f[r2[t][[1]],r2[t][[2]]].D[r2[t],t]

Well, that certainly makes life easy. The line integral along r2 contributes nothing, so the line integral around arc+bottomline is the same as the line integral around arc.

Flow along a curve and work are two different physical ideas but they are represented by the same thing: the line integral. We will see more on flow in the coming sections.

This works the same way in three dimensions.


  Clear[f,r]
  f[x_,y_,z_]:={1,-y,x y z}
  r[t_]:={t,-t^2,t}


  Integrate[f[r[t][[1]],r[t][[2]],r[t][[3]]].D[r[t],t],{t,0,1}]

There is such a thing as a line integral with respect to arc length,
Integratal of f ds. Since we know that ds=||r'(t)|| dt, this can be computed using
Integral of f(x(t),y(t),z(t)) ||r'(t)|| dt.

Try one. Here r(t)=(x(t), y(t)).


  f[x_,y_]:=x^2 y 


  r[t_]:={3 Cos[t],3 Sin[t]}

The integral of f ds from 0 to Pi is: (let's go step by step)


  f[r[t][[1]],r[t][[2]]]


  norm[D[r[t],t]]


  Simplify[%]


  fds=3 f[r[t][[1]],r[t][[2]]]


  Integrate[81 Cos[t]^2 Sin[t],{t,0,Pi}]

We can do this all at once, of course.


  Integrate[f[r[t][[1]],r[t][[2]]]*norm[D[r[t],t]],
     {t,0,Pi}]

Up to Vector Integral Calculus