Let $f:\mathbb R \rightarrow\mathbb R $ be continuous, and choose $-\infty < a<b<\infty$ and $\epsilon > 0$. Show there exists a polynomial $p$ such that:
a) $p(a)=f(a),\; p(b)=f(b)$
b) $|f(t)-p(t)|<\epsilon$ for all $t\in [a,b]$
The second part is just Weierstrass approximation theorem. But the first part I didn't manage to get. I tried conjuring up a polynomial in the form $$p=p_\epsilon+(\frac{a-x}{a-b})^Nf(b)+(\frac{b-x}{b-a})^Nf(a)$$ such that $p_\epsilon$ satisfies b by the theorem, and then play with constants to set bounds on the maximal error that the extra terms introduce (and also to cancel out $p_\epsilon$ at the bounds). I don't think this can work, since it eventually means that the extra terms are expected to approximate "some portion" of $f$, but given the fact that the proof to Weiersttrass' theorem is pretty complicated, I guess this isn't the way to go... How should I approach this properly? Thanks
Let's do it first for the case $f(a) = f(b)=0.$ Find polynomials $P_n \to f$ uniformly on $[a,b].$ Then verfify that the polynomials
$$Q_n(x)=P_n(x)- P_n(a) -\frac{P_n(b)-P_n(a)}{b-a}(x-a)$$
converge to $f$ uniformly on $[a,b],$ with $Q_n(a) = Q_n(b) = 0$ for all $n.$
In the general case, let $l(x)$ be the linear function connecting $(a,f(a))$ to $(b,f(b)).$ Then $f(x) - l(x)$ equals $0$ at the endpoints. From the above we can find polynomials $Q_n \to f-l$ uniformly on $[a,b],$ with $Q_n(a)= Q_n(b) = 0.$ Now check that $Q_n + l$ satisfies the requirements.