TITLE: Approximation with continuous functions
QUESTION [10 upvotes]: Is it true that for every function $\mathbb{R} \to \mathbb{R}$ there exists a sequence of continuous functions $f_n(x): \mathbb{R} \to \mathbb{R}$ such that for any $x \in \mathbb{R}$ $f_n(x)$ converges to $f(x)$?
I started with characteristic function of rationals and tried to find corresponding sequence and got stuck. So additional question if this statement is true for this function.

REPLY [3 votes]: All the answers here rely on measure-theoretic ideas to give a negative answer. I feel that this does not exactly meet the point, instead I would say: You did not quite ask the right question, but if you did, the answer would in fact be "yes".
The space of all functions $\mathbb{R} \longrightarrow \mathbb{R}$ with the topology of pointwise convergence is a locally convex vector space, as its topology is induced by the system of seminorms
$$ \|f\|_x = |f(x)|.$$
However, since this system of norms in uncountable, sequences are not the right tool to describe convergence in this space.
Instead you should use nets. Using nets, you indeed have the following result: Every (yes every!) function $\mathbb{R} \longrightarrow \mathbb{R}$ is even the pointwise limit of a net of piecewise linear functions with finitely many knots. In particular, it is the limit of a net of continuous functions.
The set of finite subsets $\tau$ of $\mathbb{R}$ is ordered by inclusion and it is a directed set as the union of two finite sets is finite.
Now take a function $f:\mathbb{R} \longrightarrow \mathbb{R}$. For each finite subset $\tau$ of $\mathbb{R}$, let $f_\tau$ be the piecewise linear function with
$$f_\tau(t) = f(t)~~~~~\forall t \in \tau$$
that is constant left of the smallest element of $\tau$ and right of the biggest element of $\tau$. Then $(f_\tau)$ is a net that converges to $f$.