Physics[Vectors][int] - extend the int command to also compute path, surface, and volume integrals from the mathematical representation of the region, vectorial, parametric or as a set of expressions relating the coordinates to each other
Calling Sequence
int(F, r_ = A .. B, path = C)
int(F, r_, path = C, parameter = [t = a..b])
int(F, r_ = C, parameter = [t = a..b])
int(F, r_ = A .. B, path = C, kind = crossproduct)
int(F, S_, surface = C, parameters = [u = a..b, v = c..d])
int(F, S_ = C, parameters = [u = a..b, v = c..d])
int(F, S_, parameters = [u = a..b, v = c..d], kind = crossproduct)
int(F, V, volume = C, parameters = [u = a..b, v = c..d, w = c..d])
int(F, V = C, parameters = [u = a..b, v = c..d, w = c..d])
Parameters
F or F_
-
the integrand, can be an algebraic scalar expression F, or a vector function F_ (to represent vector functions see notation)
C
the mathematical formulation for the region of integration; it could be a vector function representation - of a curve, surface, or volume - or an algebraic equation relating the coordinates, or any region's representation as a set or list of such relations, solved or not for the coordinates in terms of parameters.
r_ = A..B
the global symbol r_ (not another symbol), representing the position vector, whose differential dr→ is the line element of the integration path. On the right-hand side A and B represent the initial and final points of the path C of integration and can be omitted when the parameter option is used and includes the parameter's range of integration.
r_ = C
in this case the right-hand side is itself the region of integration C and the argument path = C can be omitted.
S_
the global symbol S_ (not another symbol); dS→ represents the surface element of the surface of integration.
S_ = C
in this case the right-hand side is itself the region of integration C and the argument surface = C can be omitted.
V
the global symbol V (not another symbol); dV represents the volume element of the volume of integration.
V = C
in this case the right-hand side is itself the region of integration C and the argument volume = C can be omitted.
path = C
synonym curve = C, together with using the symbol r_ as integration variable, it indicates that the integral is a 1-dimensional path integral
surface = C
together with using the symbol S_ as integration variable, indicates that the integral is a 2-dimensional surface integral
volume = C
together with using the symbol V as integration variable, indicates that the integral is a 3-dimensional volume integral
kind = crossproduct
indicates that the integrand is the cross product of the vector function F_ (the first argument to int) with the line or surface elements dr→ or dS→
parameters = ...
synonym parameter, optional for line integrals, mandatory for surface and volume integrals, the right-hand side is a list with the parameters and their ranges specifying the region of integration, e.g. in the case of surface integrals [u = a..b, v = c..d]. In the case of path integrals, the right-hand side can also be only the parameter, without its range, provide that the integration limits A and B are given.
inert
optional, when passed it makes int return the integral expressed in terms of the parameters but before performing the integration, as an inert Int function call
Description
The int command of the Vectors package extends the Maple int command to also compute vector integrals; these are path, surface, or volume integrals, where the integrand is a scalar or vector function, and starting from any region's description (algebraic, parametric, vectorial). In the context of the Physics Vectors package, vectors are names that end with the underscore _ and vector functions are functions where the name ends with the underscore _.
There are three kinds of line or path integrals:
∫A→B→F⁢ⅆr→path=C
∫A→B→F→ ·ⅆr→path=C
∫A→B→F→ ×ⅆr→path=C
where A→ and B→ are points in space, the limits of integration, that belong to the curve C over which the integral is performed. In the first integral, F is a scalar function and the result of the integration is thus a vector. In the second and third integrals the integrand F→ is a vector function, so that the dot product F→·dr→ is a scalar and so is the integral, while in the third one F→×dr→ is a vector and so is its integration over the region C.
Likewise, there are three kinds of surface integrals
∫F⁢ⅆS→surface=C,parameters=u=a..b,v=c..d
∫F→ ·ⅆS→surface=C,parameters=u=a..b,v=c..d
∫F→ ×ⅆS→surface=C,parameters=u=a..b,v=c..d
and two types of volume integrals
∫F⁢ⅆVvolume=C,parameters=u=a..b,v=c..d,w=f..g
∫F→⁢ⅆVvolume=C,parameters=u=a..b,v=c..d,w=f..g
The conventions to represent these integrals are those of the standard int Maple command, extended to handle vector integrals as follows:
The first argument - the integrand - can be a scalar function, say F, or a vector function F→, in which case, for line and surface integrals, where the element of integration is also a vector, the integral is understood as the integral of their scalar product e.g. F→·dr→ for line integrals. If the optional argument kind = crossproduct is passed, the integral is understood as the integral of the cross product e.g. F→×dS→ for surface integrals.
The second argument, the integration variable, also indicates the kind of integration - line (path), surface, or volume - by respectively using the global names r_, S_, or V, so that dr→ is a line element, dS→ a surface element and dV a volume element. In the case of path integrals, the second argument can include the range as in r_ = A_ .. B_ where A_ and B_ represent two points in space that belong to the integration curve C.
The region of integration is indicated as region = ... where region is the keyword path or curve for line integrals, and surface and volume for surface and volume integrals. The right-hand side of region = ... specifies the region of integration as a vector function or as an equation relating the coordinates, or as a set or list of them. That specification is used by int to derive parametric equations representing the region using the ParametrizeCurve, ParametrizeSurface, and ParametrizeVolume commands. Alternative ways of specifying the region of integration are discussed in the Examples section.
The parameters and their ranges covering the region of integration, are required in the case of surface and volume integrals. Indicating the parameter, or its range, are both optional in the case of line integrals and, when the range is not passed, the integration limits are required expressed as two points A→ and B→. When these two points are one and the same, it is understood to be a closed path of integration. The parameters can also be indicated as functionality of the coordinates, for example using x⁡t instead of just x when indicating the integration region C.
The limits of integration A→ and B→ in path integrals must be points of the integration path and can be represented using the notation for algebraic vectors of the Vectors package, as a sum of terms where each one is the product of a unit vector times some coefficient, or as a list with the three components of the vector.
You can use a shortcut notation for all of path, surface, and volume integrals, consisting of passing the second argument as an equation having integration variable (r_, S_, or V) on the left-hand side, and the region of integration C on the right-hand side. In those cases, the argument region = C where region is one of path, surface, or volume becomes redundant and can be omitted.
The line element dr→ in path integrals is expressed in terms of a parameter t as
d⁢r→=ⅆⅆtr→⁡t⁢dt
Using indexed notation for derivatives r→u=∂∂ur→⁡u,v, the surface element dS→ in surface integrals is expressed in terms of parameters as
dS→=r→u×r→v⁢du⁢dv
and the volume element dV in volume integrals as
dV=r→u·r→v×r→w⁢du⁢dv⁢dw
Since both dS→ and dV involve a cross product, there is a sign that depends on the ordering of the parameters u,v,w. To have control over that sign, the parameters on the right-hand side of parameters = ... are expected as an ordered list.
The integrals in the three cases are computed by first expressing the integrand and the integration element in terms of the parameters using the parametric equations derived with ParametrizeCurve, ParametrizeSurface, and ParametrizeVolume, then performing the vector product operations, then the integration. Passing the optional argument inert, the last integration step is not performed and a result is returned using the inert function Int.
Examples
with(Physics:-Vectors);
&x,`+`,`.`,Assume,ChangeBasis,ChangeCoordinates,CompactDisplay,Component,Curl,DirectionalDiff,Divergence,Gradient,Identify,Laplacian,∇,Norm,ParametrizeCurve,ParametrizeSurface,ParametrizeVolume,Setup,Simplify,`^`,diff,int
Setup(mathematicalnotation = true);
mathematicalnotation=true
Path integrals
Consider the following scalar function F, path C and integration limits A→ and B→
F := x*y;
F≔x⁢y
C := {y = x^2, z = 0};
C≔y=x2,z=0
A_ := [0, 0, 0];
A→≔0,0,0
B_ := [1, 1, 0];
B→≔1,1,0
The line or path integral, shown here in inert form on the left-hand side and active, computed to the end on the right-hand side, is
(Int = int)(F, r_ = A_ .. B_, path = C);
Note that the output on the right-hand side is a vector. Within int, to perform this integration the curve C=y=x2,z=0 is first parametrized using ParametrizeCurve
ParametrizeCurve(C);
x⁡t=t,y⁡t=t2,z⁡t=0,t
The output above is a sequence, first the parametric equations as an ordered list (order x,y,z) then the parameter, in this case t. For the formulation of the integral to make sense, the limits of integration A→ and B→ must belong to this curve, i.e. satisfy the parametric equations for some value of the parameter, in this case t=0 and t=1
A_ = Eval((8)[1], t = 0);
0,0,0=x⁡t=t,y⁡t=t2,z⁡t=0t=0|x⁡t=t,y⁡t=t2,z⁡t=0t=0
B_ = Eval((8)[1], t = 1);
1,1,0=x⁡t=t,y⁡t=t2,z⁡t=0t=1|x⁡t=t,y⁡t=t2,z⁡t=0t=1
To see the integral after being parametrized and before performing the integration use the option inert
(Int = int)(F, r_ = A_ .. B_, path = C, inert);
Since there is a relation one-to-one between the integration limits A→ and B→ and the parameter's range, instead of indicating A→ and B→ you can also indicate the range of t itself, getting the same result (7)
(Int = int)(F, r_, path = C, parameter = {t = 0..1});
When the parameter's range is passed, you can also use a shortcut notation, passing the second argument as an equation r_ = C, making more explicit that r_ is the vector representation of region of integration, so the line element dr→ is the differential of the parametric equations of C. In this case indicating path = C is redundant and can be omitted.
(Int = int)(F, r_ = C, parameter = {t = 0..1});
The integration path and the limits of integration can be expressed in vector notation as well
C_ := x*_i + x^2*_j;
C→≔x2⁢j∧+x⁢i∧
A_ := 0;
A→≔0
B_ := _i + _j;
B→≔i∧+j∧
(Int = int)(F, r_ = A_ .. B_, path = C_);
The following C represents a circle of radius a on the x,y plane
C := {x^2 + y^2 = a^2, z = 0};
C≔z=0,x2+y2=a2
To perform a path integral over this curve, the curve is first parametrized as
x⁡φ=a⁢cos⁡φ,y⁡φ=a⁢sin⁡φ,z⁡φ=0,φ
Checking the form of the parametrization returned is useful when using the parameter = a..b option to understand what the values of a and b need to be. From the above we see that for φ=0..π2, the limits of integration A→ and B→ are
eval((19)[1], phi = 0);
x⁡0=a,y⁡0=0,z⁡0=0
A_ := a*_i;
A→≔a⁢i∧
eval((19)[1], phi = Pi/2);
x⁡π2=0,y⁡π2=a,z⁡π2=0
B_ := a*_j;
B→≔a⁢j∧
So for the following integrand, we have (in the context of int, the keywords curve and path are synonyms)
F := 1;
F≔1
(Int = int)(F, r_ = A_ .. B_, curve = C);
An example having for integrand a vector function F→, also expressing the path using vector notation
F_ := x^2*_i + y*_j + x*y*z*_k;
F→≔x⁢y⁢z⁢k∧+x2⁢i∧+y⁢j∧
C_ := x*(_i + _j + _k);
C→≔x⁢i∧+j∧+k∧
Integrate over this curve from the origin to the point i∧+j∧+k∧. To represent a point whose three coordinates are equal, you can use a list with three equal values or, as a shortcut notation, use the single value of the three coordinates. So instead of 0,0,0 you can use 0 and instead of 1,1,1 you can use 1
A_, B_ := 0, 1;
A→,B→≔0,1
When the integrand is a vector function, int computes the integral of the dot product F→·dr→ over the given curve, resulting in a scalar value
(Int = int)(F_, r_ = A_ .. B_, path = C_);
To compute the integral of the cross product F→×dr→ use the option kind = crossproduct. In this example, we can see that the value of the parameter t for which the points A→ and B→ satisfy the parametric equations are t=0 and t=1. Knowing those values allows for passing this information directly and omit the integration limits A→ and B→
(Int = int)(F_, r_, path = C_, kind = crossproduct, parameters = {t = 0..1});
The case of a straight line that passes through two given points is special: in addition to handling any mathematical formulation of a line, ParametrizeCurve can also compute the parametric equations directly from the coordinates of those two points. For example
P__1 := 2*_i - 3*_j + 4*_k;
P__1≔2⁢i∧−3⁢j∧+4⁢k∧
P__2 := -4*_i + 2*_j - _k;
P__2≔−4⁢i∧+2⁢j∧−k∧
we have (in the computational context of ParametrizeCurve, line and straightline are synonyms)
ParametrizeCurve(line(P__1, P__2));
x⁡t=2−6⁢t,y⁡t=−3+5⁢t,z⁡t=−5⁢t+4,t
Likewise, int can compute path integrals over a straight line that passes through two points in the same way. Take for instance as integration limits the points that satisfy this line for t=5 and t=−5
A_ := (16*_i)/5 - 4*_j + 5*_k;
A→≔16⁢i∧5−4⁢j∧+5⁢k∧
B_ := -(44*_i)/5 + 6*_j - 5*_k;
B→≔−44⁢i∧5+6⁢j∧−5⁢k∧
(Int = int)(F_, r_ = A_ .. B_, path = line(P__1, P__2), kind = crossproduct);
Consider integrating over a path C that consists of three line segments, say C1,C2,C3, connecting the origin with the point 1,1,1 via 0,0,0⁢→⁢1,0,0⁢→⁢1,1,0⁢→⁢1,1,1, so first a translation along the x axis only, then one along the y axis, then one along the z axis.
One way of performing this computation is to make three calls to int, passing each of the three different paths C1,C2,C3 then add the results. Another way, significantly simpler, is using the path=linesegments⁡.... First one path at a time: the vectorial representations of these paths and the three computations are as follows:
C__1_ := x*_i;
C→1≔x⁢i∧
A_, B_ := 0, _i;
A→,B→≔0,i∧
(Int = int)(F_, r_ = A_ .. B_, path = C__1_);
C__2_ := _i + y*_j;
C→2≔y⁢j∧+i∧
A_, B_ := B_, B_ + _j;
A→,B→≔i∧,i∧+j∧
(Int = int)(F_, r_ = A_ .. B_, path = C__2_);
C__3_ := _i + _j + z*_k;
C→3≔z⁢k∧+i∧+j∧
A_, B_ := B_, B_ + _k;
A→,B→≔i∧+j∧,i∧+j∧+k∧
(Int = int)(F_, r_ = A_ .. B_, path = C__3_);
(39) + (42) + (45);
These three steps can be compacted into one using path=linesegments⁡...
(Int = int)(F_, r_, path = linesegments(0, _i, _i + _j, _i + _j + _k));
Moreover, note that this integral from 0 to 1,1,1=i∧+j∧+k∧ depends on the path of integration. To see that, compute the same integral over the straight line that joins these two points:
(Int = int)(F_, r_, path = linesegment(0, _i + _j + _k));
So 132 instead of 43. The reason for that: the curl of F→ is not zero
(%Curl = Curl)(F_);
∇×x⁢y⁢z⁢k∧+x2⁢i∧+y⁢j∧=x⁢z⁢i∧−y⁢z⁢j∧
therefore, the path integral from A→ to B→ depends on the path. Note as well that when there are only two points, the path=linesegment⁡A→,B→ notation is equivalent to r→=A→..B→,path=line⁡A→,B→ so the integral above can also be expressed as
(Int = int)(F_, r_ = 0.. _i + _j + _k, path = line(0, _i + _j + _k));
Consider the same computation over two different paths in a case where the curl of F→ is equal to zero; take for instance F→ to be equal to the position vector itself
F_ := x * _i + y * _j + z * _k;
F→≔x⁢i∧+y⁢j∧+z⁢k∧
∇×x⁢i∧+y⁢j∧+z⁢k∧=0
Now the integral does not depend on the path:
You can indicate that the line integral is around a closed curve in two different ways: passing the initial and final points (integration limits) A→ and B→ such that A→=B→, or entirely omitting the integration limits and passing a range for the parameter such that the curve is closed. The following represents a circle on the x,y plane
Integrate the vectorial line element dr→ around the whole circle using the two mentioned ways of representing a closed curve. From symmetry considerations, this integral should be equal to 0: we are adding infinitesimal vectorial line elements tangent to the circle around all of it: the contributions of the upper half cancel those of the lower half. Start and finish the integration at the point a,0,0
(Int = int)(1, r_ = A_ .. A_, path = C);
(Int = int)(1, r_, path = C, parameter = {phi = 0..2*Pi});
These are the contributions of the upper half only
(Int = int)(1, r_, path = C, parameter = {phi = 0..Pi});
Take now F→=r→, the position vector, and integrate the cross product F→×dr→ around the circle C: this time, at each point of the circle, F→×dr→ is perpendicular to the plane x,y, in the k∧ direction, so there are no cancellations, everything adds. Here again start and finish the integration at the point a,0,0
(Int = int)(F_, r_ = A_ .. A_, path = C, kind = crossproduct);
(Int = int)(F_, r_, path = C, parameter = {phi = 0..2*Pi}, kind = crossproduct);
Surface and Volume integrals
The case of surface and volume integrals is analogous to that of line (path) integrals, but for two things: instead of one, there are two or three parameters, and instead of indicating integration limits, it is required that you indicate the parameter's ranges.
The following C represents the surface of a sphere of radius a centered at the origin
with(Physics, Assume, CompactDisplay);
Assume,CompactDisplay
Assume(a > 0);
a::0,∞
C__2 := x^2 + y^2 + z^2 = a^2;
C__2≔x2+y2+z2=a2
ParametrizeSurface(C__2);
x⁡θ,φ=a⁢sin⁡θ⁢cos⁡φ,y⁡θ,φ=a⁢sin⁡θ⁢sin⁡φ,z⁡θ,φ=a⁢cos⁡θ,θ,φ
From the definition of the vectorial surface element as
dS→ is a vector perpendicular to the surface of the sphere. Hence, the vectorial surface integral of dS→ over the upper half of the sphere should be a vector perpendicular to the plane x,y in the k∧ direction. Also, checking the form of the parametrization returned by ParametrizeSurface is useful to understand what the ranges for parameters θ and φ need to be to represent the desired region.
(Int = int)(1, S_, surface = C__2, parameters = [theta = 0..Pi/2, phi = 0..2*Pi]);
From symmetry considerations, the integral of dS→ over the lower half of the sphere should have the same magnitude but opposite direction (−k∧), from where the integral over the whole sphere, so for θ=0..π, should be equal to 0
(Int = int)(1, S_, surface = C__2, parameters = [theta = 0..Pi, phi = 0..2*Pi]);
From this example we see that to get the area computing the integral of dS→ over the whole surface it is necessary to take as integrand the modulus of dS→, that is its scalar product with a unit vector parallel to it. By definition of surface element (see the Description) that unit vector is given by
CompactDisplay(r_(theta, phi));
r→⁡θ,φ⁢will now be displayed as⁢r→
n_ := diff(r_(theta, phi), theta) &x diff(r_(theta, phi), phi)/Norm(diff(r_(theta, phi), theta) &x diff(r_(theta, phi), phi));
n→≔r→θ×r→φr→θ×r→φ
where r→ is the vectorial form of the parametric equations of the surface. It is easy to see this vector is the radial unit vector r∧. For that purpose you can use the option output = vector of ParametrizeSurface to get the vectorial form of the parametric equations for C2
ParametrizeSurface(C__2, output = vector);
a⁢sin⁡θ⁢cos⁡φ⁢i∧+a⁢sin⁡θ⁢sin⁡φ⁢j∧+a⁢cos⁡θ⁢k∧,θ,φ
Introduce this value of r→ into the expression for n→ and change basis to spherical
n_ := eval(n_, r_(theta, phi) = (71)[1]);
n→≔2⁢a2⁢sin⁡θ2⁢cos⁡φ⁢i∧+a2⁢sin⁡θ2⁢sin⁡φ⁢j∧+sin⁡2⁢θ⁢a2⁢k∧24⁢a4⁢sin⁡θ4⁢cos⁡φ2+4⁢a4⁢sin⁡θ4⁢sin⁡φ2+a4⁢sin⁡2⁢θ2
n_ := ChangeBasis(n_, spherical);
n→≔r∧
Putting all together, the area of a sphere of radius a is given by this closed surface integral
(Int = int)(n_, S_, surface = C__2, parameters = [theta = 0..Pi, phi = 0..2*Pi]);
You can also use a shortcut notation for surface integrals passing the second argument as an equation S_ = C, making more explicit that S_ is the vector representation of the surface. In this case indicating surface = C is redundant and can be omitted.
(Int = int)(n_, S_ = C__2, parameters = [theta = 0..Pi, phi = 0..2*Pi]);
In the case of the volume of a sphere, an algebraic representation of the region is
C__3 := x^2 + y^2 + z^2 = r^2;
C__3≔x2+y2+z2=r2
from where the volume of a sphere of radius a is equal to the integral of the corresponding dV=r→u·r→v×r→w⁢du⁢dv⁢dw with parameters r=0..a, θ=0..π and φ=0..2⁢π
(Int = int)(1, V, volume = C__3, parameters = [r = 0..a, theta=0..Pi, phi = 0..2*Pi]);
Using ParametrizeVolume one can also see that the vectorial representation of this region is just the position vector r→ written in spherical coordinates and basis
ParametrizeVolume(C__3, basis = spherical, output = vector);
r⁢r∧,r,θ,φ
so one can use this simpler vectorial representation of the sphere as well
(Int = int)(1, V, volume = r*_r, parameters = [r = 0..a, theta=0..Pi, phi = 0..2*Pi]);
You can also use a shortcut notation for volume integrals passing the second argument as an equation V = C, making more explicit that V is the specified volume of integration C. In this case indicating volume = C is redundant and can be omitted.
(Int = int)(1, V = r*_r, parameters = [r = 0..a, theta=0..Pi, phi = 0..2*Pi]);
See Also
ChangeBasis, ChangeCoordinates, convert,VectorCalculus, Identify, int, notation, operations, ParametrizeCurve, ParametrizeSurface, ParametrizeVolume, Physics, Physics conventions, Physics examples, Physics Updates, Tensors - a complete guide, Mini-Course Computer Algebra for Physicists, Physics[Vectors], Setup, standard int, VectorCalculus:-int
Compatibility
The Physics[Vectors][int] command was introduced in Maple 2022.
For more information on Maple 2022 changes, see Updates in Maple 2022.
Download Help Document