Source, sink, and spin

Divergence and curl calculator

This tool estimates the divergence and the curl of a vector field at one point. You type a field in the plane, $\mathbf{F}=\langle P,Q\rangle$, or a field in space, $\mathbf{F}=\langle P,Q,R\rangle$, plus a point. Each partial derivative is a central difference. The numbers are numerical approximations, not a symbolic derivative.

In the plane, both answers are numbers. Positive divergence is a source tendency, and negative divergence is a sink tendency. Positive curl is a counterclockwise tendency, and negative curl is a clockwise tendency. In space, the curl is a vector. The page also draws the arrows, either the whole planar field or the horizontal slice through your point.

This is not a computer algebra system. It does not prove that a partial derivative exists, and it does not evaluate a flux integral or a circulation. For the map of the course, read multivariable and vector calculus. For the boundary form of the curl, read Stokes theorem intuition.

Allowed pieces: numbers, the variables $x$, $y$, and $z$, plus, minus, times, divide, powers, parentheses, and $\sin$, $\cos$, $\tan$, $\mathrm{sqrt}$, $\mathrm{abs}$, $\log$ (natural), $\exp$, $\pi$, $e$. Type them as sin, cos, tan, sqrt, abs, log, exp, pi, e. Write a times sign between variables. The letters xy are not the product x*y.

Components

Point

In the plane, divergence is Px + Qy and the scalar curl is Qx minus Py. Example buttons fill the boxes and compute.

How to use the calculator

The boxes start on the rotation field $\mathbf{F}=\langle -y, x\rangle$ at $(1,0)$, with step $0.001$. Press Compute. The partial derivatives are constant, so the same divergence and curl appear at every point where you move the dot. Divergence is $0$. The scalar curl is $2$.

Choose a field in the plane or in space. In the plane the $z$ and $R$ boxes hide, and an expression that uses $z$ is refused until you switch. Fill every component. The five example buttons each load one field and compute it.

How to read the output

The large line is the divergence, and the curl. Under it, each partial derivative is named, so you can add $P_x+Q_y$ yourself, and subtract for $Q_x-P_y$. In space the curl line is a vector, and the next line is its length.

The picture is a window centered on your point. Arrow length follows the size of $\langle P,Q\rangle$, with the longest samples kept from hiding the rest. The dot is the evaluation point. A sentence under the picture reads the sign of the divergence as source or sink, and the sign of the planar curl as counterclockwise or clockwise. In space that planar sign is the $z$ component. The full curl vector can point out of the slice, and the numbers above the picture are where you see that.

Treat the output as a probe. Change the step by a factor of ten and compute again. If the stable digits hold, you are close to the partial derivatives. If they jump, you are seeing rounding, a kink, or a formula that breaks nearby.

Worked examples

Rotation field $\mathbf{F}=\langle -y, x\rangle$ at $(1,0)$. Then $P_x=0$, $P_y=-1$, $Q_x=1$, $Q_y=0$. Divergence is $0$. Scalar curl is $1-(-1)=2$. The arrows circle the origin counterclockwise. This is the planar field on the Stokes explainer, before the extra zero component.

Radial field $\mathbf{F}=\langle x, y\rangle$ at $(1,1)$. Divergence is $1+1=2$. Scalar curl is $0-0=0$. Arrows point away from the origin and lengthen with distance. Every small disk is a source, and a paddle wheel does not spin.

Shear field $\mathbf{F}=\langle y, 0\rangle$ at $(1,1)$. Divergence is $0$. Scalar curl is $0-1=-1$, a clockwise tendency. The arrows are horizontal. The section below explains why straight arrows can still spin a wheel.

Gradient field $\mathbf{F}=\langle y, x\rangle$ at $(1,2)$. This is $\nabla(xy)$. Divergence is $0$. Scalar curl is $1-1=0$. A gradient of a smooth scalar function has curl zero. The page should agree, up to rounding dust.

Field in space $\mathbf{F}=\langle -y, x, 0\rangle$ at $(1,0,0)$. Divergence is $0$. The curl vector is $\langle 0,0,2\rangle$, and its length is $2$. The picture is the slice $z=0$, which looks like the rotation field. The $z$ component is the spin you see. The other two components are zero, so the axis of rotation is vertical.

