Multivariable calculus

Partial Derivatives of sqrt(x^2 + y^2 + z^2 + 1)

For f(x,y,z) = sqrt(x^2 + y^2 + z^2 + 1), the partial derivative with respect to x is x divided by that same square root, and the y and z partials replace x with y and z. A useful check is that f times the x partial equals x exactly.

f(x,y,z)=x2+y2+z2+1f(x,y,z) = \sqrt{x^2 + y^2 + z^2 + 1}
fx=xx2+y2+z2+1\frac{\partial f}{\partial x} = \frac{x}{\sqrt{x^2 + y^2 + z^2 + 1}}
fy=yx2+y2+z2+1\frac{\partial f}{\partial y} = \frac{y}{\sqrt{x^2 + y^2 + z^2 + 1}}
fz=zx2+y2+z2+1\frac{\partial f}{\partial z} = \frac{z}{\sqrt{x^2 + y^2 + z^2 + 1}}

Rewrite the root as a power, then chain

Square roots are easiest to differentiate once you write them as a one half power. Put u=x2+y2+z2+1u = x^2 + y^2 + z^2 + 1, so f=u1/2f = u^{1/2}. The power rule gives 12u1/2\frac{1}{2}u^{-1/2}, and the chain rule multiplies by ux=2x\frac{\partial u}{\partial x} = 2x.

fx=12u1/22x=xx2+y2+z2+1\frac{\partial f}{\partial x} = \tfrac{1}{2}u^{-1/2}\cdot 2x = \frac{x}{\sqrt{x^2 + y^2 + z^2 + 1}}

The 22 from the inside derivative cancels the 12\frac{1}{2} from the power rule, which is why the numerator ends up as a bare xx rather than 2x2x. That cancellation happens every time you differentiate the square root of a sum of squares, so it is worth recognising on sight.

The mistake: taking the root apart

The tempting shortcut is to treat x2+y2+z2+1\sqrt{x^2 + y^2 + z^2 + 1} as though the root distributes over the sum. It does not. There is no valid step from x2+y2\sqrt{x^2 + y^2} to x+yx + y, and any answer built on that is wrong from the first line.

The other frequent error is forgetting the cancellation and leaving 2x2u\frac{2x}{2\sqrt{u}} unsimplified, or worse, leaving 2xu\frac{2x}{\sqrt{u}}, which is twice the true value. Write the two half powers out explicitly the first few times so the cancellation is visible rather than remembered.

  • Wrong: distributing the root across the sum before differentiating.
  • Wrong: 2xu\frac{2x}{\sqrt{u}}, which keeps the inside derivative but drops the one half.
  • Right: xu\frac{x}{\sqrt{u}}, where the 22 and the 12\frac{1}{2} have cancelled.

Two checks and why the plus one is there

Because the numerator is xx and the denominator is ff itself, multiplying through gives a clean identity. If your answer does not satisfy it, a factor has gone astray.

ffx=x,ffy=y,ffz=zf\,\frac{\partial f}{\partial x} = x, \qquad f\,\frac{\partial f}{\partial y} = y, \qquad f\,\frac{\partial f}{\partial z} = z

At (1,2,2)(1,2,2) the inside is 1010, so f=10f = \sqrt{10} and the xx partial is 110\frac{1}{\sqrt{10}}, about 0.3160.316. Multiplying those two gives 11, which is the xx coordinate, as the identity promises.

The +1+1 inside the root is what makes this function well behaved everywhere. The pure distance function x2+y2+z2\sqrt{x^2+y^2+z^2} has no partial derivatives at the origin, because the graph comes to a point there. Adding 11 lifts the surface off that corner, so ff is smooth on all of space.

Frequently asked questions

How big can the gradient of this function get?

Its length is x2+y2+z2x2+y2+z2+1\frac{\sqrt{x^2+y^2+z^2}}{\sqrt{x^2+y^2+z^2+1}}, which is always less than 11 and approaches 11 far from the origin. So the surface steepens toward slope 11 but never reaches it.

Why does the pure distance function fail at the origin?

Along the xx axis x2+y2+z2\sqrt{x^2+y^2+z^2} reduces to x|x|, and the absolute value has a corner at 00 where the left and right slopes are 1-1 and 11. The +1+1 in this page's function removes that corner.