Consider the closed interval $[0,1]$ and let $f \in C[0,1]$. Let $g$ be a real valued function on $[0,1]$ such that $g \leq f$.


1. Suppose $g = f$ at atmost finitely many points. Does there exist a polynomial $p$ such that $g \leq p \leq f$? As pointed out in comments below, if $f^{(n)}(x) = g^{(n)}(x)=0$ for some $x \in [0,1]$ and for every $n \geq 0$, any such polynomial must be identically zero. Are there other conditions that also pose an obstruction to the existence of such polynomials?
2. What minimum extra assumptions does one need to make on $f,g$ for such polynomials to exist?



Polynomial approximation (Weierstrass theorem) with bounds
As I have commented, if $f,g:[0,1]\rightarrow\mathbb{R}$ are $C^{\infty}$ functions, and $c\in(0,1)$ is a real number with $f^{(n)}(c)=g^{(n)}(c)$ for each $n$, and $f(x)\leq g(x)$ for each $x\in[0,1]$, then there can be at most one polynomial $p$ with $f(x)\leq p(x)\leq g(x)$ for each $x\in[0,1]$, and one can easily set up $f,g$ so that there are no polynomials $p$ such that $f(x)\leq p(x)\leq g(x)$.


On the other hand, we shall see that if
$f,g:[0,1]\rightarrow\mathbb{R}$ are $C^{\infty}$-functions with


1. $f\leq g$
2. there are only finitely many points $c\in[0,1]$ with $f(c)=g(c)$,
3. if $c\in[0,1]$ and $f(c)=g(c)$, then there is some $n$ with $f^{(n)}(c)\neq g^{(n)}(c)$,


then there is some polynomial $p$ such that $f(x)\leq p(x)\leq g(x)$ whenever $x\in[0,1]$.


To get a generalized version of this result, we will need the following powerful generalization of the Stone-Weierstrass theorem from complex analysis.



