Back to Blog

The importance of Denseness

OCT 12, 2025

Density in Mathematics and the foundations of a whole branch of math :)

MathematicsReal Analysis

Preface

This blog is based on my experience in PMATH 351: Real Analysis, taught by Blake Madill. Taking this course was a thrill and a rollercoaster of emotions. I was amazed by how intricate an introductory analysis course can be, and how much it can enlighten someone. This post shares one of the concepts that really stuck with me and shows how it connects to big ideas in modern mathematics and engineering.

Notice

Quick note: this is for readers who’ve already taken second-year calculus, but no prior analysis is required.

Definitions of dense

In day-to-day life, we think of density as a measure of compactness or “filled-ness.” You might picture a block of water and a block of steel having different densities based on how “close” the atoms of iron are compared to the molecules in water. That intuition actually carries over to math: it helps us think about functions, metric spaces, and other abstract settings we work with in mathematics.

When we say a family of functions is dense, we mean that, with enough patience, it can approximate anything we care about as closely as we want. But why is that?

A geometric picture (what “dense” feels like)

We’re in a metric space (X,d)(X,d)(X,d) with a set A⊆XA\subseteq XA⊆X. Pick any point x∈Xx\in Xx∈X and any zoom level ε>0\varepsilon>0ε>0; the tiny neighborhood is the ball B(x,ε)B(x,\varepsilon)B(x,ε). If every time you zoom you still catch a point of AAA (i.e. there exists a∈A∩B(x,ε)a\in A\cap B(x,\varepsilon)a∈A∩B(x,ε), equivalently d(x,a)<εd(x,a)<\varepsilond(x,a)<ε), then AAA is basically always on tap for approximating xxx. That’s the vibe of density: no matter where you look or how hard you zoom, AAA shows up inside B(x,ε)B(x,\varepsilon)B(x,ε).

Now the formal piece: the closure of AAA is AAA plus all the points you can approach using only points of AAA. If every tiny neighborhood around xxx contains some point of AAA, then xxx lies in the closure A‾\overline{A}A.

Formal definition(s)

Dense and Closure

Let (X,d)(X,d)(X,d) be a metric space and A⊆XA\subseteq XA⊆X. We say AAA is dense in XXX iff for every x∈Xx\in Xx∈X and every ε>0\varepsilon>0ε>0, the open ball B(x,ε)B(x,\varepsilon)B(x,ε) meets AAA; equivalently,

A‾=X.\overline{A}=X .A=X.

For function spaces like C([a,b])C([a,b])C([a,b]) with the sup norm ∥f∥∞=sup⁡x∈[a,b]∣f(x)∣\|f\|_\infty=\sup_{x\in[a,b]}|f(x)|∥f∥∞​=supx∈[a,b]​∣f(x)∣, “dense” means: given any continuous fff and any ε>0\varepsilon>0ε>0, you can find ggg in your family with ∥f−g∥∞<ε\|f-g\|_\infty<\varepsilon∥f−g∥∞​<ε.

Why polynomials are dense in C([a,b])C([a,b])C([a,b])

If you think polynomials can approximate any continuous function on a closed interval, you might point to the Taylor series you learned in first-year calculus. The statement below explains WHY approximation by polynomials works in general (not just at a point via derivatives). The proof uses basic calculus, sequences of functions, and one clever trick.

Weierstrass Approximation Theorem

Weierstrass Approximation Theorem

For any continuous f:[a,b]→Rf:[a,b]\to\mathbb{R}f:[a,b]→R and any ε>0\varepsilon>0ε>0, there exists a polynomial ppp such that

∥f−p∥∞<ε.\|f-p\|_\infty<\varepsilon.∥f−p∥∞​<ε.
Proof

I’ll outline the proof informally here:

