Show that there exists $x_0\in(a,b)$ such that $f(x_0)=\frac{1}{n}(f(x_1)+f(x_2)+\cdots+f(x_n)).$ 
Question: Suppose that $f:[a,b]\to\mathbb{R}$ is continuous. Let $x_1,x_2,\cdots, x_n$ be any $n$ points in $(a,b).$ Show that there exists $x_0\in(a,b)$ such that $$f(x_0)=\frac{1}{n}(f(x_1)+f(x_2)+\cdots+f(x_n)).$$

Solution: Let $g:[a,b]\to\mathbb{R}$ be such that $$g(x)=nf(x)-\sum_{k=1}^nf(x_k), \forall x\in[a,b].$$ Observe that to prove the statement of the problem it is enough to show that $g(x_0)=0$ for some $x_0\in(a,b)$.
Now note that by the 3rd form of the Pigeon Hole principle we can conclude that there exists $1\le i,j\le n$ such that $$f(x_i)\le \frac{1}{n}\sum_{k=1}^nf(x_k)\le f(x_j)\\\implies nf(x_i)\le \sum_{k=1}^nf(x_k)\le nf(x_j).$$ Thus, $g(x_i)=nf(x_i)-\sum_{k=1}^nf(x_k)\le 0$ and $g(x_j)=nf(x_j)-\sum_{k=1}^nf(x_k)\ge 0.$ Now if $g(x_i)=0$ or $g(x_j)=0$, then we are done. Thus, let us assume that $g(x_i)<0$ and $g(x_j)>0$. Now since $f$ is continuous on $[a,b]$, implies that $g$ is continuous on $[a,b]$. Therefore, by IVT we can conclude that there exists $x_0\in(x_i,x_j)$ or $x_0\in(x_j,x_i)$ such that $g(x_0)=0$. This completes the proof.
Is this solution correct and rigorous enough and is there any other way to solve the problem?
 A: Your proof looks fine to me. There is no need however to introduce the function $g$. You know that
$$
f(x_i)\le \frac{1}{n}\sum_{k=1}^nf(x_k)\le f(x_j)
$$
for some indices $i, j$, so you can just apply the intermediate value theorem to $f$ on the interval $I = [\min(x_i, x_j), \max(x_i, x_j)]$ and conclude that $\frac{1}{n}\sum_{k=1}^nf(x_k) = f(x)$ for some $x \in I$.
Instead of using the pigeon hole principle you can also apply the mean value theorem to $f$ on the interval $J= [\min_k x_k, \max_k x_k] \subset (a, b)$ because
$$
m\le \frac{1}{n}\sum_{k=1}^nf(x_k)\le M
$$
with $m = \min_J f(x)$ and $M = \max_J f(x)$.
A: Given a continuous $f(x)$, an iterated application of the Intermediate value Theorem
gives
$$
\eqalign{
  & \exists x_{1,2}  \in \left[ {x_1 ,x_2 } \right]:f(x_{1,2} ) = t\;f(x_1 ) + \left( {1 - t} \right)f(x_2 )\quad \left| {\,0 \le t \le 1} \right.  \cr 
  & \exists x_{2,3}  \in \left[ {x_2 ,x_3 } \right]:f(x_{2,3} ) = u\;f(x_2 ) + \left( {1 - u} \right)f(x_3 )\quad \left| {\,0 \le u \le 1} \right. \cr} 
$$
which express the possibility of finding a point corresponding to the weighted mean within each interval.
Putting $t=2/3, \, u=1/3$, we can write
$$
\eqalign{
  & \exists x_{1,2}  \in \left[ {x_1 ,x_2 } \right]:f(x_{1,2} ) = {2 \over 3}\;f(x_1 ) + {1 \over 3}f(x_2 )\quad \left| {\,0 \le t \le 1} \right.  \cr 
  & \exists x_{2,3}  \in \left[ {x_2 ,x_3 } \right]:f(x_{2,3} ) = {1 \over 3}\;f(x_2 ) + {2 \over 3}f(x_3 )\quad \left| {\,0 \le u \le 1} \right.  \cr 
  & \exists x_{1,3}  \in \left[ {x_1 ,x_2 } \right] \cup \left[ {x_2 ,x_3 } \right]:f(x_{1,3} ) = {1 \over 2}\,f(x_{1,2} ) + {1 \over 2}f(x_{2,3} ) =   \cr 
  &  = {{f(x_1 ) + f(x_2 ) + f(x_3 )} \over 3} \cr} 
$$
and the extension to n points is clear.
A: Here's yet another solution:
Pick $i$ with
\begin{align}
f(x_i) &\le f(x_k)$ & \text{for all $k = 1, \ldots, n$.} \tag{1}
\end{align}
Pick $j$ with
\begin{align}
f(x_j) &\ge f(x_k)$ & \text{for all $k = 1, \ldots, n$.} \tag{2}
\end{align}
If $i = j$, then all $x_k$ are equal, and $x_0 = x_i$ solves the problem.
Consider the case $i < j$; the $i > j$ case is almost identical. But equation $1$, we have
$$
n f(x_i) \le \sum_k f(x_k)
$$
By equation 2, similarly $n f(x_j) \ge \sum_k f(x_k)$.
Then by the Intermediate value theorem, there's an $x_0 \in [x_i, x_j]$ such that
$$
f(x_0) = \frac{1}{n} \sum_k f(x_k). 
$$
