Multivariable calculus

Gradient of ln(x^2 + y^2 + z^2 + 1) in Three Variables

For f(x, y, z) = ln(x^2 + y^2 + z^2 + 1) the gradient is 2(x, y, z) divided by x^2 + y^2 + z^2 + 1. One chain rule handles all three components, since only the inner derivative changes. The field points radially outward and is longest on the unit sphere, where its length is exactly 1.

f(x,y,z)=ln⁡(x2+y2+z2+1)f(x,y,z) = \ln\left(x^{2}+y^{2}+z^{2}+1\right)
∇f=2x2+y2+z2+1⟨x,  y,  z⟩\nabla f = \frac{2}{x^{2}+y^{2}+z^{2}+1}\left\langle x,\; y,\; z \right\rangle
∂f∂x=2xx2+y2+z2+1\frac{\partial f}{\partial x} = \frac{2x}{x^{2}+y^{2}+z^{2}+1}
∂f∂y=2yx2+y2+z2+1\frac{\partial f}{\partial y} = \frac{2y}{x^{2}+y^{2}+z^{2}+1}
∂f∂z=2zx2+y2+z2+1\frac{\partial f}{\partial z} = \frac{2z}{x^{2}+y^{2}+z^{2}+1}

One chain rule, three inner derivatives

Write u=x2+y2+z2+1u = x^{2}+y^{2}+z^{2}+1. Every component of ∇f\nabla f is 1u\frac{1}{u} times the corresponding partial of uu, and those partials are 2x2x, 2y2y and 2z2z.

∇f=1u⟨∂u∂x,  ∂u∂y,  ∂u∂z⟩=2⟨x,y,z⟩x2+y2+z2+1\nabla f = \frac{1}{u}\left\langle \frac{\partial u}{\partial x},\; \frac{\partial u}{\partial y},\; \frac{\partial u}{\partial z} \right\rangle = \frac{2\left\langle x, y, z \right\rangle}{x^{2}+y^{2}+z^{2}+1}

Doing three variables costs no more thought than doing two. The outer function is differentiated once, and the only per-variable work is the inner derivative, which for a sum of squares is immediate.

At (1,1,1)(1,1,1) the denominator is 44, so the gradient is ⟨12,12,12⟩\left\langle \frac{1}{2}, \frac{1}{2}, \frac{1}{2}\right\rangle, a vector of length 32≈0.8660\frac{\sqrt{3}}{2} \approx 0.8660 pointing straight out along the diagonal.

Level surfaces are spheres, and the steepest shell is the unit sphere

Since ff depends only on ρ2=x2+y2+z2\rho^{2} = x^{2}+y^{2}+z^{2}, the level surfaces f=cf = c are spheres centred at the origin. The gradient is perpendicular to each sphere, which forces it to be radial, and the positive factor 21+ρ2\frac{2}{1+\rho^{2}} makes it point outward.

∣∇f∣=2ρ1+ρ2\left|\nabla f\right| = \frac{2\rho}{1+\rho^{2}}

That length is zero at the origin, which is the global minimum of ff with value ln⁡1=0\ln 1 = 0. It then rises, peaks, and decays. By the arithmetic mean and geometric mean inequality, 1+ρ2≥2ρ1 + \rho^{2} \geq 2\rho, so the length never exceeds 11, and it equals 11 exactly when ρ=1\rho = 1.

So the unit sphere is where this function climbs fastest, and both inside and outside it the surface flattens. Far away the gradient decays like 2ρ\frac{2}{\rho}, because out there ff behaves like 2ln⁡ρ2\ln\rho: the function keeps rising, but ever more slowly.

The mistake: differentiating the constant, or splitting the denominator

The +1+1 inside the logarithm exists to keep the argument positive and the function defined at the origin. It contributes nothing to any numerator, since constants differentiate to zero, but it stays in every denominator. Writing 2xx2+y2+z2\frac{2x}{x^{2}+y^{2}+z^{2}} silently changes the function to ln⁡ρ2\ln\rho^{2}, which blows up at the origin.

The other frequent error is treating the logarithm of a sum as a sum of logarithms, and computing the gradient of ln⁡x2+ln⁡y2+ln⁡z2+ln⁡1\ln x^{2} + \ln y^{2} + \ln z^{2} + \ln 1 instead. That would give 2x\frac{2}{x} for the first component.

ln⁡(x2+y2+z2+1)≠ln⁡x2+ln⁡y2+ln⁡z2\ln\left(x^{2}+y^{2}+z^{2}+1\right) \neq \ln x^{2} + \ln y^{2} + \ln z^{2}

There is no logarithm rule for a sum inside. The rules convert products, quotients and powers, and a sum is none of those. Test at the origin: the true gradient is ⟨0,0,0⟩\left\langle 0,0,0\right\rangle, while 2x\frac{2}{x} is undefined there.

Frequently asked questions

Why do all three components have the same denominator?

The denominator comes from the outer derivative 1u\frac{1}{u}, which is the same object no matter which variable you differentiate. Only the numerator, the inner derivative of uu, changes from component to component.

Where is this function increasing fastest?

On the unit sphere x2+y2+z2=1x^{2}+y^{2}+z^{2} = 1, where the gradient has length exactly 11. The length formula 2ρ1+ρ2\frac{2\rho}{1+\rho^{2}} is at most 11 for every ρ\rho, with equality only at ρ=1\rho = 1, so no point in space has a steeper climb than the points on that sphere.