# Vector Analysis

Vector analysis forms the basis of many physical and mathematical models. The Wolfram Language can compute the basic operations of gradient, divergence, curl, and Laplacian in a variety of coordinate systems. Moreover, these operators are implemented in a quite general form, allowing them to be used in different dimensions and with higher-rank tensors.

## Vector Analysis in Cartesian Coordinates

### Vector Derivatives

The four basic vector derivatives are shown in the following table.

 Grad[f,{x1,…,xn}] gradient of a scalar function Div[{f1,…,fn},{x1,…,xn}] divergence of a vector-valued function Curl[{f1,…,fn},{x1,…,xn}] curl of a vector-valued function Laplacian[f,{x1,…,xn}] Laplacian of a scalar function

Classical vector derivative operators in Cartesian coordinates.

Although these operators are available in any dimension, they are most commonly encountered in three dimensions.

This gives the gradient in three dimensions.
 In[1]:=
 Out[1]=
Compute a three-dimensional divergence.
 In[2]:=
 Out[2]=
The curl in three dimensions returns a vector.
 In[3]:=
 Out[3]=
This gives the Laplacian in three-dimensional space.
 In[4]:=
 Out[4]=

The following examples explore these operators in dimensions other than three.

 In[5]:=
 Out[5]=
The divergence of a vector is a scalar in any dimension.
 In[6]:=
 Out[6]=
Compute a five-dimensional Laplacian.
 In[7]:=
 Out[7]=
The curl is not restricted to three dimensions. This gives a two-dimensional curl, which is a scalar.
 In[8]:=
 Out[8]=
More generally, the curl of a vector in dimension is a completely antisymmetric tensor of rank .
 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=

The meaning of the curl in dimensions other than three is discussed more fully in the next subsection.

### Generalization to Higher-Rank Tensors

All four operators introduced in the previous subsection are general operators that can take vectors and higher-rank tensors as input. For Curl in dimension , the input can be a scalar, vector, or tensor of rank up to . For the other functions, the allowed rank of input tensors is unlimited.

The gradient of a vector is a rank-2 tensor. Each additional gradient raises the rank by one.
 In[11]:=
 Out[11]=
 In[12]:=
 Out[12]=
The divergence is a gradient followed by contraction of the last two slots. It therefore reduces the rank by 1.
 In[13]:=
 Out[13]=
 In[14]:=
 Out[14]=
It is possible to take the divergence in a slot other than the final one by using TensorContract.
 In[15]:=
 Out[15]=
The Laplacian preserves rank, so the Laplacian of a vector is another vector.
 In[16]:=
 Out[16]=
In dimension , the curl of tensor of rank is a tensor of rank .
 In[17]:=
 Out[17]=
 In[18]:=
 Out[18]=
 In[19]:=
 Out[19]=
The reason for this behavior is that the curl is the Hodge dual of the anti-symmetrized gradient. This explains the restriction on rank.
 In[20]:=
 Out[20]=
 In[21]:=
 Out[21]=
 In[22]:=
 Out[22]=

## Vector Analysis in Non-Cartesian Coordinates

### Known Coordinate Charts

The Wolfram Language contains information about a large number of coordinate charts. The function CoordinateChartData provides a mechanism for retrieving this information.

 CoordinateChartData[{"coordsys",n}] standard name for -dimensional Euclidean chart CoordinateChartData[{All,n}] available coordinate charts in -dimensional Euclidean space CoordinateChartData[{All,All,n}] available coordinate charts in -dimensional space CoordinateChartData[chart,"prop"] property "prop" for the specified coordinate chart CoordinateChartData[chart,"prop",pt] property "prop" for the specified coordinate chart at the point pt

The following examples show how to look up available coordinate charts. In their most general form, coordinate chart specifications contain a coordinate system name, a metric, and a dimension. Note that many charts require parameters. These can be specified or left at the shown defaults.

This gives the Wolfram Language standard name for three-dimensional Cartesian coordinates.
 In[23]:=
 Out[23]=
Prolate spheroidal coordinates take a parameter, the half-focal length.
 In[24]:=
 Out[24]=
The parameters can be specified in the input.
 In[25]:=
 Out[25]=
When multiple parameters are specified, they should be enclosed in a list.
 In[26]:=
 Out[26]=
These are the available coordinate charts in two-dimensional Euclidean space.
 In[27]:=
 Out[27]=
The previous input is equivalent to the following, more explicit, input.
 In[28]:=
 Out[28]=
Replacing the metric "Euclidean" with the symbol All includes non-Euclidean coordinate charts.
 In[29]:=
 Out[29]=

Although the coordinate chart standard names are quite long, it is typically possible to omit "Euclidean" and the dimension when using Euclidean coordinate charts.

