Multivariable calculus
Divergence of F = (sin(xy), cos(xy))
For F(x, y) = (sin(xy), cos(xy)) the divergence is y cos(xy) minus x sin(xy). The chain rule on the first component brings down y; on the second it brings down x and a minus sign from the derivative of cosine. The two inner derivatives differ, and that is the step most often missed.
Chain rule, with the inner derivative matched to the variable
Both components wrap the same inside function , but the inner derivative is not the same, because you are differentiating with respect to a different variable each time.
First component, outer function , differentiated with respect to .
Second component, outer function , differentiated with respect to . The derivative of carries the minus sign.
Add them and you are done. As a spot check, at the divergence is , so the field is a mild sink there.
The mistake: reusing the same inner factor twice
The wrong answer that shows up most often is . The inner derivative from the first term has been copied into the second, but the second term is differentiated with respect to , where the inner derivative of is .
A useful habit: before touching either component, write down both inner derivatives, and , and then reach for the one that matches the variable you are working in.
The other frequent wrong answer, , drops the minus sign that comes from differentiating cosine. Both errors survive a glance at the shape of the answer, so the only defence is doing the two steps separately and in order.
Every arrow has length 1, and the divergence still grows
This field is worth a second look because its arrows never change size. The two components are and , so the length of every arrow is . Only the direction varies from point to point.
Yet the divergence is not bounded. Collect the two terms with the standard combination of a sine and a cosine of the same angle and the size of the answer appears on its own.
So the divergence oscillates between and , where is the distance from the origin. Walk out along any ray that is not one of the axes and the angle grows quadratically while the envelope grows only linearly, so the swings get both wider and faster. A field whose arrows all have length can still be a strong source at one point and a strong sink a short step away.
- On the whole axis, , both terms vanish and the divergence is exactly .
- On the axis, , the divergence is just , which is the envelope at full size.
- Everywhere else it sits somewhere between, at .
The lesson generalises past this example: divergence reads how the direction of a field turns as you move, not how long its arrows are. Fixing the length of every arrow puts no ceiling whatsoever on the divergence.
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 the inner derivative y in one term and x in the other?
Because the inner function is differentiated with respect to a different variable each time. Holding fixed gives ; holding fixed gives .
Where does the minus sign in the second term come from?
From the outer function. , so the chain rule attaches a minus to the whole second term, giving .