Baby Rudin Theorem 7.26 Here is Theorem 7.26 by Rudin:

If $f$ is a continuous complex function on $[a, b]$, there exists a sequence of polynomials $P_n$ such that
$$ \lim_{n \to \infty} P_n(x) = f(x) $$
uniformly on $[a, b]$. If $f$ is real, the $P_n$ may be taken real.

Here is Rudin's proof:

We may assume, without loss of generality that $[a, b] = [0, 1]$. We may also assume that $f(0) = f(1) = 0$. For if the theorem is proved for this case, consider $$ g(x) = f(x) - f(0) - x [ f(1) - f(0) ] \qquad (0 \leq x \leq 1). $$ Here $g(0) = g(1) = 0$, and if $g$ can be obtained as the limit of a uniformly convergent sequence of polynomials, it is clear that the same is true for $f$, since $f-g$ is a polynomial.


Furthermore, we define $f(x)$ to be zero for $x$ outside $[0, 1]$. Then $f$ is uniformly continuous on the whole line.


We put
$$\tag{47}  Q_n(x) = c_n \left( 1- x^2 \right)^n \qquad (n = 1, 2, 3, \ldots), $$
where $c_n$ is chosen so that
$$ \tag{48} \int_{-1}^1 Q_n(x) \ \mathrm{d} x = 1 \qquad (n = 1, 2, 3, \ldots). $$
We need some information about the order of magnitude of $c_n$. Since
$$ 
\begin{align} 
\int_{-1}^1 \left( 1-x^2 \right)^n \ \mathrm{d} x = 2 \int_0^1 \left( 1-x^2 \right)^n \ \mathrm{d} x &\geq 2 \int_0^{1/\sqrt{n}} \left( 1-x^2 \right)^n \ \mathrm{d} x \\
&\geq 2 \int_0^{1/\sqrt{n}} \left( 1- n x^2 \right) \ \mathrm{d} x \\
&= \frac{4}{3 \sqrt{n} } \\
&> \frac{1}{ \sqrt{n} }, 
\end{align}
$$
it follows from (48) that $$ \tag{49} c_n < \sqrt{n}. $$


The inequality $\left( 1-x^2 \right)^n \geq 1-nx^2$ which we used above is easily shown to be true by considering the function
$$ \left( 1- x^2 \right)^n - 1+nx^2 $$
which is zero at $x= 0$ and whose derivative is positive in $(0, 1)$.


For any $\delta > 0$, (49) implies
$$ \tag{50} Q_n(x) \leq \sqrt{n} \left( 1- \delta^2 \right)^n \qquad ( \delta \leq \lvert x \rvert \leq 1), $$
so that $Q_n \to 0$ uniformly in $\delta \leq \lvert x \rvert \leq 1$.


Now set
$$ \tag{51}  P_n(x) = \int_{-1}^1 f(x+t) Q_n (t) \ \mathrm{d} t \qquad (0 \leq x \leq 1). $$
Our assumptions about $f$ show, by a simple change of variable, that
$$ P_n(x) = \int_{-x}^{1-x} f(x+t) Q_n(t) \ \mathrm{d} t = \int_0^1 f(t) Q_n(t-x) \ \mathrm{d} t, $$
and the last integral is clearly a polynomial in $x$. Thus $\left\{ P_n \right\}$ is a sequence of polynomials, which are real if $f$ is real.


Given $\varepsilon > 0$, we choose $\delta > 0$ such that $\lvert y-x \rvert < \delta$ implies $$ \lvert f(y) - f(x) \rvert < \frac{\varepsilon}{2}. $$
Let $M = \sup \lvert f(x) \rvert$. Using (48), (50), and the fact that $Q_n(x) \geq 0$, we see that for $0 \leq x \leq 1$,
$$ 
\begin{align}
\left\lvert P_n(x) - f(x) \right\rvert &= \left\lvert \int_{-1}^1 [ f(x+t) - f(x) ] Q_n(t) \ \mathrm{d} t \right\rvert \\
&\leq \int_{-1}^1 \lvert f(x+t) - f(x) \rvert Q_n(t) \ \mathrm{d} t \\
&\leq 2M \int_{-1}^{-\delta} Q_n(t) \ \mathrm{d} t + \frac{\varepsilon}{2} \int_{-\delta}^\delta Q_n(t) \ \mathrm{d} t + 2 M \int_\delta^1 Q_n(t) \ \mathrm{d} t \\
&\leq 4M \sqrt{n} \left( 1 - \delta^2 \right)^n + \frac{\varepsilon}{2} \\
&< \varepsilon
\end{align}
$$
for all large enough $n$, which proves the theorem.

