Wolfram Language Fast Introduction for Math Students
Get Started »

Vector Analysis & Visualization

In the Wolfram Language, n-dimensional vectors are represented by lists of length n.

Calculate the dot product of two vectors:

In[1]:=
Click for copyable input
{1, 2, 3}.{a, b, c}
Out[1]=

Type ESCcrossESC for the cross product symbol:

In[2]:=
Click for copyable input
{1, 2, c}\[Cross]{a, b, c}
Out[2]=

Calculate a vector’s norm:

In[1]:=
Click for copyable input
Norm[{1, 1, 1}]
Out[1]=

Find the projection of a vector onto the x axis:

In[2]:=
Click for copyable input
Projection[{8, 6, 7}, {1, 0, 0}]
Out[2]=

Find the angle between two vectors:

In[3]:=
Click for copyable input
VectorAngle[{1, 0}, {0, 1}]
Out[3]=

Calculate the gradient of a vector:

(For the symbol, use ESCgradESC.)
In[1]:=
Click for copyable input
\!\(
\*SubscriptBox[\(\[Del]\), \({x, y}\)]\({
\*SuperscriptBox[\(x\), \(2\)] + y, x + 
\*SuperscriptBox[\(y\), \(2\)]}\)\)
Out[1]=

Compute the divergence or curl of a vector field:

In[2]:=
Click for copyable input
Div[{f[x, y, z], g[x, y, z], h[x, y, z]}, {x, y, z}]
Out[2]=

The Wolfram Language has 2D and 3D functions suitable for visualizing vector fields:

In[1]:=
Click for copyable input
VectorPlot[{y, -x}, {x, -3, 3}, {y, -3, 3}]
Out[1]=
In[2]:=
Click for copyable input
VectorPlot3D[{y, -x, z}, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}]
Out[2]=

Plot a vector field over a slice surface:

In[3]:=
Click for copyable input
SliceVectorPlot3D[{y, -x, z}, "CenterPlanes", {x, -2, 2}, {y, -2, 
  2}, {z, -2, 2}]
Out[3]=

QUICK REFERENCE: Vector Analysis »

QUICK REFERENCE: Vector Visualization »