# Minimizing a function

1. Jan 13, 2012

### autre

1. The problem statement, all variables and given/known data

Let $f(a)=\frac{1}{n-1}\sum_{i=1}^{n}(x_{i}-a)^{2}$

Find the value of a that minimizes f(a) by replacing $(x_{i}-a)$ by $((x_{i}-\bar{x})+(\bar{x}-a))$.

2. The attempt at a solution
$f(a)=\frac{1}{n-1}\sum_{i=1}^{n}((x_{i}-\bar{x})+(\bar{x}-a))^{2}=\frac{1}{n-1}\sum_{i=1}^{n}((x_{i}-\bar{x})^{2}+(\bar{x}-a){}^{2}+2(x_{i}-\bar{x})(\bar{x}-a))=\frac{1}{n-1}[\sum_{i=1}^{n}(x_{i}-\bar{x})^{2}+\sum(\bar{x}-a){}^{2}+\sum2(x_{i}-\bar{x})(\bar{x}-a)]$

I'm a little stuck here. Any ideas?

2. Jan 13, 2012

### autre

Any ideas, guys?

3. Jan 13, 2012

### Dick

Try using $\sum_{i=1}^{n} x_{i}=n \bar{x}$.

4. Jan 13, 2012

### autre

Thanks!

5. Jan 13, 2012

### SammyS

Staff Emeritus
In your final expression, the first sum doesn't depend on a. It's easy to make the other two equal to zero. Is that the minimum possible?

Is the third sum equal to zero for all values of a ?

6. Jan 13, 2012

### autre

I know that the minimum should be the mean a = 1\n$\sum x_i$. How do I make the other two equal to zero?

Last edited: Jan 13, 2012
7. Jan 13, 2012

### Dick

What is $\Sigma^n_1 (x_i-\bar{x})$?

8. Jan 13, 2012

### SammyS

Staff Emeritus
Do you realize that $\bar{x}$ is:
$\displaystyle\bar{x}=\frac{1}{n}\sum_{i=1}^{n}x_i \,?$ ​

So you're saying that the solution is $a=\bar{x}\,.$