Multivariable calculus

Divergence of F = (e^x cos y, e^x sin y)

For F(x, y) = (e^x cos y, e^x sin y) the divergence is 2 e^x cos y. Both diagonal partials equal e^x cos y, so the answer is twice one of them. Since e^x is always positive, the sign is the sign of cos y: a source where cos y is positive, a sink where it is negative.

F(x,y)=excosy, exsiny\mathbf{F}(x,y) = \left\langle e^{x}\cos y,\ e^{x}\sin y \right\rangle
Px=x(excosy)=excosy\frac{\partial P}{\partial x} = \frac{\partial}{\partial x}\left(e^{x}\cos y\right) = e^{x}\cos y
Qy=y(exsiny)=excosy\frac{\partial Q}{\partial y} = \frac{\partial}{\partial y}\left(e^{x}\sin y\right) = e^{x}\cos y
F=excosy+excosy=2excosy\nabla \cdot \mathbf{F} = e^{x}\cos y + e^{x}\cos y = 2e^{x}\cos y

Each partial sees the other factor as a constant multiplier

Both components are a function of xx times a function of yy, which is the easiest possible shape for a partial derivative. Whichever variable you are differentiating, the other factor comes along for the ride.

For the first component you differentiate with respect to xx, so cosy\cos y is the constant and exe^{x} is the work. The exponential is its own derivative, so nothing changes at all.

x(excosy)=cosyxex=excosy\frac{\partial}{\partial x}\left(e^{x}\cos y\right) = \cos y \cdot \frac{\partial}{\partial x}e^{x} = e^{x}\cos y

For the second component you differentiate with respect to yy, so now exe^{x} is the constant and siny\sin y is the work.

y(exsiny)=exysiny=excosy\frac{\partial}{\partial y}\left(e^{x}\sin y\right) = e^{x} \cdot \frac{\partial}{\partial y}\sin y = e^{x}\cos y

The two agree, so the sum doubles: F=2excosy\nabla \cdot \mathbf{F} = 2e^{x}\cos y.

The mistake: differentiating both components with respect to x

Because exe^{x} appears in both components, it is tempting to run down the list differentiating with respect to xx each time. That gives excosy+exsinye^{x}\cos y + e^{x}\sin y, which is not the divergence of anything you were asked about.

Say the rule out loud as you work: first component with respect to the first variable, second component with respect to the second variable. The variable changes even when the component looks familiar.

A close cousin of this error is a lost minus sign. The derivative of siny\sin y is +cosy+\cos y; the minus belongs to the derivative of cosy\cos y, which never gets used here because cosy\cos y only ever sits in the component being differentiated with respect to xx.

Where the field sources and where it sinks

The factor exe^{x} is positive for every real xx, so it can change the size of the divergence but never its sign. Everything is decided by cosy\cos y.

  • For π2<y<π2-\frac{\pi}{2} < y < \frac{\pi}{2} the divergence is positive: a source.
  • For π2<y<3π2\frac{\pi}{2} < y < \frac{3\pi}{2} it is negative: a sink.
  • On the lines y=π2+kπy = \frac{\pi}{2} + k\pi it is exactly zero, and those horizontal lines separate the bands.

One sign change makes the whole picture different. The nearby field excosy, exsiny\langle e^{x}\cos y,\ -e^{x}\sin y \rangle has divergence excosyexcosy=0e^{x}\cos y - e^{x}\cos y = 0 everywhere, because flipping the second component flips the sign of the second partial. That version is incompressible; this one is not.

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 does the exponential factor survive into the answer unchanged?

Because exe^{x} is its own derivative. Differentiating the first component with respect to xx leaves it alone, and differentiating the second with respect to yy never touches it.

For which y is the divergence negative?

Wherever cosy<0\cos y < 0, that is for π2<y<3π2\frac{\pi}{2} < y < \frac{3\pi}{2} and every shift of that band by 2π2\pi. The value of xx scales the size but never flips the sign.