Line Integrals of Vector Fields
Using Maple and the vec_calc Package
This worksheet shows how to compute line integrals of vector fields using Maple and the vec_calc package. As examples we compute
* The Work Done by an Electric Field
* The Circulation of a Fluid
To start the vec_calc package, execute the following commands:
> restart;
> libname:=libname,"C:/mylib/vec_calc7":
> with(vec_calc): vc_aliases:
> with(linalg):with(student):with(plots):
Warning, the protected names norm and trace have been redefined and unprotected
Warning, the name changecoords has been redefined
The Work Done by an Electric Field
The electric field of a line of charge with charge density is where is a constant. A particle of charge moves through this field along the line segment from to . We want to find the work done by this electric field on the charged particle.
We input the field as the function:
> E:=MF([x,y,z],[2*k*lambda*x/sqrt(x^2+y^2),2*k*lambda*y/sqrt(x^2+y^2),0]);
We input the line segment as
> r:=MF(t, evall([1,2,3]+t*([3,2,1]-[1,2,3])));
where . So the velocity is
> v:=D(r);
On the line segment, the electric field is
> Er:=E(op(r(t)));
The work is defined as = . Consequently,
> qEv:=q*Er &. v(t);
> Work:=Int(qEv,t=0..1); Work:=value(%);
Another way to compute this line integral is to use the Line_int_vector command (or its alias Liv ) from the vec_calc package which works directly with the parametrized curve and the vector field:
> Liv(E,r,t=0..1); Work:=q*value(%);
There is a second way to compute this work. The electric field is conservative because it is curl-free:
> CURL(E);
So the electric field has a scalar potential, .
> POT(E,'phi');
> phi(x,y,z);
By the Fundamental Theorem of Calculus, the work is the change in the potential energy:
> Work:=q*phi(3,2,1)-q*phi(1,2,3);
>
The Circulation of a Fluid
The velocity of the water in a sink going down the drain is . We want to find the circulation of the fluid counterclockwise around the circle with .
We enter the fluid velocity as a function:
> V:=MF([x,y,z],[(-y-z)/(x^2+y^2), (x-z)/(x^2+y^2), z^2*(-x-y)/((x^2+y^2)^2)]);
The circle may be parametrized as
> r:=MF(t,[2*cos(t),2*sin(t),3]);
Its tangent vector (velocity) is:
Caution: Don't confuse the velocity (tangent vector) of the curve with the velocity of the fluid .
On the curve, the fluid velocity becomes:
> V(op(r(t))); Vr:=simplify(%);
The circulation is defined as = . Consequently,
> Vr_v:=Vr &. v(t);
> Circ:=Int(Vr_v,t=0..2*Pi); Circ:=value(%);
> Liv(V,r,t=0..2*Pi); Circ:=value(%);