Consider the function $f(\mu) = \sum_{i = 1}^{n} (x_i - \mu)^2$, where $x_i = i,\,i=1, 2,\dots, n$.
What is the first and second derivative of $f(\mu)$?
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It only takes a minute to sign up.
Sign up to join this communityConsider the function $f(\mu) = \sum_{i = 1}^{n} (x_i - \mu)^2$, where $x_i = i,\,i=1, 2,\dots, n$.
What is the first and second derivative of $f(\mu)$?
$f'(\mu) = -2\sum_{i = 1}^{n} (x_i - \mu)$ and $f''(\mu)=2n$
$$\frac{d}{d \mu} f(\mu) = -2 \sum_{i=1}^n (x_i - \mu) = -2 \sum_{i=1}^n x_i + 2 n \mu $$
$$\frac{d^2}{d \mu^2} f(\mu) = 2 n $$
Adding an answer here to further clarify the other ones which are simply answers without steps. To get the first derivative, this can be re-written as:
$$\frac{d}{d\mu}\sum(x-\mu)^{2} \\ = \sum\frac{d}{d\mu}(x-\mu)^{2} $$
After that it's standard fare chain rule
$$ = \sum-1 \cdot 2(x-\mu) \\ = -2\sum(x-\mu) $$
Second derivative: you can observe the same property of linear summation: $$ \frac{d}{d\mu}-2\sum(x-\mu) \\ =-2\sum\frac{d}{d\mu}(x-\mu) \\ =-2\sum(-1) \\ =2n $$