How many smooth functions are non-analytic?
We know from example that not all smooth (infinitely differentiable) functions are analytic (equal to their Taylor expansion at all points). However, the examples on the linked page seem rather contrived, and most smooth functions that I've encountered in math and physics are analytic.
How many smooth functions are not analytic (in terms of measure or cardinality)? In what situations are such functions encountered? Are they ever encountered outside of real analysis (e.g. in physics)?
It is not difficult to see that the collection of $C^{\infty}$ functions that fail to be analytic at each point is $c$-dense in the space of continuous functions defined on a compact interval (sup metric). To see this, let $f$ be such a continuous function and choose $\epsilon > 0.$ Next, pick any $C^{\infty}$ and nowhere analytic function $\phi$ that is bounded between $-1$ and $1.$ (Take $\frac{2}{\pi}$ times the arctangent of an unbounded example, if an example bounded between $-1$ and $1$ isn't handy.) Let $P$ be a polynomial whose sup-metric distance from $f$ is less than $\frac{\epsilon}{3}$ (Weierstrass's Approximation Theorem). Now let $g = \left(\frac{\epsilon}{3}\right)\phi + P.$ Then, for each of the $c$-many real numbers $\delta$ such that $0 < \delta < \frac{\epsilon}{3},$ the function $g + \delta$ is: (a) $C^{\infty}$, (b) nowhere analytic, (c) belongs to the $\epsilon$-ball centered at $f.$ This last part involves the triangle inequality, and earlier we need the fact that if $\phi$ is $C^{\infty}$ and nowhere analytic, then the composition $\arctan \circ \phi$ is $C^{\infty}$ and nowhere analytic and $\left(\frac{\epsilon}{3}\right)\phi + P + \delta$ is $C^{\infty}$ and nowhere analytic. Note that we can also easily get $c$-many such functions arbitrarily close (sup metric) to any continuous function defined on $\mathbb R$ by appropriately splicing together functions on the intervals $...\; [-2,-1],$ $[-1,0],$ $[0,1],$ $[1,2],\; ...$
Any type of cardinality result is pretty much maxed out by this result, but by considering stronger forms of "largeness" we can do better. The results I know about involve Baire category and the idea of prevalance (complement of a Haar null set), and each implies the $c$-dense result above (and much more). Back in 2002 I posted a couple of lengthy essays in sci.math about $C^{\infty}$ and nowhere analytic functions. For some reason they were never archived by google's sci.math site, but they can be found at the Math Forum sci.math site. One day I might LaTeX these essays for posting in this group, but I doubt I'll have time in the near future.
ESSAY ON NOWHERE ANALYTIC C-INFINITY FUNCTIONS Part 1 (9 May 2002) and Part 2 (19 May 2002)
In terms of cardinality, there are the same number of smooth and analytic functions, $2^{\aleph_0}$. The constant functions are enough to see that there are at least $2^{\aleph_0}$ analytic functions. The fact that a continuous function is determined by its values on a dense subspace, along with my presumption that you are referring to smooth functions on a separable space, imply that there are at most $(2^{\aleph_0})^{\aleph_0}=2^{\aleph_0}$ smooth functions.
Added: In light of the question edit, I should mention that the cardinality of the set of smooth nonanalytic functions is also $2^{\aleph_0}$. This can be seen by taking the constant multiples of some bump function.
I don't know about measures, but analytic functions are a very special subclass of smooth functions (something which I'm sorry to leave vague at the moment, but hopefully someone will give a better answer here (Added: Now Dave L. Renfro has)). They are also important, useful, and relatively easy to work with, which is part of why they are so prevalent in the math and physics you have seen.
Where are they encountered? Bump functions are important in differential equations and manifolds, so I would guess they're important in physics. Bump functions are smooth and not analytic.
I came upon this quirky example, find smooth $f(x)$ such that $f(f(x)) = \sin x$ with $f(0)=0$ and $f'(0) = 1.$ The fact that this can be solved is quite nontrivial. It turns out that it is analytic between each $(k \pi, (k+1) \pi)$ but only $C^\infty$ at $0-$ and all multiples of $\pi.$ Go figure. The answer is periodic, resembles the sine wave but with slightly larger amplitude. This can be seen since, for $0 < x \leq \frac{\pi}{2},$ the function is between $\sin x$ and $x.$
See my answer to my own question at https://mathoverflow.net/questions/45608/formal-power-series-convergence/46765#46765
In response to your first question, it's not hard to see there are continuum many continuous functions, and hence continuum many analytic functions (consider the values of said functions at rational points; also, the constant functions provide at least continuum many.
On the other hand, there are 2^c many Lebesgue measurable functions of the reals: If S is any subset of the cantor set, the indicator function of S is Lebesgue measurable, since it has measure 0. There are, however, only continuum many Borel measurable functions.
Maybe you meant to ask, "How many smooth functions are not analytic?" I can sort of see a picture proof in my had that in the topology of continuous functions of the reals, non-analytic functions are a dense subset of the set of smooth functions.