What divergence measures

Divergence is a number at a point of a vector field. It asks whether a tiny region around that point is a source or a sink. Whatever the arrows mean, some of it enters through the boundary and some leaves. Divergence is the net outward flow per unit area, or per unit volume, after the region shrinks to the point.

Positive means a source tendency: more leaves than enters. Negative means a sink tendency. Near zero means inflow and outflow balance. The arrows can still be long. Balance is not a field that vanishes.

For $\mathbf{F}=\langle P,Q\rangle$ the divergence is $P_x+Q_y$. In space, add $R_z$. The radial field $\langle x,y\rangle$ has divergence $2$ everywhere, so every small disk is a source. The rotation field $\langle -y,x\rangle$ has divergence $0$. The flow turns, and it does not create or destroy anything.

What curl measures

Curl asks whether a tiny paddle wheel at the point would spin, and which way. In the plane the answer is $Q_x-P_y$. Positive is a counterclockwise tendency. Negative is clockwise. Near zero means the wheel does not spin from the first order behavior of the field. The rotation field has curl $2$ everywhere. The radial field has curl $0$. Those arrows can stretch a wheel. They do not turn it.

In space the curl is the vector $\langle R_y-Q_z,\, P_z-R_x,\, Q_x-P_y\rangle$. Its direction is the axis of the spin, in the right hand sense: fingers follow the spin, and the thumb points along the curl. Its length is the strength. The $z$ component is still the planar curl, so it reports the turn in a horizontal slice.

The picture on this page is always a horizontal slice. In the plane it is the whole field. In space it is the plane of constant $z$ through your point, and the arrows are $P$ and $Q$. A spin about a horizontal axis does not show up as a turn of those arrows. Read the full curl vector before you say a field in space has no rotation.

How the theorems use these numbers

The divergence theorem and Stokes theorem move a derivative from an interior onto a boundary. That is the same idea as the fundamental theorem of calculus, which recovers a derivative on an interval from the values at the two endpoints.

The divergence theorem says the flux of $\mathbf{F}$ through the closed boundary of a solid equals the triple integral of the divergence. If the divergence is the constant $2$ throughout the solid, the flux is $2$ times the volume.

Stokes theorem says the circulation of $\mathbf{F}$ around the oriented rim of a surface equals the flux of the curl through the surface. Green's theorem is the flat case: the double integral of $Q_x-P_y$ equals the circulation around the boundary. On the rotation field the curl is $2$, so circulation around a disk is $2$ times the area. The unit circle gives $2\pi$, and the unit disk has area $\pi$. That match is the check on the Stokes explainer.

Both theorems need the field smooth on the whole region, not only on the boundary. A blowup at one interior point can leave a tidy curl nearby and still refuse the theorem. This page refuses a point where a component is not a finite number. The wider map is the fields section, plus the glossary lines for divergence, curl, and Stokes theorem.

Why a gradient field has zero curl

If $\mathbf{F}$ is the gradient of a scalar $f$, then $P=f_x$ and $Q=f_y$. When the mixed partial derivatives are continuous, they agree, so $Q_x-P_y$ is $0$. In space every component of the curl cancels the same way. A gradient field does not spin the paddle wheel.

A line integral of a gradient then depends only on the endpoints, on a region without holes. Circulation on a closed loop is $0$, and Stokes theorem agrees because the curl is the zero vector.

Curl zero is required. It is not always enough. On a punctured plane, a field can have curl zero wherever it is defined and still fail to be a gradient on the whole region. This page checks one point. It does not certify a potential. The gradient button loads $\langle y,x\rangle$, which is $\nabla(xy)$, and the curl there is $0$. The gradient calculator starts from a scalar. This page starts from the components.

The shear field, with straight arrows

The field $\langle y,0\rangle$ has horizontal arrows. Above the $x$ axis they point right and lengthen as $y$ grows. Below it they point left. A particle stays on a horizontal line and never turns.

A paddle wheel still spins. A stronger push to the right on the top than on the bottom is clockwise, even when every nearby arrow points the same way. Here $Q_x-P_y=-1$, and the divergence is $0$.

