# First & Second Derivative of a Summation

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)$ ?

-
BTW, why not write $f(\mu)$ as $f(\mu) = \sum_{i=1}^n(\mu-i)^2$? –  Anon Jan 29 '13 at 19:39
@Anon: How do you know that your edit is what was intended? If you don’t know for sure, it should be rolled back. –  Brian M. Scott Jan 29 '13 at 19:39
Expand, or better imagine expanding. Differentiate with respect to $\mu$. If you do it twice, you get a bunch of $2's$. Simplifying the result for "once" requires knowing $1+2+\cdots +n$. –  André Nicolas Jan 29 '13 at 19:40
Hey Anon, honestly I thought of your notation too...I just used the notation my prof gave me...his notation's quite weird sometimes too...Figured this community will really help me much more haha –  bryansis2010 Jan 29 '13 at 19:41
@BrianM.Scott I would agree with that. It is tough (at least for me) to imagine $x_i = 1,\ldots,n$ would mean something else though. –  Anon Jan 29 '13 at 19:42

$f'(\mu) = -2\sum_{i = 1}^{n} (x_i - \mu)$ and $f''(\mu)=2n$

-
This is right, but I don't see how this is a hint, you just gave the full answer (not that there is anything wrong with that.) –  user50407 Jan 29 '13 at 20:46
hi michael corleone this is hint because i don't write all arithmetic detail –  Maisam Hedyelloo Jan 29 '13 at 20:49
Ok, I suppose it doesn't really matter, as the tick on the side shows that the asker was happy with this answer :). I just think of hints as being more about helping the person get started than giving them the answer. –  user50407 Jan 29 '13 at 20:55
ok,thanks i accept your idea (but in simple question hint and answer is same ) –  Maisam Hedyelloo Jan 29 '13 at 21:02

$$\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$$

-
helly rlgordonma, should i start from 1, instead of 0? –  bryansis2010 Jan 29 '13 at 19:45
Oh yes, sorry about that. I'll fix that error - doesn't change the gist of the result of course. –  Ron Gordon Jan 29 '13 at 19:47