Let f be a continuous real valued function on the compact interval [a,b]. Given ϵ>0, show that there is a polynomial p such that: |p(x)−f(x)|<ϵ Let $f$ be a continuous real valued function on the compact interval $[a,b]$. Given $\epsilon > 0$, show that there is a polynomial $p$ such that:
$p(a)=f(a)$,
$p'(a)=0$
and $|p(x) - f(x)| < \epsilon$
This is a question I came across in Pugh's Real Mathematical Analysis.
Is this not a simple application of the Weierstrass Approximation Theorem and the fact that the set of polynomials is dense in
$C^0([a, b], \mathbb{R})$.
Density means that for each $f \in C^0$ and each $\epsilon > 0$ there is a polynomial function $p(x)$ such that for all $x \in [a, b]$,
$|f(x) − p(x)| < \epsilon$. So the third property being asked is immediately satisfied.
Is this correct?
But how does this imply that $p(a)=f(a)$ and $p'(a)=0$?
Am I misreading the question or not understanding it at all? Any tips or clarifications would be greatly appreciated.
$\mathbf{Edit:} \mathbf{ Attempted} \mathbf{ Solution}$
$f(x)$ is a continuous function on the compact interval $[a,b]$.
By the Weierstrass Approximation Theorem we can find a polynomial $q(x)$ such that:
$|f(x)-q(x)|<\epsilon/2$
So, let $p(x)=q(x)-q(a) +f(a)$, then $p(a)=f(a)$
Given $\epsilon > 0$,
define $q(x) = (\frac{b-a}{n}$)$(\frac{x-a}{b-a})^n$ for large $n$
Then,
$q'(x)=(\frac{x-a}{b-a})^{n-1}$ so $q'(a)= 0$ and thus $p'(a)=0$
Finally,
$|p(x) - f(x)| < |q(x) - f(x)| + |q(a)-f(a)|$
$|p(x) - f(x)| < \epsilon/2 + \epsilon/2$
$|p(x) - f(x)| < \epsilon$
Is this a reasonable solution? Thank you kindly.
 A: Getting $p(a) = f(a)$ is easy, just replace $p(x)$ by $p(x)-p(a)+f(a)$ (and get $2\epsilon$ instead of $\epsilon$, but that is easily overcome by starting with $\epsilon/2$ in the original application of Weierstrass' Theorem).
For the second part, by a similar argument, it can be seen to be equivalent to this: given $\epsilon>0$ and $v \in \mathbb R$, find a polynomial $q(x)$ such that $|q(x)| < \epsilon$ on $[a,b]$, and $q'(a) = v$.  One way to do this is to find a positive integer $n$ so that
$$ \eta = \frac{(b-a)v}{n \epsilon} $$
satisfies $|\eta| < 1$, and setting
$$q(x) = \epsilon \eta \left(\frac{b-x}{b-a}\right)^n .$$
A: Consider
$$\mathcal{A} = \{ g(x) \in C^0([a, b], \mathbb{R}) | g'(a) = 0 \}.$$
It's pretty clear that $\mathcal{A}$ is a function algebra. Since $1, x^3 - 3a^2 \in \mathcal{A}$, then $\mathcal{A}$ vanishes nowhere and separates points. By Stone-Weierstrass, $\mathcal{A}$ is dense in $C^0([a, b], \mathbb{R})$, and so for any $\varepsilon > 0$, there is some $q(x) \in \mathcal{A}$ such that $|q(x) - f(x)| < \frac{\varepsilon}{2}$.
Then you can define $p(x) = q(x) - q(a) + f(a)$ as you have in your current answer, which would satisfy all three properties you need.