First, reduce to the interval [0,1][0,1][0,1] using Φ:C([0,1])→C([a,b])\Phi:C([0,1])\to C([a,b])Φ:C([0,1])→C([a,b]) with Φ(f)=f∘ϕ−1\Phi(f)=f\circ\phi^{-1}Φ(f)=f∘ϕ−1, where ϕ:[a,b]→[0,1]\phi:[a,b]\to[0,1]ϕ:[a,b]→[0,1] and ϕ(x)=x−ab−a\phi(x)=\frac{x-a}{b-a}ϕ(x)=b−ax−a​. This is an isometric isomorphism, so it preserves the sup norm and has an inverse.

Next, for f∈C([0,1])f\in C([0,1])f∈C([0,1]), define ggg with g(0)=g(1)=0g(0)=g(1)=0g(0)=g(1)=0 by g(x)=f(x)−[(f(1)−f(0))x+f(0)]g(x)=f(x)-\big[(f(1)-f(0))x+f(0)\big]g(x)=f(x)−[(f(1)−f(0))x+f(0)].

Consider Qn(x)=cn(1−x2)nQ_n(x)=c_n(1-x^2)^nQn​(x)=cn​(1−x2)n with cn>0c_n>0cn​>0 chosen so that ∫−11Qn(x) dx=1\int_{-1}^1 Q_n(x)\,dx=1∫−11​Qn​(x)dx=1.

Using a basic inequality, one shows 1=∫−11Qn(x) dx>cnn1=\int_{-1}^1 Q_n(x)\,dx > \dfrac{c_n}{\sqrt{n}}1=∫−11​Qn​(x)dx>n​cn​​, hence cn<nc_n<\sqrt{n}cn​<n​.

Extend fff beyond [0,1][0,1][0,1] by zero (consistent with the endpoints) and set

Pn(x)=∫−11f(x+t)Qn(t) dt=∫01f(u)Qn(u−x) du.P_n(x)=\int_{-1}^1 f(x+t)Q_n(t)\,dt = \int_{0}^1 f(u)Q_n(u-x)\,du.Pn​(x)=∫−11​f(x+t)Qn​(t)dt=∫01​f(u)Qn​(u−x)du.

Let M=∥f∥∞M=\|f\|_\inftyM=∥f∥∞​. By uniform continuity, choose 0<δ<10<\delta<10<δ<1 so that ∣f(x)−f(y)∣<ε|f(x)-f(y)|<\varepsilon∣f(x)−f(y)∣<ε whenever ∣x−y∣<δ|x-y|<\delta∣x−y∣<δ. Then, omitting routine steps,

∣Pn(x)−f(x)∣=∣∫−11(f(x+t)−f(x))Qn(t) dt∣≤∫−11∣f(x+t)−f(x)∣ Qn(t) dt≤4Mn(1−δ)(1−δ2)n+ε→n→∞  ε.\begin{aligned} |P_n(x)-f(x)| &= \left|\int_{-1}^1 \big(f(x+t)-f(x)\big)Q_n(t)\,dt\right| \\ &\le \int_{-1}^1 |f(x+t)-f(x)|\,Q_n(t)\,dt \\ &\le 4M\sqrt{n}(1-\delta)(1-\delta^2)^n + \varepsilon \\ &\xrightarrow[n\to\infty]{}\;\varepsilon. \end{aligned}∣Pn​(x)−f(x)∣​=​∫−11​(f(x+t)−f(x))Qn​(t)dt​≤∫−11​∣f(x+t)−f(x)∣Qn​(t)dt≤4Mn​(1−δ)(1−δ2)n+εn→∞​ε.​

This proves the result for f∈C([0,1])f\in C([0,1])f∈C([0,1]), and by the isometric isomorphism we conclude that polynomials are dense in C([a,b])C([a,b])C([a,b]).

Alternatively, Stone–Weierstrass (conceptual). The set of polynomials is a subalgebra of C([a,b])C([a,b])C([a,b]) that separates points and contains constants. On a compact space, such a subalgebra is uniformly dense. Here, “subalgebra” means closed under addition, scalar multiplication, and pointwise multiplication. “Separates points” is the functional analogue of injectivity: if your family contains a function that takes different values at two points, it separates them.

