# Existence of a continuous function close to a piece-wise constant function

$g:[a,b]\to \mathbb{R}$ be a piece-wise constant function. Then for any $\epsilon>0$,there exists a continuous function $g^{\epsilon}:[a,b]\to\mathbb{R}$ such that there is a family $\{J_{\lambda}\}_{\lambda\in\Lambda}$ of intervals in $[a,b]$ satisfying the following: $$\{x\in[a,b]|g^{\epsilon}(x)\neq g(x)\}\subset\cup_{\lambda\in{\Lambda}}J_{\lambda},\:\:\:\: \sum_{\lambda\in\Lambda}|J_{\lambda}|<\epsilon$$

As $g$ is piece-wise, so there is a partition $P=\{J_1,\dots,J_n\}$ that $g$ can be written as the following: $$g(x)=\sum_{J\in{P}}c_J\chi_J(x).$$ Too continue, I assume $J_1=[a,a+\frac{i_1}{n})\:\: \text{and for each$k$}\:\: J_k=[a+\frac{i_{k-1}}{n},a+\frac{i_{k}}{n})$, where $i_1+\dots+i_n=n$.

Given $\epsilon >0$, I define the continuous function $$g^{\epsilon}=\begin{cases} g(a)& x\in [a,a+\frac{i_1}{n}-\frac{\epsilon}{2n})\\\frac{ g(a+\frac{i_1}{n})-g(a)}{\epsilon}2n&x\in[a+\frac{i_1}{n}-\frac{\epsilon}{2n}, a+\frac{i_1}{n}) \\ g(a+\frac{i_{k-1}}{n})& x\in [a+\frac{i_{k-1}}{n},a+\frac{i_k}{n}-\frac{\epsilon}{2n})\\ \frac{ g(a+\frac{i_{k}}{n})-g(a+\frac{i_{k-1}}{n})}{\epsilon}2n&x\in[a+\frac{i_{k-1}}{n}-\frac{\epsilon}{2n}, a+\frac{i_{k-1}}{n})\end{cases}$$

I'm not sure if my argument is accurate, also I just considered very special case of partition. Is there any other way to define this function?

• I didn't think about $b$ :( – Parisina Jul 23 '17 at 23:43

Let $\epsilon>0$. Since $g$ is piecewise constant, there is partition $P=\{a=x_0, x_1, x_2 \cdots b=x_n\}$ such that $g$ is constant on $[x_i, x_{i+1}]$ for $0 \leq i \leq n-1$. The $x_i$'s in the interior of $[a,b]$ are transition points, essentially, and the idea is to cover them with arbitrarily small intervals.
Choose open intervals $\{J_i\}_{1 \leq 1 < n}$ such that for $1 \leq i < n$,
$J_i = \left(x_i - \text{min}\left(\frac{\epsilon}{2n}, \frac{x_i - x_{i-1}}{2}\right), x_i + \text{min}\left(\frac{\epsilon}{2n}, \frac{x_{i+1} - x_i}{2}\right)\right)$
Now let $g^{\epsilon}(x)$ such that $g(x) = g^{\epsilon}(x)$ when $x \in [a,b] \setminus \bigcup J_i$ and when $x \in J_i$ for some $1 \leq i < n$ interpolate linearly. In other words, draw a line from the point $(\inf J_i, g(\inf J_i))$ to the point $(\sup J_i, g(\sup J_i))$.
Note that $\sum |J_i| \leq (n-1)\frac{\epsilon}{n} < \epsilon$