linalg::divergence --
divergence of a vector field
Introductionlinalg::divergence(v, x ...) computes the
divergence of the vector field v with respect to
x in Cartesian coordinates. This is the sum div(v) =
sum(diff(v,x[i]),i=1..n.
Call(s)linalg::divergence(v, x)
linalg::divergence(v, x, ogCoord)
Parametersv |
- | a list of arithmetical expressions, or a vector (i.e.,
an n x 1 or 1 x n matrix of a domain of category
Cat::Matrix) |
x |
- | a list of (indexed) identifiers |
ogCoord |
- | a list, or a name (identifier) of a predefined coordinate system |
Returnsan arithmetical expression, or an element of the component ring of
v.
Related
Functionslinalg::curl, linalg::grad, linalg::ogCoordTab
Detailslinalg::divergence(v, x, ogCoord) computes
the divergence of the vector field v with respect to
x in the orthogonally curvilinear coordinate system. The
scaling factors of the specified coordinate system must be the value of
the index ogCoord of the table linalg::ogCoordTab (see example
2).ogCoord is given as a list then the divergence of
v is computed in the orthogonal curvilinear coordinates,
whose scaling factors are given in ogCoord (see example 3).v is a vector then the component ring of
v must be a field (i.e., a domain of category Cat::Field) for which
differentiation with respect to x is defined.
Example
1We compute the divergence of the vector field v((x,y,z)=(x^2, 2y, z) in Cartesian coordinates:
>> delete x, y, z: v := matrix([x^2, 2*y, z])
+- -+
| 2 |
| x |
| |
| 2 y |
| |
| z |
+- -+
>> linalg::divergence(v, [x, y, z])
2 x + 3
Example
2We compute the divergence of the vector field v(r,phi,z)=(r,cos(phi),z) (0<=phi<=2*PI) in cylindrical coordinates:
>> delete r, phi, z: linalg::divergence([r, sin(phi), z], [r, phi, z], Cylindrical)
3 r + cos(phi)
--------------
r
The following relations between Cartesian and cylindrical coordinates hold:
x=r*cos(phi), y=r*sin(phi), z=z.
Other predefined orthogonal coordinate systems can be found in the
table linalg::ogCoordTab.
Example
3We want to compute the divergence of the vector field v(r,theta,phi)=(r^2,0,0) (0<=theta<=PI, 0<=phi<=2*PI) in spherical coordinates.
The vectors
e_r = [sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta)],
e_theta = [cos(theta)*cos(phi), cos(theta)*sin(phi),-sin(theta)],
e_phi = [-sin(phi), cos(phi), 0],
form an orthogonal system in spherical coordinates.
The scaling factors of the corresponding coordinate transformation
(see linalg::ogCoordTab) are:
g1=|e_r|=1, g2=|e_theta|=r, g3=|e_phi|=r*sin(theta), which
we use in the following example to compute the divergence of the above
vector field in spherical coordinates:
>> delete r, theta, phi:
linalg::divergence(
[r^2, 0, 0], [r, theta, phi], [1, r, r*sin(theta)]
)
4 r
Note that the spherical coordinates are already defined
in linalg::ogCoordTab, i.e., the
last result can also be achieved with the input
linalg::divergence([r^2, 0, 0], [r, theta, phi],
Spherical).