Multivariable calculus

Gradient of ln of sqrt(x^2 + y^2): The Log Potential

For f(x, y) = ln sqrt(x^2 + y^2) the gradient is (x, y) divided by x^2 + y^2. Use the log rule to rewrite f as one half ln(x^2 + y^2) before differentiating. The result is a radial field pointing away from the origin whose length is 1 over r, the classic two dimensional logarithmic potential.

f(x,y)=lnx2+y2f(x,y) = \ln\sqrt{x^{2}+y^{2}}
f=xx2+y2,  yx2+y2\nabla f = \left\langle \frac{x}{x^{2}+y^{2}},\; \frac{y}{x^{2}+y^{2}} \right\rangle
fx=xx2+y2\frac{\partial f}{\partial x} = \frac{x}{x^{2}+y^{2}}
fy=yx2+y2\frac{\partial f}{\partial y} = \frac{y}{x^{2}+y^{2}}

Simplify with log rules before you differentiate

A square root inside a logarithm is a half power, and logarithms turn powers into multipliers. Do that first and the chain rule has only one layer to handle.

f=lnx2+y2=ln(x2+y2)1/2=12ln(x2+y2)f = \ln\sqrt{x^{2}+y^{2}} = \ln\left(x^{2}+y^{2}\right)^{1/2} = \tfrac{1}{2}\ln\left(x^{2}+y^{2}\right)

Now differentiate. The outer derivative gives 1x2+y2\frac{1}{x^{2}+y^{2}}, the inner derivative gives 2x2x, and the 12\frac{1}{2} out front cancels the 22.

fx=122xx2+y2=xx2+y2\frac{\partial f}{\partial x} = \tfrac{1}{2}\cdot\frac{2x}{x^{2}+y^{2}} = \frac{x}{x^{2}+y^{2}}

The yy component is identical with the letters exchanged, which the symmetry of ff demands. In polar form, f=lnrf = \ln r, and the gradient is 1r\frac{1}{r} in the radial direction.

f=x,yx2+y2=1rr^\nabla f = \frac{\left\langle x, y \right\rangle}{x^{2}+y^{2}} = \frac{1}{r}\,\hat{\mathbf{r}}

What the field looks like

Level curves of lnr\ln r are circles about the origin, so the gradient must be radial, and since lnr\ln r increases outward it points away from the origin. Its length falls off like 1r\frac{1}{r}.

f=x2+y2x2+y2=1r\left|\nabla f\right| = \frac{\sqrt{x^{2}+y^{2}}}{x^{2}+y^{2}} = \frac{1}{r}

At (3,4)(3,4), where r=5r = 5, the gradient is 325,425\left\langle \frac{3}{25}, \frac{4}{25}\right\rangle, of length 15\frac{1}{5}.

This field is worth recognising on sight. It is the two dimensional analogue of an inverse square law, it is the velocity field of a point source in fluid flow, and it is the potential whose Laplacian vanishes everywhere except the origin. That last fact is easy to check: fxx+fyy=y2x2(x2+y2)2+x2y2(x2+y2)2=0f_{xx} + f_{yy} = \frac{y^{2}-x^{2}}{(x^{2}+y^{2})^{2}} + \frac{x^{2}-y^{2}}{(x^{2}+y^{2})^{2}} = 0.

Nothing here is defined at the origin. Both ff and its gradient blow up there, so any statement about this surface carries the standing condition (x,y)(0,0)(x,y) \neq (0,0).

The mistake: differentiating the square root by brute force

Attacked without the log rule, the derivative becomes a two layer chain: the derivative of ln\ln evaluated at x2+y2\sqrt{x^{2}+y^{2}}, times the derivative of the square root, times the derivative of the inside. Done correctly it still works.

1x2+y2xx2+y2=xx2+y2\frac{1}{\sqrt{x^{2}+y^{2}}}\cdot\frac{x}{\sqrt{x^{2}+y^{2}}} = \frac{x}{x^{2}+y^{2}}

Done in a hurry it produces xx2+y2\frac{x}{\sqrt{x^{2}+y^{2}}}, which drops one of the two square roots. The give-away is the size of the answer far from the origin: the true gradient shrinks like 1r\frac{1}{r}, while the wrong one has constant length 11, which would mean a logarithm climbing at a fixed rate forever.

A second slip is writing 1x2+y2\frac{1}{x^{2}+y^{2}} for the whole partial, forgetting the inner 2x2x and the 12\frac{1}{2} that tames it.

Frequently asked questions

Why does the 12\frac{1}{2} disappear from the answer?

It cancels against the 22 produced by differentiating x2x^{2}. Written out, 121x2+y22x\frac{1}{2}\cdot\frac{1}{x^{2}+y^{2}}\cdot 2x collapses to xx2+y2\frac{x}{x^{2}+y^{2}}. If your answer still carries a stray factor of 22 or 12\frac{1}{2}, that cancellation is where to look.

What happens to this gradient at the origin?

It does not exist there, and neither does ff, since ln0\ln 0 is undefined. The gradient has length 1r\frac{1}{r}, which grows without bound as you approach the origin, so no limiting value can be assigned. The natural domain is the punctured plane.