# Every Continuous Function on an Interval has a Primitive

We distinguish between several types of intervals:

1. Every continuous function $f:\left[0,1\right]\to ℝ$ has a primitive.

Proof:  We use the Weierstrass approximation theorem (click for an alternative ad hoc proof). According to [6.7.2] there is a sequence of polynomials $\left({p}_{n}\right)$ that converges uniformely on $\left[0,1\right]$ to f:

${p}_{n}\underset{gm}{\to }f$

As every polynomial ${p}_{n}$ is integrable due to [8.1.10], the uniform limit f has a primitive according to [8.1.15].

2. Every continuous function $f:\left[a,b\right]\to ℝ$ has a primitive.

Proof:  The function $f\circ \left(a+\left(b-a\right)\cdot \mathrm{X}\right)$ is continuous on $\left[0,1\right]$ and thus has a primitive g according to 1. With the chain rule [7.7.8] we see that

$h≔\left(b-a\right)\left(g\circ \frac{\mathrm{X}-a}{b-a}\right)$

is differentiable with ${h}^{\prime }=\left(b-a\right)\left({g}^{\prime }\circ \frac{\mathrm{X}-a}{b-a}\right)\frac{1}{b-a}=f\circ \left(a+\left(b-a\right)\cdot \mathrm{X}\right)\circ \frac{\mathrm{X}-a}{b-a}=f$.
h is thus a primitive function of f.

3. Every continuous function $f:I\to ℝ$ has a primitive.

Proof:  Closed intervals are covered by 2, so we only need to consider intervals I of the type $\right]a,b\left[$, $\right]a,b\right]$ or $\left[a,b\left[$. As an example we will assume I is of the latter type. I may be represented as the union of an increasing sequence $\left({I}_{n}\right)$ of closed subintervals: $I=\underset{i\in ℕ}{\cup }{I}_{n}$. Take for instance

f is continuous, and thus integrable, on each of these closed intervals. Due to [8.1.3] there is a unique differentiable function ${g}_{n}:{I}_{n}\to ℝ$ for each $n>1$ such that ${g}_{n}\left(a\right)=0$ and ${{g}_{n}}^{\prime }\left(x\right)=f\left(x\right)$ for all $x\in {I}_{n}$.

The uniqueness guarantees for any $m\ge n>1$ that

${g}_{m}\left(x\right)={g}_{n}\left(x\right)$ for all $x\in {I}_{n}\phantom{\rule{1pt}{0ex}}$.

Setting

$g\left(x\right)≔{g}_{n}\left(x\right)$, if $x\in {I}_{n}$ for an appropriate n

thus yields a well defined function $g:I\to ℝ$ that coincides locally at each x with one of the functions ${g}_{n}$. Hence g is differentiable with ${g}^{\prime }=f$.