Multivariable calculus

Divergence of F = (xyz, y^2, z sin x)

For F(x, y, z) = (xyz, y^2, z sin x) the divergence is yz + 2y + sin x. Differentiating xyz with respect to x leaves yz, y^2 with respect to y leaves 2y, and z sin x with respect to z leaves sin x. Every other partial derivative of this field is irrelevant to the divergence.

F(x,y,z)=xyz, y2, zsinx\mathbf{F}(x,y,z) = \left\langle xyz,\ y^{2},\ z\sin x \right\rangle
Px=x(xyz)=yz\frac{\partial P}{\partial x} = \frac{\partial}{\partial x}\left(xyz\right) = yz
Qy=y(y2)=2y\frac{\partial Q}{\partial y} = \frac{\partial}{\partial y}\left(y^{2}\right) = 2y
Rz=z(zsinx)=sinx\frac{\partial R}{\partial z} = \frac{\partial}{\partial z}\left(z\sin x\right) = \sin x
F=yz+2y+sinx\nabla \cdot \mathbf{F} = yz + 2y + \sin x

Anything without the working variable rides along unchanged

This field is built so that each component is the working variable times something that does not contain it. That makes every diagonal partial a one-step calculation.

  • P=xyzP = xyz differentiated in xx: the factor yzyz is frozen, so the answer is yzyz.
  • Q=y2Q = y^{2} differentiated in yy: no other variable is present, so the answer is 2y2y.
  • R=zsinxR = z\sin x differentiated in zz: the factor sinx\sin x is frozen, so the answer is sinx\sin x.
F=yz+2y+sinx\nabla \cdot \mathbf{F} = yz + 2y + \sin x

Check it at a point to be sure the bookkeeping held. At (0,1,2)(0, 1, 2) the divergence is 12+21+sin0=41\cdot 2 + 2\cdot 1 + \sin 0 = 4.

The mistake: differentiating the factor that is frozen

The third component is where this goes wrong. Seeing sinx\sin x triggers the reflex to differentiate it, producing zcosxz\cos x. But the third component is differentiated with respect to zz, and sinx\sin x is a constant as far as zz is concerned.

The same trap sits in the first component: x(xyz)\frac{\partial}{\partial x}(xyz) is yzyz, not xzxz or xyxy, because only the xx factor is differentiated and the rest stays put.

One reliable habit is to rewrite the component with the frozen part in brackets before you differentiate. Writing zsinxz\sin x as (sinx)z\left(\sin x\right)\cdot z makes it obvious that you are differentiating zz with a constant in front.

What the answer depends on

The divergence yz+2y+sinxyz + 2y + \sin x involves all three variables, even though no single component did. That is normal: divergence assembles contributions from three separate places.

It also shows why divergence cannot be read off the size of the field. The middle component y2y^{2} is large when yy is large and negative, yet its contribution 2y2y is negative there, pulling the divergence down. Magnitude and divergence are different measurements.

The surface where yz+2y+sinx=0yz + 2y + \sin x = 0 separates the source regions from the sink regions. Because sinx\sin x oscillates, that surface repeats in bands as you travel along the xx axis.

Checked on every build: each component is differentiated numerically with respect to its own variable, and the sum is compared against the divergence above at six sample points.

Frequently asked questions

Why is sin x not differentiated in the third component?

Because that component is differentiated with respect to zz, and sinx\sin x contains no zz. It behaves as a constant coefficient, so z(zsinx)=sinx\frac{\partial}{\partial z}\left(z\sin x\right) = \sin x.

Does the divergence depend on all three variables?

Yes. The term yzyz brings in yy and zz, the term 2y2y brings in yy again, and sinx\sin x brings in xx. Each contribution comes from a different component of the field.