Why do we assume that $f(0)=f(1)=0$? Also, why do we define the function $g$ and why the $f(x)$ function should be zero for $x$ outside of $[0,1]$ interval? As it's stated in the theorem $f$ is complex function which is continuous on $[a,b]$. So if we assume all these things stated above, we prove the theorem for certain continuous function and not for every case.
 A: Say a function $f : [a, b] \to \mathbb{R}$, where $a < b$, "has the convergence property" if and only if there is a sequence of polynomials with real coefficients $\{P_i\}_{i \in \mathbb{N}}$ which converges uniformly to $f$ on $[a, b]$ and, furthermore, that $P_i = 0$ for all $i$ whenever $f = 0$ everywhere.
Rudin proves the following theorem:

Theorem 1: For all continuous $f : [0, 1] \to \mathbb{R}$ such that $f(0) = f(1) = 0$, $f$ has the convergence property.

It sounds like you have no questions about the proof of this theorem.
From this theorem, we can then prove the theorem

Theorem 2: For all continuous $f : [0, 1] \to \mathbb{R}$, where $a \leq b$, $f$ has the convergence property.

To prove theorem 2 from theorem 1, define $g(x) = f(x) + x(f(0) - f(1)) - f(0)$. Then $g : [0, 1] \to \mathbb{R}$ is continuous, and $g(0) = g(1) = 0$. So we can take a sequence of polynomials $\{P_i\}_{i \in \mathbb{N}}$ which uniformly converge to $g$ over $[0, 1]$. And furthermore, if $f$ was zero everywhere, then $g$ is zero everywhere, and hence all $P_i$ are zero everywhere.
Define $Q_i(x) = P_i(x) + f(0) + x(f(1) - f(0))$. Then we see that $\{Q_i\}_{i \in \mathbb{N}}$ converge uniformly to $g$. And if the $P_i$ are zero everywhere and $f(0) = f(1) = 0$, then the $Q_i$ are zero everywhere.
From here, we prove

Theorem 3: For all continuous $f : [a, b] \to \mathbb{R}$ where $a < b$, $f$ has the convergence property.

To prove this theorem, define $g(x) = f(x(b - a) + a)$, $g : [0, 1] \to \mathbb{R}$. Now $g$ is continuous and thus has the convergence property by Theorem 2. Take a sequence of polynomials $\{P_i\}_{i \in \mathbb{N}}$ which uniformly converge to $g$ over $[0, 1]$. Then define $Q_i(x) = P_i(\frac{x - a}{b - a}))$. We can show that $\{Q_i\}_{i \in \mathbb{N}}$ converges to $f$ over $[a, b]$. And if $f$ is zero everywhere, then $g$ is zero everywhere, so all $P_i$ are zero, so all $Q_i$ are zero.
Finally, we prove one last theorem:

Theorem 4: For all continuous $f : [a, b] \to \mathbb{C}$ where $a < b$, there is a sequence of polynomials $\{P_i\}_{i \in \mathbb{N}}$ with complex coefficients which uniformly converges to $f$ on $[a, b]$. If $f$ is real-valued, the $P_i$ may be taken to have real coefficients.

Proof: we can write $f(x) = g(x) + h(x) i$ where $g, h : [a, b] \to \mathbb{R}$ are both continuous. Thus, both $g$ and $h$ have the convergence property, so we can write $g$ as the uniform limit of $\{P_i\}_{i \in \mathbb{N}}$ and $h$ as the uniform limit of $\{Q_i\}_{i \in \mathbb{N}}$. Then $f$ is the uniform limit of $\{P_j + i Q_j\}_{j \in \mathbb{N}}$. Furthermore, if $f$ is real-valued, then $h$ is zero everywhere, so the $Q_j$ are zero everywhere, so $P_j + i Q_j$ is real everywhere and hence has real coefficients.