CoordinateChartData contains many properties regarding the different coordinate charts. The most fundamental is the metric, which ultimately determines all lengths and volumes in the coordinate chart. However, in the context of vector analysis in orthogonal coordinates, it is more common to consider the scale factors and volume factor.

This retrieves the metric for polar coordinates at the point .
 In[30]:=
 Out[30]=
For a diagonal metric, the scale factors are the square roots of the diagonal entries.
 In[31]:=
 Out[31]=
The volume factor is the square root of the determinant of the metric.
 In[32]:=
 Out[32]=
This gives the scale factors for elliptic coordinates along a curve . Notice that the default parameter has been used.
 In[33]:=
 In[34]:=
 Out[34]=
The scale factors relate the coordinate velocity to the physical velocity.
 In[35]:=
 Out[35]=
The physical speed is then the norm of the velocity. This could also have been obtained directly from the metric and coordinate velocity.
 In[36]:=
 Out[36]=
 In[37]:=
 Out[37]=
This gives the volume factor in bipolar coordinates with the parameter set to 1. Notice that a double list is needed to ensure that 1 is treated as a parameter instead of a dimension.
 In[38]:=
 Out[38]=
For a diagonal metric, the volume factor is the product of the scale factors.
 In[39]:=
 Out[39]=
This gives the physical area of a coordinate annulus in bipolar coordinates.
 In[40]:=
 Out[40]=
All available properties can be discovered using the following syntax.
 In[41]:=
 Out[41]=

### Vector Derivatives in Non-Cartesian Coordinates

The four vector derivative operators work in any coordinate chart. It is only necessary to specify the chart in the third argument of the function.

 Grad[f,{x1,…,xn},chart] gradient in the specified coordinate chart Div[{f1,…,fn},{x1,…,xn},chart] divergence in the specified coordinate chart Curl[{f1,…,fn},{x1,…,xn},chart] curl in the specified coordinate chart Laplacian[f,{x1,…,xn},chart] Laplacian in the specified coordinate chart

Vector analysis operators in non-Cartesian coordinates.

Arrays are treated in these commands as components in the orthonormal basis. This applies to both input and output. As a result, the physical dot product can be computed using Dot.

In an orthogonal coordinate system, the gradient of a scalar equals the partial derivatives divided by the scale factors.
 In[42]:=
 Out[42]=
 In[43]:=
 Out[43]=
The gradient of vectors and higher-rank tensors introduces connection terms to the result, meaning it is not simply the gradient of each component.
 In[44]:=
 Out[44]=
 In[45]:=
 Out[45]=
Since the divergence only applies to vectors and tensors, it always has connection terms. However, since arrays are treated as being in the orthonormal basis, the divergence is still a gradient followed by a contraction.
 In[46]:=
 Out[46]=
 In[47]:=
 Out[47]=
Because of the connection terms, the divergence of a rank-2 tensor is not simply the divergence of each row.
 In[48]:=
 Out[48]=
 In[49]:=
 Out[49]=
By definition, the Laplacian is the divergence of the gradient. As a result, the Laplacian has connection terms in non-Cartesian coordinates as well.
 In[50]:=
 Out[50]=
 In[51]:=
 Out[51]=
This means the vector Laplacian is not simply the Laplacian of each component.
 In[52]:=
 Out[52]=
 In[53]:=
 Out[53]=
When acting on vectors and higher-rank tensors, the curl also contains connection terms.
 In[54]:=
 Out[54]=
When acting on scalars, there are no connection terms, but the normalization from the scale factors does appear in the result.
 In[55]:=
 Out[55]=

### Classical Definitions

As seen above, the gradient of a scalar in orthogonal coordinates involves the partial derivatives and the scale factors. There are similar definitions for the divergence of a vector, the Laplacian of a scalar, and the curl of a vector in terms of the scale factors and volume factor.

The gradient in an orthogonal chart is related to the gradient in Cartesian coordinates by the scale factors.
 In[56]:=
 Out[56]=
 In[57]:=
 Out[57]=
 In[58]:=
 Out[58]=
In an orthogonal coordinate system, the classical formula for the divergence of a vector relates it to the divergence in Cartesian coordinates using the scale factors and volume factor.
 In[59]:=
 Out[59]=
 In[60]:=
 Out[60]=
 In[61]:=
 Out[61]=
 In[62]:=
 Out[62]=
Combining the classical formula for divergence with the definition of the gradient of a scalar in an orthogonal system produces a classical formula for the Laplacian.
 In[63]:=
 Out[63]=
 In[64]:=
 Out[64]=
 In[65]:=
 Out[65]=
 In[66]:=
 Out[66]=
The following illustrates a similar formula for the three-dimensional curl of a vector. To generalize to dimension , replace the leading scales with the TensorProduct of copies of scales.
 In[67]:=
 Out[67]=
 In[68]:=
 Out[68]=
 In[69]:=
 Out[69]=
 In[70]:=
 Out[70]=