Theorem 1. Let $f$ be a function that satisfies the following conditions: (1) $f$ is continuous on $[a, b]$. (2) $f$ is differentiable on $(a, b)$ (3) $f(a) = f(b)$ Then there is a number $c \in (a, b)$ such that $f'(c) = 0$.
Proof. We may think of three cases. (1) If $f(x) = k$ for any constant $k$, then $c$ can be taken to be any number in $(a, b)$. (2) If $f(x) > f(a), \forall x \in (a, b)$, there is an absolute maximum value $c \in (a, b)$ by the Extream Value Theorem. Since $c$ is also the local maximum value, by Fermat's Theorem, we have that $f'(c) = 0$. (3) Similarly, we obtain the same result as (2). $\blacksquare$
The Mean Value Theorem
Theorem 2. Let $f$ be a function that satisfies the following conditions: (1) $f$ is continuous on $[a, b]$. (2) $f$ is differentiable on $(a, b)$ Then there is a number $c \in (a, b)$ such that $$f'(c) = \frac{f(b) - f(a)}{b-a}.$$
Proof. Let $g$ be a linear function such that $g(a) = f(a)$ and $g(b) = f(b)$. Define the function $h$ such that $h(x) = f(x) - g(x)$. Then we have that $h$ satisfies the conditions of Rolle's Theorem. Thus there is a number $c \in (a, b)$ that $h'(c) = 0$. This means that $$h'(c) = f'(c) - g'(c) = 0 \\ \Longrightarrow f'(c) = g'(c) = \frac{f(b) - f(a)}{b - a}. \blacksquare$$
Corollary
Corollary. Let $f$ and $g$ be functions satisfying the conditions of Theorem 2. Then (1) If $f'(x) = 0, \forall x \in (a, b)$, then $f(x) = C, \forall x \in (a, b)$, where $C$ is a constant. (2) If $f'(x) = g'(x), \forall x \in (a, b)$, then there exists a constant $C$ such that $f(x) = g(x) + C, \forall x \in (a, b)$.
Proof.(1) Let $x_1, x_2 (x_1 < x_2)$ be arbitrary numbers in $[a, b]$. Then by the Mean Value Theorem, there is a number $c \in (x_1, x_2)$ such that $$f'(c) = 0 = \frac{f(x_2) - f(x_1)}{x_2 - x_1}.$$ Thus we have $f(x_1) = f(x_2)$, which means that $f(x) = C = x_1 = x_2, \forall x \in (a, b)$. (2) Define a function $h$ by $h(x) = f(x) - g(x)$. Then $h'(x) = f'(x) - g'(x)$ and by applying Corollary (1), we have $f(x) - g(x) = C \Longleftrightarrow f(x) = g(x) + C$. $\blacksquare$