> 
> Theorem: (Mergelyan's Theorem) Suppose that $K\subseteq\mathbb{C}$ and
> $K$ is compact and $K\setminus\mathbb{C}$ is connected. Then whenever
> $f:K\rightarrow\mathbb{C}$ is a continuous function that is
> holomorphic on $K^{\circ}$ and $\epsilon>0$, there is some polynomial
> $p$ such that $|(f-p)(z)|<\epsilon$ whenever $z\in K$.
> 
> 
> 


Mergelyan's theorem is a well-known result from complex analysis. We are using Mergelyan's theorem because we need the maximum modulus theorem in order to get $f\leq h\leq g$ around the points $c$ where $f(c)=g(c)$ (we have more to work with if we approximate a holomorphic function rather than simply a continuous function as we would with the Stone-Weierstrass theorem). We will need a slight and easy to prove strengthening of Mergelyan's theorem.



> 
> Corollary: Suppose that $K$ is a compact subset of $\mathbb{C}$ and
> $K\setminus\mathbb{C}$ is connected. Suppose furthermore that
> $c\_{1},\dots,c\_{r}\in K^{\circ}$ and $n$ is a natural number. Let
> $f:K\rightarrow\mathbb{C}$ be a continuous function that is
> holomorphic on $K^{\circ}$. Then for each $\epsilon>0$, there is a
> polynomial $q$ such that $|(f-q)(z)|<\epsilon$ for each $z\in K$ and
> where $f^{(m)}(c\_{k})=q^{(m)}(c\_{k})$ whenever $1\leq k\leq r$ and
> $0\leq m\leq n$.
> 
> 
> 


Proof: There is some $N$ and polynomials $p\_{k,s}$ of degree at most $N$ where
$p\_{k,s}^{(m)}(c\_{j})=\delta\_{k,j}\delta\_{s,m}$ whenever $1\leq k\leq r,1\leq j\leq r,1\leq m\leq n,1\leq s\leq n$. Now, for $1\leq j\leq r$, let
$\rho\_{j}$ be the largest real number such that $B\_{\rho\_{j}}(c\_{j})\subseteq K$.


Suppose that $\delta>0$. Then from Mergelyan's theorem, there exists a polynomial $p$ such that $|(f-p)(x)|<\delta$ for each $x\in K$. In this case, we have $$|(f-p)^{(m)}(c\_{j})|\leq\frac{m!\cdot\delta}{\rho\_{j}^{m}}$$ for $0\leq m\leq n,1\leq j\leq r$.
Let $$q=p+\sum\_{k=1}^{r}\sum\_{s=0}^{n}p\_{k,s}\cdot(f-p)^{(s)}(c\_{k}).$$ Then
$q^{(m)}(c\_{j})=f^{(m)}(c\_{j})$. Therefore, $$|(q-p)(z)|\leq\sum\_{k=1}^{r}\sum\_{s=0}^{n}|p\_{k,s}(z)(f-p)^{(s)}(c\_{k})|
\leq\sum\_{k=1}^{r}\sum\_{s=0}^{n}|p\_{k,s}(z)|\cdot\frac{s!\delta}{\rho\_{l}^{s}}.$$


Therefore, if $M\_{k,s}=\max\{|p\_{k,s}(z)|:z\in K\}$, then
$$|(q-p)(z)|\leq\sum\_{k=1}^{r}\sum\_{s=0}^{n}M\_{k,s}\cdot\frac{s!\delta}{\rho\_{l}^{s}}
=\delta\cdot\sum\_{k=1}^{r}\sum\_{s=0}^{n}M\_{k,s}\cdot\frac{s!}{\rho\_{l}^{s}}$$
whenever $z\in K$. Therefore, if $z\in K$, then
$$|(f-q)(z)|\leq|(f-p)(z)|+|(p-q)(z)|=\delta\cdot[1+\sum\_{k=1}^{r}\sum\_{s=0}^{n}M\_{k,s}\cdot\frac{s!}{\rho\_{l}^{s}}].$$


Since the quantity $$\delta\cdot[1+\sum\_{k=1}^{r}\sum\_{s=0}^{n}M\_{k,s}\cdot\frac{s!}{\rho\_{l}^{s}}]$$ can be made arbitrarily close to zero, the theorem holds. Q.E.D.



> 
> Theorem: Suppose the following:
> 
> 
> 1. $f,g:[0,1]\rightarrow\mathbb{R}$ are continuous functions such that $f(x)\leq g(x)$ for all $x\in[0,1]$.
> 2. there are only finitely many points $c$ with $f(c)=g(c)$.
> 3. $f(0)<g(0)$ and $f(1)<g(1)$.
> 4. If $f(c)=g(c)$, then there exists some polynomial $p$, natural number $n$, constant $\alpha>0$, and open neighborhood $U$ of $c$ such
> that $$f(x)\leq p(x)-\alpha|x-c|^{n}\leq p(x)+\alpha|x-c|^{n}\leq
>  g(x)$$ for all $x\in U$.
> 
> 
> 



> 
> Then there exists a polynomial $p$ such that
> $f(x)\leq p(x)\leq g(x)$ for each $x\in[0,1]$.
> 
> 
> 


Proof: Let $\{c\_{1},\dots,c\_{r}\}$ be the set of all points $c$ such that $f(c)=g(c)$. Assume that $c\_{1}<\dots<c\_{r}$. Then there exists some $n$,$\alpha>0$, and $\rho>0$ along with polynomials $p\_{1},\dots,p\_{r}$ such that
$$f(x)\leq p\_{j}(x)-\alpha|x-c\_{j}|^{n}\leq p\_{j}(x)+\alpha|x-c\_{j}|^{n}\leq g(x)$$ whenever $|x-c\_{j}|<\rho$.


Now, there is a polynomial $P(x)$ along with $\beta>0$ and a $\delta>0$ such that
$$f(x)\leq P(x)-\beta|x-c\_{j}|^{n}\leq P(x)+\beta|x-c\_{j}|^{n}\leq g(x)$$
whenever $|x-c\_{j}|<\delta$ and $1\leq j\leq r$; the polynomial $P(x)$ is simply a polynomial such that $P^{(m)}(c\_{j})=p\_{j}^{(m)}(c\_{j})$ for $0\leq m\leq n$. Therefore, if we set $f^{\sharp}=f-P,g^{\sharp}=g-P$, then $$f^{\sharp}(x)\leq-\beta|x-c\_{j}|^{n}\leq\beta|x-c\_{j}|^{n}\leq g^{\sharp}(x)$$ whenever $|x-c\_{j}|<\delta,1\leq j\leq r$.


Now let $\delta\_{0}<\delta$, and let $$C=[0,1]\cup \overline{B\_{\delta\_{0}}(c\_{1})}\cup\dots\overline{B\_{\delta\_{0}}(c\_{1})}$$ where the balls $B\_{\delta\_{0}}(c\_{j})$ are in the complex plane. Now, let $h:C\rightarrow\mathbb{R}$ be a continuous function such that $f^{\sharp}(x)\leq h(x)\leq g^{\sharp}(x)$ for $x\in[0,1]$ and where $h(z)=0$ whenever $z\in \overline{B\_{\delta\_{0}}(c\_{j})},1\leq j\leq r$, and where $f^{\sharp}(x)<h(x)<g^{\sharp}(x)$ whenever $x\in[0,1]\setminus(B\_{\delta\_{0}}(c\_{1})\cup\dots B\_{\delta\_{0}}(c\_{1}))$


Now, let $\epsilon>0$ and apply our extension of Mergelyan's theorem to obtain a polynomial $q$ such that $|q(z)-h(z)|<\epsilon$ for each $z\in C$ and where $q^{(m)}(c\_{j})=0$ whenever $0\leq m<n,1\leq j\leq r$.


Now, since $q^{(m)}(c\_{j})=0$ for $0\leq m<n$, the function $\frac{q(z)}{(z-c\_{j})^{n}}$ is holomorphic on $B\_{\delta\_{0}}(c\_{j})$ and does not have modulus greater than $\frac{\epsilon}{\delta\_{0}^{n}}$ on the boundary $\partial B\_{\delta\_{0}}(c\_{j})$. Therefore, by the maximum modulus theorem, we know that
$|\frac{q(z)}{(z-c\_{j})^{n}}|\leq\frac{\epsilon}{\delta\_{0}^{n}}$ for each
$z\in B\_{\delta\_{0}}(c\_{j})$. Therefore, $|q(z)|\leq(z-c\_{j})^{n}\cdot\frac{\epsilon}{\delta\_{0}^{n}}$ for each $z\in B\_{\delta\_{0}}(c\_{j})$.


Now, if we set $\epsilon$ small enough so that $\frac{\epsilon}{\delta\_{0}^{n}}\leq\beta$, then $|q(z)|\leq\beta|z-c\_{j}|^{n}$ for each $z\in B\_{\delta\_{0}}(c\_{j})$.


Now, $q(z)$ is a complex polynomial with complex coefficients, but we need a real polynomial. Therefore, define $Q(z)=(q(z)+\overline{q(\overline{z})})/2$. Then if $x$ is real, then $Q(x)=\text{Re}(q(x))$. Therefore, if $|x-c\_{j}|<\delta\_{0}$, then
$$f^{\sharp}(x)\leq-\beta|x-c\_{j}|^{n}\leq Q(x)\leq\beta|x-c\_{j}|^{n}\leq g^{\sharp}(x).$$
Now, observe that $$|Q(x)-h(x)|\leq|q(x)-h(x)|<\epsilon$$ whenever $x\in[0,1]$. Now, let
$$B=[0,1]\setminus(B\_{\delta\_{0}}(c\_{1})\cup\dots B\_{\delta\_{0}}(c\_{1})).$$ Then $B$ is a compact set and $f^{\sharp}(x)<h(x)<g^{\sharp}(x)$ for each $x\in B$. Therefore, since
$$\min(g^{\sharp}(x)-h(x),h(x)-f^{\sharp}(x))>0$$ for each $x\in B$, by compactness, there is some $\zeta>0$ such that $$\min(g^{\sharp}(x)-h(x),h(x)-f^{\sharp}(x))\geq\zeta$$ for each $x\in B$. Therefore, if we select $\epsilon$ small enough so that $\epsilon<\zeta$, then we have
$$f^{\sharp}(x)<h(x)-\epsilon<Q(x)<h(x)+\epsilon<g^{\sharp}(x)$$ for each $x\in B$. We therefore conclude that if $\epsilon$ is small enough, then $f^{\sharp}(x)\leq Q(x)\leq g^{\sharp}(x)$ for all $x\in[0,1]$.


Therefore, $f=f^{\sharp}+P\leq Q+P\leq g^{\sharp}+P=g$. Q.E.D.


We have obtained necessary and sufficient conditions for when one can find infinitely many polynomials $p$ with $f\leq p\leq g$.



> 
> Corollary: Suppose that $f,g:[0,1]\rightarrow\mathbb{R}$ are
> continuous functions with $f(0)<g(0),f(1)<g(1)$ and $f\leq g$. Then
> there are infinitely many polynomials $p$ with $f(x)\leq p(x)\leq g(x)$ if and only if
> 
> 
> 1. there are only finitely many points $c\in[0,1]$ with $f(c)=g(c)$, and
> 2. if $f(c)=g(c)$, then there is a polynomial $p$ along with an open neighborhood $U$ of $c$, a natural number $n$ and a constant
> $\alpha>0$ such that $f(x)\leq p(x)-\alpha|x-c|^{n}\leq
>  p(x)+\alpha|x-c|^{n}\leq g(x)$ for each $x\in U$.
> 
> 
> 


