Partially equal different infinitely differentiable functions I was wondering if it's possible to have two infinitely differentiable functions $f(x)$ and $g(x)$ such that there exists $a<b$ that for all $x \in [a,b] $, $f(x)=g(x)$, but there exists a different $c$ for which $f(c) \neq g(c)$. My best try was $f(x) = x$ if $ x \geqslant 0$ and $f(x) = \sin(x)$ otherwise. That function graph is

But even that function doesn't have a fifth derivative. I can't think on a way to prove that, so any help/counter-example would be very helpful, thanks.
 A: Consider the function $\,f : \mathbb R \to \mathbb R\,$ defined by
$$ f(x) :=
\begin{cases}
0 & [x\leq0] \\[1ex] e^{-1/x} & [x>0]
\end{cases}
$$
We'll prove that $f\in C^\infty(\mathbb R, \mathbb R)$. Therefore there are infinitely many $C^\infty$-functions  $\;\mathbb R \to \mathbb R\;$ that coincide in $]-\infty,0]$. Indeed, for each $\alpha\in\mathbb R$ the function $\alpha f$ belongs to $C^\infty(\mathbb R,\mathbb R)$ and is zero in $]-\infty,0]$.
Since $f$ is obviously continuous and infinitely differentiable at every $x\neq 0$, it suffices to prove that the same is true at $x=0$.
First, $f$ is continuous at $0$:
$$ \lim_{x\to 0^+}f(x) = \lim_{x\to 0^+}e^{-1/x} = 0 = f(0) = \lim_{x\to0^-}f(x). $$
Moving on to differentiability, let's observe that for $x>0$ the $n^\text{th}$ derivative of $f$ at $x$ is given by
$$ D^n f(x) = e^{-1/x}P_n(1/x) \qquad\qquad[x>0] \tag{*}\label{Dn} $$
where $P_n\in\mathbb R[X]$ is a polynomial (whose degree depends on $n$, but in general is $\neq n$) with coefficients in $\mathbb R$. Indeed \eqref{Dn} is true for $n=1$:
$$ Df(x) = e^{-1/x}\,\frac1{x^2} \qquad\qquad[\implies P_1(X)=X^2]$$
and if \eqref{Dn}is verified for $n$, we have
\begin{align}
D^{n+1}f(x) &= D(D^nf)(x) = D\{t\mapsto e^{-1/t}P_n(1/t)\}(x) = \\[1ex]
&= e^{-1/x}\,\frac1{x^2}P_n(1/x)+e^{-1/x}DP_n(1/x)(-\frac1{x^2}) = \\[1ex]
&= e^{-1/x}P_{n+1}(1/x)
\end{align}
where
$$P_{n+1}(X) = X^2P_n(X)-X^2DP_n(X)\quad\quad$$
[observe that the derivative of a polynomial is also a polynomial],$\quad$ q.e.d.
Note that \eqref{Dn} also holds for $n=0$ if conventionally we put $D^0f(x)=f(x)$. In this case $P(X)=1$ (always for $x>0$).
Now, we can conclude by induction on $n$. For $n=1$ we have
\begin{align}
D_+f(0) &= \lim_{x\to0^+}\frac{f(x) -f(0)}{x-0} = \lim_{x\to0^+}\frac{e^{-1/x}}{x} = [\text{putting } 1/x=y] = \\[1ex]
&= \lim_{y\to+\infty}\frac{y}{e^y} = \text{[de l'H$\hat{\text{o}}$pital]} = \lim_{y\to+\infty}\frac1{e^y} = 0
\end{align}
and so $Df(0) =0$, since obviously $D_-f(0)=0$.
Step $\,n\to n+1\!:\;\;$ If $D^nf(0)=0$, we have
\begin{align}
D_+^{n+1}f(0) &= \lim_{x\to0^+}\frac{D^nf(x) - D^nf(0)}{x-0} = \lim_{x\to0^+}\frac{D^nf(x)}{x} = \\[1ex]
&= \lim_{x\to0^+}\frac{e^{-1/x}P_n(1/x)}{x} = \text{[obvious notations]} = \\[1ex]
&= \lim_{x\to0^+}\frac{e^{-1/x}(a_0+a_1\frac 1 x+\ldots+a_N\frac1{x^N})}x = \\[1ex]
&= \sum_{k=0}^N \lim_{x\to 0^+}e^{-1/x}\frac{a_k}{x^{k+1}}=0
\end{align}
because
$$ \lim_{x\to0^+}a_k\frac{e^{-1/x}}{x^{k+1}}=0 $$
by repeated application of de l'H$\hat{\text{o}}$pital's rule,$\quad$ q.e.d.
It follows that
$$D^nf(0)=0, \qquad \forall n=1,2,3,\ldots$$
since obviously $D_-^nf(0)=0.$
$\bf \text{Note.}\quad$ A faster but less direct way to achieve the same result is to use the following theorem:
$\hskip.5ex$
Let $f : I \to \mathbb R\quad$(I an interval of $\mathbb R$)$\;$ be a continuous function, derivable in $I-\{a\}$, where $a\in I$. If the limit
$$ \lim_{x\to a}Df(x) $$
exists and is finite, then $f$ is derivable even in $a$, and
$$ Df(a) = \lim_{x\to a}Df(x). $$
$\hskip.5ex$
Just apply the previous theorem to the function $x\mapsto D^nf(x)$ in \eqref{Dn}.
