Gradient, Divergence, and Curl Calculator

Enter a scalar or vector field in 2D or 3D and instantly compute its gradient, divergence, and curl with symbolic formulas and numeric evaluation at a point.

Vector calculus Step-by-step 2D & 3D

Interactive Vector Calculus Tool

Use ^ for powers, sin(), cos(), exp(), ln(), etc. Variables: x, y, z.

Leave blank to skip numeric evaluation.

Results

Enter a field and click “Compute” to see gradient, divergence, and curl. Results will appear here with both symbolic expressions and numeric values at the chosen point.

Gradient, divergence, and curl: definitions

Gradient, divergence, and curl are the three core differential operators in vector calculus. They describe how scalar and vector fields change in space.

Gradient of a scalar field

For a scalar field \( f(x,y,z) \), the gradient is a vector field defined by

\[ \nabla f = \left( \frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}, \frac{\partial f}{\partial z} \right). \]
  • \(\nabla f\) points in the direction of steepest increase of \(f\).
  • \(\|\nabla f\|\) is the maximum rate of change of \(f\) at that point.
  • Level surfaces \(f(x,y,z)=\text{const}\) are always orthogonal to \(\nabla f\).

Divergence of a vector field

For a vector field \( \mathbf{F}(x,y,z) = (F_1, F_2, F_3) \), the divergence is a scalar field

\[ \nabla \cdot \mathbf{F} = \frac{\partial F_1}{\partial x} + \frac{\partial F_2}{\partial y} + \frac{\partial F_3}{\partial z}. \]
  • Physically, divergence measures net outflow per unit volume at a point.
  • \(\nabla \cdot \mathbf{F} > 0\): the point behaves like a source.
  • \(\nabla \cdot \mathbf{F} < 0\): the point behaves like a sink.
  • \(\nabla \cdot \mathbf{F} = 0\): the field is divergence-free (locally volume-preserving), e.g. incompressible fluid flow or magnetic fields.

Curl of a vector field

For a vector field \( \mathbf{F}(x,y,z) = (F_1, F_2, F_3) \), the curl is another vector field

\[ \nabla \times \mathbf{F} = \left( \frac{\partial F_3}{\partial y} - \frac{\partial F_2}{\partial z}, \frac{\partial F_1}{\partial z} - \frac{\partial F_3}{\partial x}, \frac{\partial F_2}{\partial x} - \frac{\partial F_1}{\partial y} \right). \]
  • Curl measures the local rotation or “swirl” of the vector field.
  • The direction of \(\nabla \times \mathbf{F}\) is the axis of rotation (right-hand rule).
  • The magnitude \(\|\nabla \times \mathbf{F}\|\) is proportional to the angular speed of that rotation.
  • If \(\nabla \times \mathbf{F} = \mathbf{0}\), the field is called irrotational.

2D vs 3D formulas

In 2D, we usually work with variables \(x, y\) and treat the field as living in the plane.

2D gradient

\[ f(x,y) \quad\Rightarrow\quad \nabla f = \left( \frac{\partial f}{\partial x}, \frac{\partial f}{\partial y} ). \]

2D divergence

\[ \mathbf{F}(x,y) = (P(x,y), Q(x,y)) \quad\Rightarrow\quad \nabla \cdot \mathbf{F} = \frac{\partial P}{\partial x} + \frac{\partial Q}{\partial y}. \]

2D curl (scalar “out of plane”)

In 2D, the curl of a planar vector field is a scalar representing the component of the 3D curl in the \(z\)-direction:

\[ \mathbf{F}(x,y) = (P(x,y), Q(x,y)) \quad\Rightarrow\quad \text{curl}_z(\mathbf{F}) = \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}. \]

This scalar is often interpreted as the vorticity perpendicular to the plane.

Worked examples

Example 1: Gradient of a quadratic potential

Let \( f(x,y,z) = x^2 + y^2 + z^2 \). Then

\[ \frac{\partial f}{\partial x} = 2x,\quad \frac{\partial f}{\partial y} = 2y,\quad \frac{\partial f}{\partial z} = 2z, \] \[ \nabla f = (2x, 2y, 2z). \]

At the point \((1,2,3)\),

\[ \nabla f(1,2,3) = (2, 4, 6). \]

The gradient points radially outward and grows linearly with distance from the origin.

Example 2: Divergence and curl of a radial field

Consider the vector field \( \mathbf{F}(x,y,z) = (x, y, z) \).

Divergence:

\[ \nabla \cdot \mathbf{F} = \frac{\partial x}{\partial x} + \frac{\partial y}{\partial y} + \frac{\partial z}{\partial z} = 1 + 1 + 1 = 3. \]

The divergence is constant and positive: the field behaves like a uniform source everywhere.

Curl:

\[ \nabla \times \mathbf{F} = \left( \frac{\partial z}{\partial y} - \frac{\partial y}{\partial z}, \frac{\partial x}{\partial z} - \frac{\partial z}{\partial x}, \frac{\partial y}{\partial x} - \frac{\partial x}{\partial y} \right) = (0 - 0,\; 0 - 0,\; 0 - 0) = (0,0,0). \]

The field has zero curl: it has no local rotation, only radial expansion.

Example 3: Pure rotation field

Take the 2D vector field \( \mathbf{F}(x,y) = (-y, x) \), which represents rotation around the origin.

Divergence:

\[ \nabla \cdot \mathbf{F} = \frac{\partial (-y)}{\partial x} + \frac{\partial x}{\partial y} = 0 + 0 = 0. \]

There are no sources or sinks: the flow is incompressible.

2D curl (out-of-plane component):

\[ \text{curl}_z(\mathbf{F}) = \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y} = \frac{\partial x}{\partial x} - \frac{\partial (-y)}{\partial y} = 1 - (-1) = 2. \]

The curl is a positive constant, indicating uniform counterclockwise rotation.

Key vector calculus identities

Some important identities involving gradient, divergence, and curl:

  • Gradient of a scalar multiple: \(\nabla (af) = a \nabla f\) for constant \(a\).
  • Divergence of a gradient (Laplacian): \(\nabla \cdot (\nabla f) = \nabla^2 f\).
  • Curl of a gradient: \(\nabla \times (\nabla f) = \mathbf{0}\) (gradients are irrotational).
  • Divergence of a curl: \(\nabla \cdot (\nabla \times \mathbf{F}) = 0\) (curls are divergence-free).

These identities underpin many results in physics, such as Maxwell’s equations in electromagnetism and the Navier–Stokes equations in fluid dynamics.

FAQ

How do I enter functions in this calculator?

Use standard programming-style syntax:

  • Powers: x^2, y^3, (x^2 + y^2)^(1/2)
  • Functions: sin(x), cos(y), tan(z), exp(x*y), ln(x), sqrt(x^2 + y^2)
  • Constants: pi, e

When should I use gradient vs divergence vs curl?

  • Use the gradient when you have a scalar field (e.g. temperature, potential) and want the direction and rate of steepest change.
  • Use divergence when you have a vector field (e.g. fluid velocity, electric field) and want to detect sources and sinks.
  • Use curl when you have a vector field and want to measure local rotation or vorticity.

What is the Laplacian and how is it related?

The Laplacian of a scalar field is defined as

\[ \nabla^2 f = \nabla \cdot (\nabla f) = \frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2} + \frac{\partial^2 f}{\partial z^2}. \]

It measures how \(f\) compares to its average value in a small neighborhood and appears in diffusion, heat conduction, and wave equations.