Multivariable calculus

Gradient of arctan(y/x): The Polar Angle Field

For f(x, y) = arctan(y/x) the gradient is (-y, x) divided by x^2 + y^2. Differentiate the arctangent to get 1 over 1 plus the square of y over x, then multiply by the derivative of y over x and clear the fractions. The result is perpendicular to the position vector, with length 1 over r.

f(x,y)=arctan(yx)f(x,y) = \arctan\left(\frac{y}{x}\right)
f=yx2+y2,  xx2+y2\nabla f = \left\langle \frac{-y}{x^{2}+y^{2}},\; \frac{x}{x^{2}+y^{2}} \right\rangle
fx=yx2+y2\frac{\partial f}{\partial x} = \frac{-y}{x^{2}+y^{2}}
fy=xx2+y2\frac{\partial f}{\partial y} = \frac{x}{x^{2}+y^{2}}

Chain rule, then clear the compound fraction

Use dduarctanu=11+u2\frac{d}{du}\arctan u = \frac{1}{1+u^{2}} with u=yxu = \frac{y}{x}. For the xx partial, yy is frozen, so uu is a constant divided by xx and ux=yx2\frac{\partial u}{\partial x} = -\frac{y}{x^{2}}.

fx=11+y2x2(yx2)\frac{\partial f}{\partial x} = \frac{1}{1+\frac{y^{2}}{x^{2}}}\cdot\left(-\frac{y}{x^{2}}\right)

The compound fraction is the step people abandon. Multiply the top and bottom of the first factor by x2x^{2}.

11+y2x2=x2x2+y2fx=x2x2+y2(yx2)=yx2+y2\frac{1}{1+\frac{y^{2}}{x^{2}}} = \frac{x^{2}}{x^{2}+y^{2}} \quad\Longrightarrow\quad \frac{\partial f}{\partial x} = \frac{x^{2}}{x^{2}+y^{2}}\cdot\left(-\frac{y}{x^{2}}\right) = \frac{-y}{x^{2}+y^{2}}

The yy partial is easier, since uy=1x\frac{\partial u}{\partial y} = \frac{1}{x}.

fy=x2x2+y21x=xx2+y2\frac{\partial f}{\partial y} = \frac{x^{2}}{x^{2}+y^{2}}\cdot\frac{1}{x} = \frac{x}{x^{2}+y^{2}}

Both x2x^{2} factors cancel completely, which is the sign that the answer wants to be written in terms of r2=x2+y2r^{2} = x^{2}+y^{2} rather than in terms of the quotient you started with.

This function is the polar angle

For x>0x > 0, arctan(yx)\arctan\left(\frac{y}{x}\right) is exactly the polar angle θ\theta. Its level curves are rays out of the origin, and the gradient must be perpendicular to those rays, so it circles the origin.

fx,y=yx+xyx2+y2=0\nabla f \cdot \left\langle x, y \right\rangle = \frac{-yx + xy}{x^{2}+y^{2}} = 0

The dot product with the position vector is zero at every point, confirming the circulation. The length is again 1r\frac{1}{r}, since the numerator vector y,x\left\langle -y, x\right\rangle has length rr.

At (1,1)(1,1) the gradient is 12,12\left\langle -\frac{1}{2}, \frac{1}{2}\right\rangle, pointing counterclockwise, which is the direction in which the angle θ\theta increases.

This field returns later in the course as the standard example that a curl-free field on a region with a hole need not be conservative. Its circulation around a loop enclosing the origin is 2π2\pi, not zero, because θ\theta itself cannot be defined continuously all the way round.

The mistake: mishandling the inner quotient

Two errors cover most wrong answers.

  • Writing x(yx)=yx\frac{\partial}{\partial x}\left(\frac{y}{x}\right) = \frac{-y}{x}, losing the square in the denominator. Rewrite the quotient as yx1y x^{-1} and the power rule hands you yx2-y x^{-2} with no ambiguity.
  • Leaving the answer as y/x21+y2/x2\frac{-y/x^{2}}{1 + y^{2}/x^{2}} and treating it as finished. It is correct but unusable, and it hides the fact that the two components differ only by a swap and a sign.

Check at (1,0)(1,0), on the positive xx axis: the true gradient is 0,1\left\langle 0, 1 \right\rangle. Moving in yy from there starts sweeping the angle upward at rate 11, while moving along the axis does not change the angle at all. Any candidate answer with a nonzero first component at that point is wrong.

One boundary condition to keep stated: everything here requires x0x \neq 0, since the formula arctan(yx)\arctan\left(\frac{y}{x}\right) is undefined on the yy axis even though the angle itself is perfectly well behaved there.

Frequently asked questions

Why does the gradient of arctan(yx)\arctan\left(\frac{y}{x}\right) have no arctan\arctan in it?

Because the derivative of the arctangent is a rational function, 11+u2\frac{1}{1+u^{2}}. Once you substitute u=yxu = \frac{y}{x} and clear the compound fraction, everything left is rational in xx and yy, so the inverse trig function disappears entirely.

Is this gradient perpendicular to the gradient of lnx2+y2\ln\sqrt{x^{2}+y^{2}}?

Yes. That one is x,yx2+y2\frac{\left\langle x, y\right\rangle}{x^{2}+y^{2}} and this one is y,xx2+y2\frac{\left\langle -y, x\right\rangle}{x^{2}+y^{2}}, and their dot product is zero. That is the polar coordinate picture: rr increases radially and θ\theta increases tangentially, and the two directions are at right angles.