Straight streamlines and a nonzero curl can share a field. Curl measures the spin of a small neighborhood, not whether one path bends. Circles in a sketch are a hint of rotation, not the definition.

Common mistakes

  • Swapping the formulas. Divergence adds matching components, $P_x+Q_y+R_z$. Curl uses the crossed ones, such as $Q_x-P_y$. Adding every partial you computed is neither formula.
  • Reading the signs as one idea. Positive curl means counterclockwise. Positive divergence means a source. The rotation field has curl $2$ and divergence $0$. The radial field swaps those numbers. If your answer swaps them, the formulas were crossed.
  • Trusting streamlines as a curl test. The shear field has curl $-1$ and paths that are straight. Missing curves do not mean the curl is zero.
  • Treating one point as a theorem. Divergence $2$ at a single point does not make the flux through a large surface equal $2$ times the volume, unless the divergence is $2$ throughout the solid.
  • Forgetting that curl in space is a vector. $Q_x-P_y$ is only the $z$ component. A field can spin about a horizontal axis while that component is $0$.
  • Ignoring a hole or a blowup. Curl zero on a curve does not license Stokes theorem on a disk that contains a point where the field breaks.

These derivatives are estimates

Every partial derivative here is a central difference. The page samples a component one step $h$ to each side of the point, subtracts, and divides by $2h$. For a polynomial of degree at most $2$, that quotient matches the derivative you would write by hand, apart from ordinary rounding. For a rougher formula it is an estimate. Change $h$ by a factor of ten. If the stable digits hold, you are close to the slope. If they jump, the point may be a kink, a corner, or too close to a place where the formula breaks. The boxes start at $0.001$.

The output is not a proof that a partial derivative exists, and it is not a proof of either theorem. It is a numerical check against algebra you did yourself. If the field is undefined at the point, or a sample beside the step is not finite, the page stops. Move the point, or repair the formula, before you treat that spot as a divergence or a curl.

Related reading

The course map is multivariable and vector calculus. Circulation and the flux of the curl are on Stokes theorem intuition. Short lines: divergence, curl, vector field, and gradient.

After the components are on your paper, the vector operations calculator checks a dot product, a cross product, or a magnitude. A scalar function, when you want its gradient rather than the curl of a field, belongs on the gradient and directional derivative calculator.

Disclaimer. Educational estimate only. This page is not a computer algebra system and not a proof. See the site disclaimer and the FAQ on calculators versus understanding.

Common questions

What does the sign of the divergence mean?

Positive divergence is a source tendency. A tiny region around the point sends out more of the field than it takes in. Negative divergence is a sink tendency. A value near zero means inflow and outflow balance at that point. The arrows can still be long.

What does the sign of the curl mean in the plane?

For a planar field the curl on this page is the number $Q_x-P_y$. Positive means a counterclockwise rotation tendency. Negative means a clockwise tendency. In space the curl is a vector. The sign of its $z$ component is the same counterclockwise or clockwise reading for the horizontal slice drawn here.

Why does a gradient field have zero curl?

If the components are partial derivatives of one scalar function, and the mixed partials are continuous, those mixed partials agree. The curl subtracts one order from the other, so each component cancels. Curl zero at one point is not, by itself, a proof that a potential exists on a whole region.

Why can the shear field rotate if the arrows are straight?

The field $\langle y, 0\rangle$ has horizontal arrows, so each particle travels in a straight line. A tiny wheel still feels a stronger push to the right on its top than on its bottom, which is a clockwise spin. The scalar curl is $-1$. Curl measures that local spin, not whether one streamline bends.

Are these partial derivatives exact?

No. Each one is a central difference with the step shown under the result. For a polynomial of low degree the estimate often matches the algebra. A kink, a corner, or a point where the formula is undefined will not settle. The number is a check, not a symbolic proof.

What if the field is undefined at my point?

The page refuses the point. Divergence and curl need the components to return finite numbers on both sides of a small step. A formula such as $1/x$ at $x=0$, or a square root of a negative number, stops the calculation. Move to a point where every component is defined.

Want a tool that matches a new explainer, or a check that a page and a calculator disagree? Write a short note.

Suggest a topic or tool