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.



Approximation with continuous functions
Quick answer:


What you want to do is look up ``Baire function'' (in Wikipedia, for example). The Baire class of functions is the least collection of functions $f:\mathbb R\to\mathbb R$ that contains the continuous functions and is closed under limits. 


Here is a simple way of seeing that the answer is negative: Any continuous function $f:{\mathbb R}\to{\mathbb R}$ is determined by its value on the rationals, so by an easy counting argument, there are only as many continuous functions as there are reals. Since a sequence of reals can be easily coded by a single real, there are only $|{\mathbb R}|$-many functions that are limit of sequences of continuous functions (you could replace "pointwise limit" with just about anything you want as long as the countable sequence suffices to describe the new function). But there are $2^{|{\mathbb R}|}$ many functions from ${\mathbb R}$ to itself. 


The Wikipedia entry talks about class $n$ Baire functions for all $n\in{\mathbb N}$: Baire class one functions are pointwise limits of sequences of continuous functions. Baire class two functions are pointwise limits of sequences of Baire class one functions, etc. You need to go on much longer through a transfinite process to capture all Baire functions, resulting in a hierarchy of length [$\omega\_1$](http://en.wikipedia.org/wiki/First_uncountable_ordinal). But even then you will fail to capture all functions $f:\mathbb R\to\mathbb R$: There are only $\mathfrak c$ many Baire functions. In fact, these are precisely the Borel measurable functions. 




---


Let me close with something of an advertisement. Pete Clark's comments in another answer show that $\chi\_{\mathbb Q}$ is not the pointwise limit of continuous functions. For this, he described a characterization of the Baire class 1 functions that clearly $\chi\_{\mathbb Q}$ does not satisfy. Since the answer has been deleted, let me repeat Peter's comment:



> 
> A real function $f$ is in Baire class one iff for every nonempty perfect subset $P\subset\mathbb R$, there exists $x\in P$ such that the restriction of $f$ to $P$ is continuous at $x$ (in fact, $f\upharpoonright P$ is continuous at all points of $P$ except for a set that is [first category](http://en.wikipedia.org/wiki/First_category) in $P$). Taking $P$ to be a closed interval $[a,b]$, this shows that there is a dense subset of points at which $f$ is either left- or right- continuous. This is not the case for $\chi\_{\mathbb Q}$.
> 
> 
> 


(Note the nice corollary that, since derivatives are obviously Baire class one functions, they are continuous on a dense set of reals.)


The argument above, on the other hand, only refers to cardinality considerations, so it does not apply to specific examples. 


One can refine the argument (essentially, by a sophisticated use of Cantor's diagonalization) by appealing to techniques of descriptive set theory. Here, one studies ``definable'' classes of functions $f:{\mathbb R}\to{\mathbb R}$ or, more generally, of subsets of ${\mathbb R}^n$, and it is therefore the right setting for this type of problems. 


The simplest kind of definability a function may have is that its graph is Borel (this is the case if the function is continuous, for example). From here, a very large hierarchy of levels of complexity of subsets of ${\mathbb R}^m$ is defined, starting by taking projections of Borel subsets of ${\mathbb R}^{m+1}$, and complements, and then iterating this procedure.


The fact that we can actually iterate the procedure, i.e., that the hierarchy does not collapse, is where Cantor's diagonalization appears. Anyway, any class of functions with a simple description is easily seen to belong to a (typically, very short) initial segment of this hierarchy, and so we know it cannot capture the class of all functions. Many variants of your question are seen immediately to have negative answers through this procedure, which has the advantage of separating levels of complexity in a more refined way than mere cardinality. 


An excellent reference you may want to look at is Alekos Kechris's [book](http://rads.stackoverflow.com/amzn/click/0387943749).


