Partial derivative of a summation Simple question but not sure why for, $ f = \frac{\lambda}{2}\sum_{j=1}^{D} w_j^2$
$$\frac{\partial f}{\partial wj}= \lambda w_j$$
I would have thought the answer would be $\frac{\partial f}{\partial wj}= \lambda \sum_{j=1}^{D} w_j^2$
Since we get the derivative of $w_j^2$ which is $2w_j$, pull out the 2, getting rid of $\frac{\lambda}{2}$, and multiply by $w_j$. 
 A: Take for example $D=2$. Then
$$
f=\frac\lambda2(w_1^2+w_2^2)
$$
and indeed
$$
\frac{\partial f}{\partial w_1}=\frac\lambda22w_1=\lambda w_1
$$
and
$$
\frac{\partial f}{\partial w_2}=\frac\lambda22w_2=\lambda w_2.
$$
The case of arbitrary $D$ is analogous.
A: What you have written doesn't quite make sense!  The given function is a function of the D variables, $\omega_1, \omega_2, \cdot\cdot\cdot, \omega_D$.  But then what variable do you want to differentiate with respect to?  Having used "j" as the summation index, you should not then use "j" as an index outside that summation!  
It would be better to use some other index, say "i"- having summed over all variables, differentiate with respect to one of those,
The derivative of a constant is 0.  And when you are differentiating with respect to the variable $\omega_j$, all the other variable are treated as constants.
For example, if D= 4 so that $f(\omega_1, \omega_2, \omega_3, \omega_4)= \frac{\lambda}{2}\sum_{j=1}^4 \omega_j^2= \frac{\lambda}{2}\omega_1^2+ \frac{\lambda}{2}\omega_2^2+ \frac{\lambda}{2}\omega_3^2+ \frac{\lambda}{2}\omega_4^2$.  The derivative with respect to any one of those variables, say $\omega_j$, is $\lambda \omega_j$.
A: $\frac  {\partial \omega_j^2}{\partial \omega_j}=2\omega _j$
And, $\frac  {\partial \omega_i^2}{\partial \omega_j}=0$ for  $i\not =j $. ..
