Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given a vector $X = [x_1, x_2,\ldots,x_n]^T$, how do you differentiate the function $\dfrac{\sum\limits_{i=1}^n |x_i|}{\left(\sum\limits_{i=1}^n x_i^2\right)^{\frac12}}$ with respect to each $x_i$ where $x_i \in [0,1]$

share|cite|improve this question
If the $x_i$ are positive, then no need for the absolute value, yes? – J. M. Sep 6 '11 at 5:18
Anyway: treat this problem as if you're differentiating $\frac{x+c}{\sqrt{x^2+d}}$ with respect to $x$... – J. M. Sep 6 '11 at 5:19
Write $|x_i|=\mathrm{sgn}(x_i) x_i$, it's not differentiable when $x_i=0$ anyway. Then note $\partial_ir=x_i/r$ and use the quotient rule. – anon Sep 6 '11 at 5:38
up vote 3 down vote accepted

Since $\|x\|^2=\sum\limits_{j=1}^nx_i^2$, we get that $\frac{\partial}{\partial x_k}\|x\|^2=2x_k$.

The chain rule says that $\frac{\partial}{\partial x_k}\|x\|^2=2\|x\|\frac{\partial}{\partial x_k}\|x\|$.

Thus, we get that $\frac{\partial}{\partial x_k}\|x\|=\frac{x_k}{\|x\|}$. This also gives that $\frac{\mathrm{d}}{\mathrm{d}x}|x|=\frac{x}{|x|}$.

These and the quotient rule yields $$ \frac{\partial}{\partial x_k}\frac{\sum\limits_{i=1}^n |x_i|}{\|x\|}=\frac{\frac{x_k}{|x_k|}\|x\|-\frac{x_k}{\|x\|}\sum\limits_{i=1}^n|x_i|}{\|x\|^2} $$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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