Why dense subsets are convenient to prove theorems

I will provide two examples in Linear Algebra where density can be exploited in a very slick way.
Plenty of other examples can be found in Approximation Theory and Functional Analysis.

Cayley-Hamilton theorem. If $p$ is the characteristic polynomial of $A$, then $p(A)=0$.
Proof. If $A$ is a diagonalizable matrix the claim is trivial by applying $p$ to the Jordan normal form of $A$. If $A$ is not a diagonalizable matrix, it can be made so by introducing an arbitrarily small perturbation $A\mapsto A_\varepsilon$. Since $p$ is continuous the claim follows by density.

The trace is abelian. We have $\text{Tr}(AB)=\text{Tr}(BA)$.
Proof. If $A$ is invertible then $AB$ and $BA= A^{-1}(AB)A$ are conjugated matrices, hence they have the same characteristic polynomial and the same trace. If $A$ is not invertible, it can be made so by considering $A+\varepsilon I$. Since $\text{Tr}$ is a continuous operator, the claim follows by density.

That should be enough to start understanding why density is really important: it gives us a rigorous way for "cheating", i.e. for working with stronger regularity assumptions.


Let's say you wanted to prove that the sum of the Riemann (or Lebesgue) integrals of two real-valued functions with the same domain is equal to the integral of the sum. (We assume, of course, that each of the two functions is integrable in the required sense.)

To do this, we first prove this property for step functions (for Riemann integrals) or for simple functions (for Lebesgue integrals). E.g., for Lebesgue integrals, the simple functions are dense in the $L^{1}$-space, so for two general functions $f, g$, the result $$ \int f + \int g = \int (f + g) $$ follows by: approximating each of $f, g$ by simple functions $s_{f}, s_{g}$ with accuracy within $\epsilon/2$ in the sense of the $L^{1}$-distance. For the functions $s_{f}, s_{g}$, the desired equality is verifiable more or less directly. Therefore, we obtain that $$ |\int f + \int g - \int (f + g)| < \epsilon. $$ This is one for every positive $\epsilon$, so $$ |\int f + \int g - \int (f + g)| = 0. $$

Another example is the proof of Plancherel's Theorem.