I have the function $f(x)=(x-a_1)^2+(x-a_2)^2+...+(x-a_n)^2$, where $a_1, ..., a_n \in ℝ$ and $n \in ℕ^*$, and I'm trying to prove why $f$ has its minimum value when $x$ is the arithmetic mean of $a_1+a_2+...+a_n$.
How can I approach this?
(I had an epiphany while writing the question, but I'd like to see other possible solutions)
This problem can be solved in three steps:
First, we find the first derivative of $f$, which is the following: $$f'(x)=2\sum_{i=1}^n{(x-a_i)}=2nx-2\sum_{i=1}^n{a_i}$$
Then, we calculate the extremum of $f$: $$ f'(x)=0\Leftrightarrow 2nx-2\sum_{i=1}^n{a_i}=0\Leftrightarrow nx=\sum_{i=1}^n{a_i} \Leftrightarrow x={{a_1+a_2+...+a_n}\over n} $$
Finally, we find the second derivative of $f$, which is the following: $$f''(x)=2n$$
Since $f''(x)>0,\ \ ∀\ \ x ∈ ℝ$, $f$ is strictly convex in $ℝ$ and therefore the extremum we found above, which is the arithmetic mean of $a_1+a_2+...+a_n$, is a global minimum.