[Math] Why does this partial derivative of a summation work

calculusderivativesordinary differential equationspartial derivativesummation

I'm trying to take the partial derivative of $-\sum\limits_{i=1}^n \frac{(x_i-\mu)^2}{2\sigma^2}$ with respect to $\mu$. The correct answer is $\sum\limits_{i=1}^n \frac{x_i-\mu}{\sigma^2}$. It looks like some u-substitution work where $u = x_i-\mu$ and $du = -1$ so it's $\sum\limits_{i=1}^n \frac{u^2}{2\sigma^2}du$ which ends up being $\sum\limits_{i=1}^n\frac{2(x_i-\mu)}{2\sigma^2} \times (-1)$

it all cancels out but why does this still work when inside of a summation?

Usually when I do derivatives of summations, I have to incorporate the $n$ into the equation to rid myself of the summation operator. For example,
$$\prod\limits_{i=1}^n \frac{1}{\sqrt{2\pi\sigma^2}} = \bigg(\frac{1}{\sqrt{2\pi\sigma^2}}\bigg)^n$$

The summation operator throws me off when it involves derivatives and the only way it makes sense to me is to restructure the format so that it doesn't include the summation operator. How can this be reorganized so the derivative makes sense?

Best Answer

The derivative and thus the partial derivative are linear operators, i.e. for a sum of functions $f_i$ and $a \in \mathbb{R}$:$${\partial \over \partial x}\left( \sum a\cdot f_i \right)= a\cdot \sum {{\partial f_i \over \partial x}}$$

So in your case we have

$${\partial \over \partial \mu}\left( -\sum\limits_{i=1}^n \frac{(x_i-\mu)^2}{2\sigma^2} \right) = -{1 \over 2 \sigma^2}\sum\limits_{i=1}^n{\partial \over \partial \mu} \left( {(x_i-\mu)^2}\right) = -{1 \over 2 \sigma^2}\sum\limits_{i=1}^n -2{(x_i-\mu)} $$ $$= {1 \over \sigma^2}\sum\limits_{i=1}^n {x_i-\mu} $$

Which is exactly what you have as a result. Further, I don't know what you mean by the u-substitution. This is plain application of the chain rule. Moreover, what you have here is not correct:

$$\sum\limits_{i=1}^n \frac{1}{\sqrt{2\pi\sigma^2}} \color{red}{\neq} \bigg(\frac{1}{\sqrt{2\pi\sigma^2}}\bigg)^n$$

Summation does not result in exponentiation, but just multiplication. You should have gotten:

$$\sum\limits_{i=1}^n \frac{1}{\sqrt{2\pi\sigma^2}} = \frac{n}{\sqrt{2\pi\sigma^2}}$$

Related Question