$f:\mathbb{R}^n\rightarrow\mathbb{R}$ is a map $f(x)=\langle x,x\rangle$, $g:\mathbb{R}\rightarrow\mathbb{R}$ is a map $g(x)=\sqrt{x}$, so the composition $h:=g\circ f:\mathbb{R}^n\rightarrow\mathbb{R}$ is a map $x\mapsto \|x\|$, I want the derivative of $h$ at $a$, according to chain rule it should be $D(g(f(a)))\circ D f(a)$,could any one tell me now next steps?

  • $\begingroup$ Since $h$ is a function of multiple variables you can find partial derivatives. So $\frac {\partial h}{\partial x_i} = \frac {dg}{df(x))}\frac {\partial f}{\partial x_i}$ $\endgroup$ – Kaster Feb 26 '13 at 18:39
  • $\begingroup$ The chain rule would give $Dh(x) = Dg(f(x)) Df(x)$. You are missing a 'D'. Also note that $h$ is differentiable iff $x \neq 0$. $\endgroup$ – copper.hat Feb 26 '13 at 18:50
  • $\begingroup$ @copper.hat yes, I missed $\endgroup$ – Marso Feb 27 '13 at 12:30

If $x_1,\ldots,x_n$ are coordinates on $\mathbb{R}^n$ then $f(\vec{x}) = x_1^2+\cdots+x_n^2$. It follows that $$h(\vec{x}) = \sqrt{x_1^2+\cdots+x_n^2} \equiv \left(x_1^2+\cdots+x_n^2\right)^{1/2} \, . $$

The differential of $h$ is given by the partial derivatives $\partial h/\partial x_k$. Provided that $\vec{x}$ is not the zero vector, i.e. at least one of the $x_k$ is non-zero, we can apply the chain rule:

$$\frac{\partial h}{\partial x_k} = \frac{1}{2}\times\left(x_1^2+\cdots+x_n^2\right)^{-1/2} \times 2x_k \equiv \frac{x_k}{\sqrt{x_1^2+\cdots+x_n^2}} \, . $$

If the differentiation confuses you then try it on a single variable: $\sqrt{x^2}$. Putting everything together:

$$(Dh)(\vec{x}) = \left(\frac{\partial h}{\partial x_1},\ldots,\frac{\partial h}{\partial x_n}\right) = \frac{(x_1,\ldots,x_n)}{\sqrt{x_1^2+\cdots+x_n^2}}$$

Equivalently: $(Dh)(\vec{x})=\vec{x}/||\vec{x}||.$

  • 3
    $\begingroup$ A note: this is true only for $\vec{x}\neq 0$. In $\vec{x} = 0$ the function is not differentiable. $\endgroup$ – Daniel Robert-Nicoud Feb 26 '13 at 19:23
  • $\begingroup$ @DanielRobert-Nicoud +1 Absolutely! Thanks for the clarification. I took that as a tacit assumption. If the OP's doing multi-variable calculus then I assumed they realise that division by zero is forbidden. I've made that explicit with a cheeky edit. Thanks again Dan. $\endgroup$ – Fly by Night Feb 26 '13 at 19:52

Here is an approach which works on any inner product space.

First the derivative of $f$ is $$ Df_x(k)=(x,k)+(k,x)=2(x,k) $$ and the derivative of $g$ is $$ Dg_t(s)=g'(t)s=\frac{s}{2\sqrt{t}} $$ for all $t\neq 0$.

Now the derivative of $h=g\circ f$ is, by he chain rule $$ Dh_x(k)=Dg_{f(x)}\circ Df_x(k)=g'(f(x))2(x,h)=\frac{(x,k)}{\|x\|} $$ for all $x\neq 0$.


You can also think about it geometrically: perturbing $a$ by a $\delta a$ perpendicular to $a$ does not change the length of $a$ to first order. Perturbing it in the direction of $a$ increases the length by $\delta a$. Therefore the derivative is $\hat{a}=a/\|a\|$.

  • $\begingroup$ But it's not. Provided $\hat{a} \neq 0$, the differential of $\hat{a} \mapsto ||\hat{a}||$ is $\hat{a}/||\hat{a}||$. $\endgroup$ – Fly by Night Feb 26 '13 at 18:52
  • $\begingroup$ @FlybyNight I'm using the notation (which might not be standard outside of physics) that a hatted vector is a unit vector: $\hat{a} = a/\|a\|$. $\endgroup$ – user7530 Feb 26 '13 at 19:07
  • $\begingroup$ Ah, okay! I'd seen the hat used by engineers but assumed it simply denoted a vector as in $i$-hat, $j$-hat and $k$-hat. It seems that the hat denotes, in general, a unit vector. So using $\hat{a}$ to denote the vector parallel to $\vec{a}$ and of unit length, namely $\vec{a}/||\vec{a}||$ makes perfect sense. My apologies. Thanks for teaching me something new! $\endgroup$ – Fly by Night Feb 26 '13 at 19:16

Here is a coordinate free argument:

According to the chain rule $$dh(a)=dg\bigl(f(a)\bigr)\circ df(a)\ .\tag{1}$$ Now $$f(a+X)-f(a)=(a+X)\cdot(a+X)-a\cdot a=2a\cdot X+|X|^2\tag{2}$$ and therefore $$df(a).X=2 a\cdot X\ .$$ Furthermore the formula $$g'(y)={1\over 2\sqrt{y}}\qquad(y>0)$$ can be written in the form $$dg(y).Y={1\over 2g(y)}Y\ .\tag{3}$$ Letting $y:=f(a)$ and plugging $(2)$ and $(3)$ into $(1)$ we obtain $$dh(a).X=dg\bigl(f(a)\bigr)\bigl(df(a).X\bigr)={1\over 2g\bigl(f(a)\bigr)}\bigl(2a \cdot X)\bigr)={a\cdot X\over|a|}\ .$$ It follows that $dh(a)$ can be represented by the gradient $$\nabla h(a)={a\over|a|}\qquad(a\ne0)$$ in the form $$dh(a).X=\nabla h(a)\cdot X\qquad(X\in{\mathbb R}^n)\ .$$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.