Use MVT to show $f'(x)=g'(x)$ implies $f(x)=g(x)+c$ for some $c\in \mathbb{R}$ Use the Mean Value Theorem to prove:
If $f$ and $g$ are defined on the same interval and $f'(x)=g'(x)$ for all $x$ in the interval, then there is some $c\in\mathbb{R}$ such that $f=g+c$.
My attempt:
Let the interval be $[a, b]$.
Let $d$ be any point in $(a, b]$
$f$ and g are continuous on $[a, d]$ and differentiable on $(a, d)$. 
So, by the Mean Value Theorem, $\exists d_1\in(a, d)$ such that
$\displaystyle f'(d_1)=\frac{f(d)-f(a)}{d-a}$
By the Mean Value Theorem, $\exists d_2\in (a, d)$ such that
$\displaystyle g'(d_2)=\frac{g(d)-g(a)}{d-a}$
If we could somehow show that $f'(d_1)=g'(d_2)$, we would have 
$\displaystyle\frac{f(d)-f(a)}{d-a}=\frac{g(d)-g(a)}{d-a}$
$\implies f(d)-f(a)=g(d)-g(a)$
$\implies f(d)=g(d)+f(a)-g(a)\ \forall d\in(a, b]$
But I don't know how to prove that $f'(d_1)=g'(d_2)$, although I think it's true. Any suggestions would be greatly appreciated.
 A: Let $f,g$ be differentiable on $]a,b[$.
Note that mean-value theorem gives that $a\leq x < y \leq b$ implies there is some $x < c <y$ such that $(f-g)(x) - (f-g)(y) = (f'-g')(c)(x-y)$.
Note that $(f'-g')(c) = 0$ by assumption,
so $(f-g)(x) - (f-g)(y) = 0$ for all $a \leq x < y \leq b$,
and hence $f-g$ is constant on $]a,b[$.
A: Consider the function $h = f - g$ on $[a,b]$. Then $h$ is differentiable with derivative $0$ on $(a,b)$. Let $x\in (a,b]$. Then by the mean value theorem, there exists $c\in (a,x)\subseteq (a,b)$ such that $h'(c) = \frac{h(x) - h(a)}{x - a}$. $h'(c) = 0$ by assumption, so
$$
\frac{h(x) - h(a)}{x - a} = 0,
$$
implying
$$
h(x) = h(a).
$$
But $x$ was arbitrary, so that $h(x) = h(a)$ for all $x\in[a,b]$, which implies $h(x) = f(x) - g(x) = h(a)$, which is a constant, so rearranging gives $f(x) = g(x) + h(a)$ on $[a,b]$.
The trick is to consider $f$ and $g$ at the same time by considering their difference (which you know the derivative of!). While it will be true that $f'(d_1) = g'(d_2)$ here, I don't know how to show this without showing that $d_1 = d_2$, which can be true, but also cannot be guaranteed (for example, if $f'$ achieves the value $f'(d_1)$ at more than one point in the interval). By looking at $f - g$, you obtain only one point via the mean value theorem, which eliminates the issue of needing to force $d_1 = d_2$.
