Line Integrals

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.
In[1]:=
Clear[f,r]
f[x_,y_]:={2 x y,x^3}
r[t_]:={Cos[t],Sin[t]}
In[2]:=
D[r[t],t]
Out[2]=
{-Sin[t], Cos[t]}
In[3]:=
arc=ParametricPlot[r[t],{t,0,Pi},AspectRatio->Automatic];

In[4]:=
f[r[t][[1]],r[t][[2]]].D[r[t],t]
Out[4]=
4 2
Cos[t] - 2 Cos[t] Sin[t]
In[5]:=
Integrate[f[r[t][[1]],r[t][[2]]].D[r[t],t],{t,0,Pi}]
Out[5]=
3 Pi ---- 8
It should be clear that if you follow the curve backwards, the integral is the negative of the integral following the curve forwards.
In[6]:=
Integrate[f[r[t][[1]],r[t][[2]]].D[r[t],t],{t,Pi,0}]
Out[6]=
-3 Pi
-----
8
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".
In[7]:=
r2[t_]:={t,0}
bottomline=ParametricPlot[r2[t],{t,-1,1},
PlotStyle->{RGBColor[1,0,0]}];

In[8]:=
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.
In[9]:=
f[r2[t][[1]],r2[t][[2]]].D[r2[t],t]
Out[9]=
0
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.
In[10]:=
Clear[f,r]
f[x_,y_,z_]:={1,-y,x y z}
r[t_]:={t,-t^2,t}
In[11]:=
Integrate[f[r[t][[1]],r[t][[2]],r[t][[3]]].D[r[t],t],{t,0,1}]
Out[11]=
3 -- 10
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)).
In[12]:=
f[x_,y_]:=x^2 y
In[13]:=
r[t_]:={3 Cos[t],3 Sin[t]}
The integral of f ds from 0 to Pi is: (let's go step by step)
In[14]:=
f[r[t][[1]],r[t][[2]]]
Out[14]=
2
27 Cos[t] Sin[t]
In[15]:=
norm[D[r[t],t]]
Out[15]=
2 2
Sqrt[9 Cos[t] + 9 Sin[t] ]
In[16]:=
Simplify[%]
Out[16]=
3
In[17]:=
fds=3 f[r[t][[1]],r[t][[2]]]
Out[17]=
2
81 Cos[t] Sin[t]
In[18]:=
Integrate[81 Cos[t]^2 Sin[t],{t,0,Pi}]
Out[18]=
54
We can do this all at once, of course.
In[19]:=
Integrate[f[r[t][[1]],r[t][[2]]]*norm[D[r[t],t]],
{t,0,Pi}]
Out[19]=
54
Up to Vector Integral Calculus