This matters because it explains why Taylor-style polynomial approximations of continuous functions actually work and converge uniformly on compact intervals.

Examples and applications

These are common examples you’ll find in first-year analysis books and they hint at how broadly “density” shows up.

Example 1: Need for separation of points

Example 1

Let V=span{1,x2,x4,… }V=\mathrm{span}\{1,x^2,x^4,\dots\}V=span{1,x2,x4,…}. Then VVV is dense in C([0,1])C([0,1])C([0,1]) but not dense in C([−1,1])C([-1,1])C([−1,1]).

Proof

On [0,1][0,1][0,1] every continuous function can be uniformly approximated by polynomials in xxx. Because x↦xx\mapsto \sqrt{x}x↦x​ is continuous on [0,1][0,1][0,1], any polynomial in xxx can be uniformly approximated by a polynomial in x2x^2x2 (compose with a polynomial approximation of ⋅\sqrt{\cdot}⋅​ on [0,1][0,1][0,1]), so VVV is dense in C([0,1])C([0,1])C([0,1]).

On [−1,1][-1,1][−1,1], every v∈Vv\in Vv∈V is even (v(x)=v(−x)v(x)=v(-x)v(x)=v(−x)). The odd function g(x)=xg(x)=xg(x)=x cannot be uniformly approximated by even functions, so VVV fails to separate the points aaa and −a-a−a and is not dense in C([−1,1])C([-1,1])C([−1,1]).

Example 2: Using density to prove other topological phenomena

Corollary (Example 2)
C([a,b])C([a,b])C([a,b]) is separable.
Proof

Since the rationals Q\mathbb{Q}Q are countable and dense in R\mathbb{R}R, the set of polynomials with rational coefficients is countable and dense in the real polynomials. By Weierstrass, polynomials are dense in C([a,b])C([a,b])C([a,b]) under ∥⋅∥∞\|\cdot\|_\infty∥⋅∥∞​. Hence the closure of a countable set (rational-coefficient polynomials) is all of C([a,b])C([a,b])C([a,b]), so C([a,b])C([a,b])C([a,b]) is separable.

Example 3: Moment vanishing

Example 3

Let f∈C([0,1])f\in C([0,1])f∈C([0,1]) satisfy ∫01xnf(x) dx=0\displaystyle \int_0^1 x^n f(x)\,dx = 0∫01​xnf(x)dx=0 for all n≥0n\ge 0n≥0. Prove f≡0f\equiv 0f≡0.

Proof

Polynomials are dense in C([0,1])C([0,1])C([0,1]), so pick polynomials Pn→fP_n \to fPn​→f uniformly (meaning we can make PnP_nPn​ as close to fff as we want). Then standard limit rules give Pnf→f2P_n f \to f^2Pn​f→f2 uniformly.

Write a generic polynomial as Pn(x)=∑k=0nck xkP_n(x)=\sum_{k=0}^{n} c_k\,x^kPn​(x)=∑k=0n​ck​xk. By the hypothesis ∫01xmf(x) dx=0\int_0^1 x^m f(x)\,dx = 0∫01​xmf(x)dx=0 for all m≥0m\ge 0m≥0, we get

∫01Pn(x) f(x) dx=∑k=0nck∫01xkf(x) dx=0.\int_0^1 P_n(x)\,f(x)\,dx = \sum_{k=0}^{n} c_k \int_0^1 x^k f(x)\,dx = 0.∫01​Pn​(x)f(x)dx=k=0∑n​ck​∫01​xkf(x)dx=0.

Passing to the limit (uniform convergence on a compact interval lets us swap limit and integral),

∫01f2(x) dx=  lim⁡n→∞∫01Pn(x)f(x) dx=  0.\int_0^1 f^2(x)\,dx =\; \lim_{n\to\infty} \int_0^1 P_n(x)f(x)\,dx =\; 0.∫01​f2(x)dx=n→∞lim​∫01​Pn​(x)f(x)dx=0.

