# About density of some piecewise linear function in some subspace of $C[a,b]$

It is known that the piecewise linear continuous functions form a dense set in the metric space $C[a,b]$ of continuous real valued functions on the compact interval $[a,b]\subset \mathbb{R}$ with "the supremum" metric $d(f,g)=\sup\limits_{t \in [a,b]} |f(t)-g(t)|$ for $f,g \in C[a,b]$.

Consider subspace $X=\{f\in C[a,b]: f(a)=f(b)\}$ of the metric space $(C[a,b],d)$. How do I show that the set of all piecewise linear functions $g$ on $[a,b]$ such that $g(a)=g(b)$ form a dense subset in $X$?

-
How do you show that the set of piecewise linear continuous functions is dense in $C[a,b]$? (I ask because your method might be easily modifiable to solve this problem, or it might not be.) I would use uniform continuity. –  Jonas Meyer Nov 28 '11 at 9:00
I saw the proof of the classical Weierstrass approximation theorem which based of the density of piecewise linear functions, but I don't remember neither author nor tittle. –  Richard Nov 28 '11 at 9:09
Thanks. I was wondering if you had seen a more direct approach. –  Jonas Meyer Nov 28 '11 at 9:19

You can prove it directly by using uniform continuity of $f\in X$, breaking up $[a,b]$ into a bunch of equal size pieces (small intervals), and putting a segment on each piece to match up with $f$ at the endpoints of the piece.
If instead you wanted to use the result stated in the first paragraph, starting with $f\in X$, take a piecewise linear continuous $g$ such that $d(f,g)$ is small. Define $h$ to be linear with $h(a)=f(a)-g(a)$ and $h(b)=f(b)-g(b)$. Then $g+h$ is piecewise linear and matches $f$ at the endpoints, and $d(f,g+h)\leq d(f,g)+d(g,g+h)=d(f,g)+d(0,h)\leq 2d(f,g)$ is small.