Vector Field Plotter — Theory
1. What is a vector field?
A vector field assigns a vector to every point in a region. In two dimensions, a vector field has the form
\[
\mathbf F(x,y)=\langle P(x,y),Q(x,y)\rangle.
\]
In three dimensions, a vector field has the form
\[
\mathbf F(x,y,z)=\langle P(x,y,z),Q(x,y,z),R(x,y,z)\rangle.
\]
Each arrow in the plot shows the direction and strength of the field at one point.
2. Vector magnitude
The magnitude of a vector field tells how strong the field is at a point.
\[
\left\|\mathbf F\right\|
=
\sqrt{P^2+Q^2}
\]
for a two-dimensional field, and
\[
\left\|\mathbf F\right\|
=
\sqrt{P^2+Q^2+R^2}
\]
for a three-dimensional field.
3. Flow lines
A flow line is a curve that follows the vector field. If the position vector is
\(\mathbf r(t)\), then a flow line satisfies
\[
\frac{d\mathbf r}{dt}=\mathbf F(\mathbf r(t)).
\]
In two dimensions, this means
\[
\frac{dx}{dt}=P(x,y),
\qquad
\frac{dy}{dt}=Q(x,y).
\]
Flow lines help show the motion suggested by the vector field.
4. Divergence in 2D
For a two-dimensional field
\[
\mathbf F(x,y)=\langle P(x,y),Q(x,y)\rangle,
\]
the divergence is
\[
\nabla\cdot\mathbf F
=
\frac{\partial P}{\partial x}
+
\frac{\partial Q}{\partial y}.
\]
Positive divergence suggests source-like behavior. Negative divergence suggests sink-like behavior.
5. Divergence in 3D
For a three-dimensional field
\[
\mathbf F(x,y,z)=\langle P,Q,R\rangle,
\]
the divergence is
\[
\nabla\cdot\mathbf F
=
\frac{\partial P}{\partial x}
+
\frac{\partial Q}{\partial y}
+
\frac{\partial R}{\partial z}.
\]
6. Curl in 2D
A two-dimensional vector field can rotate in the plane. The important curl value is the
\(z\)-component:
\[
\operatorname{curl}_z \mathbf F
=
\frac{\partial Q}{\partial x}
-
\frac{\partial P}{\partial y}.
\]
If this value is positive, the local rotation is counterclockwise. If it is negative,
the local rotation is clockwise.
7. Curl in 3D
In three dimensions, curl is a vector:
\[
\nabla\times\mathbf F
=
\left\langle
R_y-Q_z,\,
P_z-R_x,\,
Q_x-P_y
\right\rangle.
\]
The direction of curl gives the axis of local rotation, and the magnitude gives the rotation strength.
8. Example: rotational field
Consider the field
\[
\mathbf F(x,y)=\langle -y,x\rangle.
\]
Here,
\[
P=-y,
\qquad
Q=x.
\]
The divergence is
\[
\nabla\cdot\mathbf F
=
P_x+Q_y
=
0+0
=
0.
\]
So the field is not acting like a source or sink.
9. Curl of the rotational field
The two-dimensional curl is
\[
\operatorname{curl}_z \mathbf F
=
Q_x-P_y.
\]
Since
\[
Q_x=1,
\qquad
P_y=-1,
\]
we get
\[
\operatorname{curl}_z \mathbf F
=
1-(-1)
=
2.
\]
This confirms that \(\mathbf F=\langle -y,x\rangle\) is a rotational field.
10. Source and sink examples
The field
\[
\mathbf F(x,y)=\langle x,y\rangle
\]
points outward from the origin. Its divergence is
\[
\nabla\cdot\mathbf F
=
1+1
=
2.
\]
This is a source-like field.
The field
\[
\mathbf F(x,y)=\langle -x,-y\rangle
\]
points inward toward the origin. Its divergence is
\[
\nabla\cdot\mathbf F
=
-1+(-1)
=
-2.
\]
This is a sink-like field.
12. Common mistakes
- Confusing vectors with points: a vector field assigns an arrow to each point.
- Forgetting signs in curl: in 2D, curl is \(Q_x-P_y\), not \(P_y-Q_x\).
- Confusing divergence with curl: divergence measures source/sink behavior, while curl measures rotation.
- Using unnormalized arrows only: very large vectors can hide direction patterns unless normalization is used.
- Overreading 3D projections: a 3D plot is projected onto the screen, so rotation helps reveal depth.