Since f2≥0f^2 \ge 0f2≥0 and is continuous, the only way its integral can be 000 is if f2≡0f^2 \equiv 0f2≡0, hence f≡0f \equiv 0f≡0.

Connection to Fourier Analysis

Here’s a fun twist. We’ve shown, at least informally, that polynomials can approximate any continuous function on an interval. Can trigonometric functions do the same? It might seem unlikely at first, since they are periodic and a bit harder to tame. The punchline is yes, on the right domain, and the same density idea opens the door to Fourier analysis.

Trigonometric density (Fourier on the circle)

Stone–Weierstrass on the circle (trigonometric density)

Let T={z∈C:∣z∣=1}\mathbb T=\{z\in\mathbb C:\lvert z\rvert=1\}T={z∈C:∣z∣=1} be the unit circle and let C(T,C)C(\mathbb T,\mathbb C)C(T,C) be the continuous (complex-valued) functions on T\mathbb TT with the sup norm. The trigonometric polynomials

T={ p(z)=∑n=−NNcn z n : N∈N, cn∈C }\mathcal T=\Bigl\{\,p(z)=\sum_{n=-N}^{N} c_n\,z^{\,n}\ :\ N\in\mathbb N,\ c_n\in\mathbb C\,\Bigr\}T={p(z)=n=−N∑N​cn​zn : N∈N, cn​∈C}

are dense in C(T,C)C(\mathbb T,\mathbb C)C(T,C). Equivalently, for every f∈C(T,C)f\in C(\mathbb T,\mathbb C)f∈C(T,C) and ε>0\varepsilon>0ε>0 there is p∈Tp\in\mathcal Tp∈T with ∥f−p∥∞<ε\lVert f-p\rVert_\infty<\varepsilon∥f−p∥∞​<ε.

Note

There’s a complex version of Stone–Weierstrass we won’t prove here. Roughly, you need a subalgebra that contains constants, separates points, and is closed under complex conjugation. It’s natural to work over C\mathbb CC because trigonometric functions align with complex exponentials.

Proof

Why this is true (the friendly sketch).
Look at the small algebra A={∑k=0Nakzk}A=\{\sum_{k=0}^N a_k z^k\}A={∑k=0N​ak​zk}. On the circle, complex conjugation sends zzz to z−1z^{-1}z−1. Allowing conjugates gives negative powers:

A∗={∑n=−NNcnzn}=T.A^*=\Bigl\{\sum_{n=-N}^{N} c_n z^n\Bigr\}=\mathcal T.A∗={n=−N∑N​cn​zn}=T.

Now check the three Stone–Weierstrass boxes on the compact space T\mathbb TT:

  1. Has constants. 1∈T1\in\mathcal T1∈T.
  2. Separates points. The identity f(z)=zf(z)=zf(z)=z is injective on T\mathbb TT, so z1≠z2⇒f(z1)≠f(z2)z_1\neq z_2 \Rightarrow f(z_1)\neq f(z_2)z1​=z2​⇒f(z1​)=f(z2​).

  3. Closed under conjugation. If p(z)=∑cnznp(z)=\sum c_n z^np(z)=∑cn​zn, then p‾(z)=∑cn‾z−n∈T\overline p(z)=\sum \overline{c_n}z^{-n}\in\mathcal Tp​(z)=∑cn​​z−n∈T.

Stone–Weierstrass then says T\mathcal TT is dense in C(T,C)C(\mathbb T,\mathbb C)C(T,C). This means any complex function can be approximated with trigonometric polynomials. That is exactly what Fourier series rely on.

Real sine–cosine form

If f∈C(T,R)f\in C(\mathbb T,\mathbb R)f∈C(T,R) (equivalently, fff is a continuous 2π2\pi2π-periodic real function of ttt), then for every ε>0\varepsilon>0ε>0 there exist NNN and real numbers a0,an,bna_0,a_n,b_na0​,an​,bn​ such that

