TITLE: Are the analytic functions dense in the space of continuous functions?
QUESTION [8 upvotes]: We can consider functions defined on the real or complex numbers in any finite number of dimensions. The functions are defined everywhere. They need not have limited support. They may be defined over open or closed subsets of R^n or C^n (typing on my phone so avoiding latex) or everywhere.
In defining continuous functions, continuity is considered in the context of the topology induced by the Euclidean metric.
Distance between functions can be taken to be the distance in the L2 norm (the integral over the entire domain of the squared difference between two functions).

Which of these assumptions, if changed, might change the answer to the question? For example, we might want to be able to approximate continuous functions with analytic functions. But we might also wish to do this confidently for as wide a class of functions as possible: for instance, what about piecewise continuous functions with finite or countable points of discontinuity? We can consider widening the class of functions to include either of the latter two. Moreover, we might want to impose the strictest convergence criteria as possible for the approximations. For example, we might want to strengthen the requirement from closeness in L^2 to closeness that is uniform or close to uniform (e.g. uniform but for a finite set of points, i.e. "almost everywhere"), where closeness is viewed in the sense of convergence of a sequence of successively better approximations. So consider the stated (numbered) assumptions, but feel free to comment on whether the answer would still hold for more favorable assumptions given that the goal is to approximate functions as stated.

REPLY [6 votes]: As was mentionned in a previous answer before the question was put on hold, Stone-Weierstrass's theorem states that polynomial functions are dense in the space of continuous functions $f: [a,b] \to \mathbb R$ for the uniform convergence, which implies $L^2$ density. In fact, since continuous functions are dense in $L^2$, this means that any measurable function $f: [a,b] \to \mathbb R$ with $\int_{a}^b |f|^2 <+\infty$ can be $L^2$-approximated by polynomials, no matter how discontinuous $f$ is.
This still works for functions defined over an infinite interval, but more work is required (it is not an immediate consequence of Stone-Weierstrass).
If $U \subset \mathbb C$ is an open set, then the space of complex analytic functions $f: U \to \mathbb C$ that is also in $L^2(U)$ is closed for the $L^2$ norm (it is called the Bergman space $A^2(U)$). In particular, it is not dense in the space of continuous complex-valued functions defined on $U$.
I am not sure if this case is also of interest to you, but if $K \subset \mathbb C$ is a compact without interior, you can ask whether complex-valued continuous functions on $K$ can be uniformly approximated by restrictions to $K$ of analytic functions. This is a more delicate question, which depends on $K$. It is known for example that if $K$ disconnects the plane in at most finitely many components, the answer is yes; same thing if $K$ has zero Lebesgue measure.