Application of Rolle's theorem in a problem For $n\in\mathbb {N}$, we define the function $g_n$ by: for $x\in\mathbb {R} $
$$
g_0 (x)=1\\ g_n (x)=\frac {x (x-1)...(x-n+1)}{n!}
$$
Let $f:[0, + \infty [ \to\mathbb { R}$ be a map of class $C^\infty $. We suppose that there exists a unique sequence  $(a_n)_n $ such that: for all $n\in\mathbb {N}$
$$
\sum_{k=0}^{n}{a_kg_k (x)}=f (x)\qquad \forall x\in\{0,1,...,n\}\qquad(*)
$$
Problem
Let $x \in [0, + \infty[ $. Show that:
$$
\forall N\in \mathbb {N},\exists \theta\in \mathbb {R}\text { such that } f (x)=\sum_{k=0}^{N}{a_kg_k (x)}+g_{N+1}(x)f^{(N+1)}(\theta)
$$
for the case $x\in \{0,1,...,N\} $, from (*), it is evident. But for the case $x\notin \{0,1,...,N\} $ I have no idea I only have this indication:
Hint : use the auxiliary function $t \to f (t)= \sum_{k=0}^{N}{a_kg_k (t)}+Ag_{N+1}(t)$, where A is a suitably chosen constant and apply the rolle's theorem).
An idea please.
 A: Given $x\in\Bbb R\setminus\{0,1,\ldots,N\}$, consider $h(t)=\sum_{k=0}^{N}{a_kg_k (t)}+Ag_{N+1}(t)-f(t)$ with $A$ a constant such that $h(x)=0$. Then $A=\dfrac{f(x)-\sum_{k=0}^{N}{a_kg_k (t)}}{g_{N+1}(x)}$ (we can divide by $g_{N+1}(x)$ because $x\notin\{0,1,\ldots,N\}$). Moreover, $h(y)=0$ for all $y\in\{0,1,\ldots,N\}$. Besides, $h$ is $C^\infty$.
Thus $h$ has at least N+1 roots, so by Rolle's theorem $h'$ has at least N roots, each one between two roots of $h$. Applying Rolle's theorem again, $h''$ has at least N-1 roots; again, $h'''$ has at least N-2 roots. And so on, until we arrive at $h^{(N+1)}$, which will have at least one root. Let's call this root $\theta$.
We have that $h(t)=\sum_{k=0}^{N}{a_kg_k (t)}+Ag_{N+1}(t)-f(t)$ and each $g_k$ is a polynomial of degree $k$, so when we differentiate N+1 times the only polynomial that will "survive" (not disappear by differentiation so it becomes $0$) is $g_{N+1}$, since is the only one with degree greater or equal to N+1. The leading term of $Ag_{N+1}$ is $\dfrac{Ax^{N+1}}{(N+1)!}$, so when differentiating N+1 times we get $A$. Then $h^{(N+1)}(t)=A-f^{(N+1)}(t)$. We know it has a root we called $\theta$, so $h^{(N+1)}(\theta)=0=A-f^{(N+1)}(\theta)$, and then $A=f^{(N+1)}(\theta)$.
Now remember we know what $A$ is, since we demanded it to make true $h(x)=0$. We had that $A=\dfrac{f(x)-\sum_{k=0}^{N}{a_kg_k (x)}}{g_{N+1}(x)}$, and know we have $A=f^{(N+1)}(\theta)$, so finally
$f(x)=\sum_{k=0}^{N}{a_kg_k (x)}+g_{N+1}(x)f^{(N+1)}(\theta)$.
Note: Since we got $\theta$ by Rolle's theorem, we know something more about it: $\theta\in(0,N)$.