∥ f ⁣(eit)−(a0+∑n=1N(ancos⁡nt+bnsin⁡nt))∥∞<ε.\Bigl\|\,f\!\bigl(e^{it}\bigr)-\Bigl(a_0+\sum_{n=1}^{N}\bigl(a_n\cos nt+b_n\sin nt\bigr)\Bigr)\Bigr\|_\infty<\varepsilon.​f(eit)−(a0​+n=1∑N​(an​cosnt+bn​sinnt))​∞​<ε.
Proof

View f(eit)f(e^{it})f(eit) as a 2π2\pi2π-periodic function of ttt. Density of T\mathcal TT gives a complex sum ∑(n=−N)Ncneint\sum_{(n = -N)}^{N} c_n e^{int}∑(n=−N)N​cn​eint uniformly close to fff. Taking real and imaginary parts yields the stated sine–cosine form with real coefficients.

The angle trick (matching periodic functions to the circle)

Define Φ:C(T,C)→C([−π,π],C)\Phi:C(\mathbb T,\mathbb C)\to C([-\pi,\pi],\mathbb C)Φ:C(T,C)→C([−π,π],C) by Φ(f)(t)=f(eit)\Phi(f)(t)=f(e^{it})Φ(f)(t)=f(eit) and restrict the codomain to 2π2\pi2π-periodic functions. Then Φ\PhiΦ is an isometry (distance-preserving). Under Φ\PhiΦ, elements of T\mathcal TT become finite sums of einte^{int}eint, the usual trigonometric polynomials on [−π,π][-\pi,\pi][−π,π]. So “dense on T\mathbb TT” is the same as “dense among 2π2\pi2π-periodic continuous functions.”

Takeaways

Polynomials are dense on [a,b][a,b][a,b] (Weierstrass), so any continuous function on a closed interval can be uniformly approximated by polynomials. Trigonometric polynomials are dense on the unit circle (Stone–Weierstrass), so any continuous 2π2\pi2π-periodic signal can be uniformly approximated by sines and cosines. Together, these results form the backbone of approximation theory and lead directly into Fourier analysis.


Appendix: quick definitions used above

Algebra / subalgebra
A set A⊂C(K,C)A\subset C(K,\mathbb C)A⊂C(K,C) (continuous functions on compact KKK) is a subalgebra if it’s closed under +++, scalar multiplication, and pointwise multiplication, and it contains the constant functions.
Separates points
A family F⊂C(K,C)\mathcal F\subset C(K,\mathbb C)F⊂C(K,C) separates points if for any x≠yx\neq yx=y in KKK there exists f∈Ff\in\mathcal Ff∈F with f(x)≠f(y)f(x)\neq f(y)f(x)=f(y).
Self-adjoint
A⊂C(K,C)A\subset C(K,\mathbb C)A⊂C(K,C) is self-adjoint if f∈Af\in Af∈A implies f‾∈A\overline f\in Af​∈A, where f‾(x)=f(x)‾\overline f(x)=\overline{f(x)}f​(x)=f(x)​.
Complex Stone–Weierstrass (statement)
If KKK is compact and A⊂C(K,C)A\subset C(K,\mathbb C)A⊂C(K,C) is a self-adjoint subalgebra that contains constants and separates points of KKK, then AAA is dense in C(K,C)C(K,\mathbb C)C(K,C) under the sup norm.
Unit circle and trig polynomials
T={z∈C:∣z∣=1}\mathbb T=\{z\in\mathbb C:|z|=1\}T={z∈C:∣z∣=1}. A trigonometric polynomial is p(z)=∑n=−NNcnz np(z)=\sum_{n=-N}^{N} c_n z^{\,n}p(z)=∑n=−NN​cn​zn; in angle form this is t↦∑n=−NNcneintt\mapsto\sum_{n=-N}^{N} c_n e^{int}t↦∑n=−NN​cn​eint.

On this page