If $f(x) \leq g(x)$ for all $x$ and $f(a) = g(a)$ then $f'(a) = g'(a)$? 
Let $f(x) \leq g(x)$ for all $x$ in an open set $D$, and let $a$ be an interior point of $D$ such that $f(a) = g(a)$ and both $f, g$ are differentiable at $a$.
  Does it follows that $f'(a)=g'(a)$?

Is that right, and if so, why? If not then please give examples.
 A: By assumption, the differentiable function $h(x) := g(x) - f(x)$ has a minimum point at $a$.
Since $a$ is an interior point, then $h'(a) = 0$, i.e. $f'(a) = g'(a)$.
A: Proof
I will give a proof for the problem as follows, which totally depends on some most basic facts of calculus.
According to the assumptions, $$\frac{f(x)-f(a)}{x-a}\leq \frac{g(x)-g(a)}{x-a},\tag1$$where $x$ belongs to some right neighborhood of $a.$ And$$\frac{f(x)-f(a)}{x-a}\geq \frac{g(x)-g(a)}{x-a},\tag2$$where $x$ belongs to some left neighborhood of $a.$Thus, for $(1)$, let $x \to a+.$ $$\lim_{x \to a+}\frac{f(x)-f(a)}{x-a}\leq \lim_{x \to a+}\frac{g(x)-g(a)}{x-a},\tag 3$$which implies $$f'_+(a) \leq g'_+(a).\tag4$$Likewise, for $(2)$, let $x \to a-.$ $$\lim_{x \to a-}\frac{f(x)-f(a)}{x-a}\geq \lim_{x \to a-}\frac{g(x)-g(a)}{x-a},\tag 5$$which implies $$f'_-(a) \geq g'_-(a).\tag6$$
But by the definition of the differentiability, we have  $$f'(a)=f'_+(a)=f'_-(a),~~~~~g'(a)=g'_+(a)=g'_-(a).\tag7$$
Thus, $(4)$ and $(5)$ claim that $$f'(a) \leq g'(a),~~~~~f'(a) \geq g'(a)\tag8$$respectively, which demands $$f'(a)=g'(a).$$
A: Fundamentally, the intuition here is that if two curves touch each other ($f(a)=g(a)$) and have different derivatives at that point, then one has to actually cross the other. If we are to have $f\leq g$ on the entire interval, then the only way those two curves can touch is if they just "kiss", tangent to each other, and then separate again without actually crossing.
For example, if $f'(a)>g'(a)$, then $f$ is steeper than $g$ at $a$. Therefore, "obviously", at the point $a$, $f$ is cutting up across the curve of $g$ from below, and we will end up with $f(a+h)>g(a)$ for sufficiently small $h$. Now, the question is, how do we turn this visual intuition into a mathematical proof. There are many ways. One is to just look at the definition of the derivative directly. For sufficiently small $h$, we will have:
$$\frac{f(a+h)-f(a)}{h}>\frac{g(a+h)-g(a)}{h}$$
This is true because it's true in the limit $h\to 0$, which means it has to be true for sufficiently small $h$. In detail: if we call the left hand side $A(h)$ and the right hand side $B(h)$, we have $\lim_{h\to 0} A(h)>\lim_{h\to 0} B(h)$, and you can prove from the definition of a limit that this implies $A(h)>B(h)$ for sufficiently small $h$.
Anyway, going back to the inequality, we can cancel out $f(a)$ and $g(a)$ since they're equal to one another and we can multiply both sides by $h$ to get, for sufficiently small $h$:
$$f(a+h)>g(a+h)$$
Which proves exactly what we said: because $f$ is steeper than $g$ at the point $a$, $f$ will be higher than $g$ immediately after $a$.
The case $f'(a)<g'(a)$ can be handled in a similar way.
