25
$\begingroup$

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

$\endgroup$
11
  • $\begingroup$ BTW, why not write $f(\mu)$ as $f(\mu) = \sum_{i=1}^n(\mu-i)^2$? $\endgroup$
    – Anon
    Jan 29, 2013 at 19:39
  • $\begingroup$ @Anon: How do you know that your edit is what was intended? If you don’t know for sure, it should be rolled back. $\endgroup$ Jan 29, 2013 at 19:39
  • 1
    $\begingroup$ 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$. $\endgroup$ Jan 29, 2013 at 19:40
  • $\begingroup$ 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 $\endgroup$ Jan 29, 2013 at 19:41
  • $\begingroup$ @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. $\endgroup$
    – Anon
    Jan 29, 2013 at 19:42

3 Answers 3

23
$\begingroup$

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

$\endgroup$
8
  • 12
    $\begingroup$ 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.) $\endgroup$
    – user50407
    Jan 29, 2013 at 20:46
  • 2
    $\begingroup$ hi michael corleone this is hint because i don't write all arithmetic detail $\endgroup$
    – M.H
    Jan 29, 2013 at 20:49
  • 2
    $\begingroup$ 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. $\endgroup$
    – user50407
    Jan 29, 2013 at 20:55
  • 3
    $\begingroup$ @user50407 is it only about asker? There are lot of others who lend here in search of a answer. $\endgroup$ Sep 4, 2016 at 20:55
  • 2
    $\begingroup$ Here we have one function (xi−μ) that is part of a larger function in that it is raised to a power of 2, (μ−i)^2 ? According to the extended power rule, we multiply the derivative of the outer function (μ−i)^2 x the derivative of the inner function (xi−μ). The derivative of the outer function brings the 2 down in front as 2*(xi−μ), and the derivative of the inner function (xi−μ) is -1. So the -2 comes from multiplying the two derivatives according to the extend power rule: 2*(xi−μ)*-1 = -2(xi−μ) $\endgroup$ Sep 19, 2018 at 20:11
19
$\begingroup$

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

$\endgroup$
4
  • $\begingroup$ helly rlgordonma, should i start from 1, instead of 0? $\endgroup$ Jan 29, 2013 at 19:45
  • $\begingroup$ Oh yes, sorry about that. I'll fix that error - doesn't change the gist of the result of course. $\endgroup$
    – Ron Gordon
    Jan 29, 2013 at 19:47
  • 2
    $\begingroup$ What rule did you use to get to this answer and how the basic rules (sum, product, chain, e.t.c) fit in this derivation at each step. Could you please explain. Thanks. $\endgroup$ Aug 26, 2018 at 14:51
  • 1
    $\begingroup$ In the 1st step on line 1, the chain rule is applied. The term within the brackets is differentiated, producing a -1. Then the bracket itself is differentiated, producing the 2 at the front. The 2nd step on line 1 involves no differentiation. Instead, the bracket is split into two terms. The second term has an n because it is simply the summation from i=1 to i=n of a constant. The summation of a constant is equal to n multiplied by the constant. Then for the second line, there are no extra rules. The first term becomes 0 because it's a constant and the second term loses mu. Hope this helps. $\endgroup$
    – AkThao
    Mar 15, 2020 at 17:02
12
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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