# Almost everywhere continuous function that cannot be extended to continuous function

Find $f:\mathbb R \to \mathbb R$ an almost everywhere continuous function such that there isn't any $g:\mathbb R \to \mathbb R$ continuous function with $f=g$ a.e..

My attempt at a solution

I was trying to construct a function $f$ of such characteristics and I thought of a function which is constant on intervals of the form $(n,n+1)$ for $n$ integer and has jumps of height $1$ between any two integers. I didn't know how to explicitly define this function, but the idea is $f$ on $[0,1)$ has the value $0$; on $[1,2)$ takes the value $1$; on $[2,3)$, $0$, and continue this way and define it the same way for the negatives.

It is clear that this function is continuous almost everywhere (except at the integers), but I didn't know how to show that it can't be extended to a continuous function on the real line. I would appreciat any suggestions or help to prove this and also if there is a nice way to define the function I've just constructed.

Just take $f=0$ on $(-\infty,0]$ and $f=1$ on $(0,\infty)$. Suppose $g$ is any continuous function such that $g=f$ a.e., then you have two options:
1. $g(0) \neq 0$: Then there is $\delta > 0$ such that $g(x) \neq 0$ on $(-\delta,0]$ and $f(x) = 0$ on $(-\delta,0]$ contradicting the fact that $g=f$ a.e.
2. $g(0) = 0$: Then choose $\delta > 0$ such that $|g(x)|< 1/2$ on $[0,\delta)$. Once again this contradicts the assumptions that $g=f$ a.e.
• Thanks!, just one silly question, wouldn't be sufficient in 2. to choose $\delta>0$ such that $|g(x)|<1$? Sep 9 '15 at 5:28
• How can we bound $g$ by $1/2$ on $[0, \delta)$. For any such $\delta > 0,[0, \delta) \cap (0, \infty) = (0, \delta)$, an interval on which $g = f$ almost everywhere. $\implies$ there exists at least one point in $x \in (0, \delta)$ such that $g(x) = 1$. Oct 30 '18 at 6:58