Foundations to Frontier
Tests
A. Mathematical Foundations › A3 Calculus and Analysis › Real and functional analysis

Universal Approximation Theorems (Preview)

A neural network with one hidden layer can approximate any continuous function on a compact set as closely as you like (Cybenko, Hornik, Leshno–Pinkus). This page builds such networks by hand, shows what the theorem doesn't promise (efficiency, learnability, generalization), and previews the deeper results: approximation rates, the curse of dimensionality, Barron spaces, and why depth can be exponentially better than width.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Building any shape from simple pieces

With enough small, straight Lego bricks you can build something that looks like a smooth curve. Use more, smaller bricks and the curve gets smoother. A neural network does the same thing with neurons. Each one contributes a simple bend or step, and adding up enough of them can trace out any shape.

That’s the universal approximation theorem: one hidden layer can approximate anything continuous. But “enough neurons” can mean astronomically many, and the theorem doesn’t say how to find the right ones.

One hidden layer can approximate anything, but at what width?
target:
network:
L² error vs N = 2…64 (log–log)slope −2: smooth; −½: a jump
sup error = 4.17e-1 · L² error = 2.14e-1
Grey: target. Orange: network. Ticks: where hidden units put their kinks or steps. Every method improves as N grows, which is universality. How fast depends on the target's smoothness and on whether the units are placed well (constructed) or randomly (random features).
Why engineers care

Engineers replace expensive physics models (aerodynamic tables, contact dynamics, sensor calibrations) with neural networks. Universality says that’s possible in principle. Approximation rates tell you how big the network must be, and that decides whether it fits on a robot’s onboard computer.

📝 Quick check (Level 0)
0/3 answered
  1. 1. More, smaller bricks make the curve…
  2. 2. The universal approximation theorem guarantees…
  3. 3. Each ReLU neuron adds one…

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

A network you can build by hand

A one-hidden-layer network computes g(x)=c+∑j=1Naj σ(wjx+bj)g(x) = c + \sum_{j=1}^Na_j\,\sigma(w_jx + b_j). With ReLU σ(z)=max⁡(0,z)\sigma(z) = \max(0,z), each unit is flat and then a straight ramp, bending at x=−bj/wjx = -b_j/w_j.

  • A hat function from three units: relu⁡(x)−2relu⁡(x−1)+relu⁡(x−2)\operatorname{relu}(x) - 2\operatorname{relu}(x-1) + \operatorname{relu}(x-2) rises from 0 to 1 on [0,1][0,1] and falls back to 0 on [1,2][1,2].
  • Any piecewise-linear function with knots x0<x1<⋯<xNx_0 < x_1 < \dots < x_N is g(x)=f(x0)+s0(x−x0)+∑j=1N−1(sj−sj−1)relu⁡(x−xj)g(x) = f(x_0) + s_0(x - x_0) + \sum_{j=1}^{N-1}(s_j - s_{j-1})\operatorname{relu}(x - x_j), where sjs_j are the slopes. That’s one hidden unit per interior knot.
  • So a ReLU layer can match the piecewise-linear interpolant of any continuous ff. That interpolant converges uniformly as the knots get denser (A3.5-2). This is universality in 1-D, proved by construction.

With sigmoids, σ(k(x−a))\sigma(k(x - a)) approaches a step as k→∞k\to\infty, and sums of steps make staircases. That’s Cybenko’s original route.

📝 Quick check (Level 1)
0/3 answered
  1. 1. hat(0.5) with hat = relu(x) − 2relu(x−1) + relu(x−2)?
  2. 2. A piecewise-linear interpolant with 9 knots needs how many hidden ReLUs?
  3. 3. A steep sigmoid looks like a…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.

The theorems

  • Cybenko (1989): sums ∑ajσ(wj⊤x+bj)\sum a_j\sigma(w_j^\top x + b_j) with a continuous sigmoidal σ\sigma are dense in C(K)C(K) for compact K⊂RdK\subset\mathbb R^d, in the sup norm.
  • Hornik, Stinchcombe and White (1989) extended this to general “squashing” functions and to LpL^p norms.
  • Leshno, Lin, Pinkus and Schocken (1993): a one-hidden-layer network with a continuous activation is universal if and only if the activation is not a polynomial. A polynomial activation of degree mm can only produce polynomials of degree ≤m\le m.

What the theorem doesn’t say

  1. How many units. The width needed depends on the target’s smoothness and dimension.
  2. How to find the weights. Training is non-convex optimization.
  3. Generalization. It’s about representing ff on all of KK, not learning it from finite samples (B1, B2).
  4. Extrapolation. Outside the compact set KK, nothing is promised.

Rates: smoothness and dimension

In 1-D, the ReLU interpolant with NN pieces has error ≤max⁡∣f′′∣8h2=O(N−2)\le\frac{\max|f''|}{8}h^2 = O(N^{-2}). In dd dimensions, a grid with the same spacing has NdN^d cells. Reaching error ε\varepsilon for a CsC^s target generally needs about ε−d/s\varepsilon^{-d/s} parameters for any method that depends continuously on ff (DeVore, Howard and Micchelli, 1989). That’s the curse of dimensionality. Deep learning works in high dimensions because real targets have extra structure:

  • low intrinsic dimension (A3.5-1’s covering numbers);
  • compositional structure;
  • the Fourier-moment condition that defines Barron spaces.
🐍 Exercise 1: build universal approximators by hand
Construct a ReLU network that exactly equals the piecewise-linear interpolant of sin and confirm its O(1/N²) sup error and the h²/8 bound. Then build a sigmoid staircase and see it converge only like 1/N.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Which activation is NOT universal in one hidden layer?
  2. 2. Halving the knot spacing reduces the interpolation error by…
  3. 3. The universal approximation theorem says nothing about…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Why polynomials fail and ReLUs succeed

If σ\sigma is a polynomial of degree mm, every σ(w⊤x+b)\sigma(w^\top x + b) is a polynomial of degree ≤m\le m, and so is any sum of them. They form a finite-dimensional subspace, which is closed and can’t be dense in the infinite-dimensional C(K)C(K). For non-polynomial σ\sigma, Leshno et al. show the closure contains all polynomials, which are dense by Weierstrass (A3.5-2).

Proof sketch: 1-D ReLU universality

Let f∈C[a,b]f\in C[a,b] and ε>0\varepsilon > 0.

  1. Pick the spacing. ff is uniformly continuous, so choose δ\delta with ∣f(x)−f(y)∣<ε|f(x) - f(y)| < \varepsilon whenever ∣x−y∣<δ|x - y| < \delta.
  2. Interpolate. The piecewise-linear interpolant gg on a grid of spacing <δ< \delta takes values between neighbouring ff values on each cell, so ∣f−g∣<ε|f - g| < \varepsilon everywhere.
  3. Write it as a network. gg is exactly a one-hidden-layer ReLU network, with one unit per interior knot. ∎

In dd dimensions a standard route is to approximate ff by ridge functions ∑hk(wk⊤x)\sum h_k(w_k^\top x). Each 1-D hkh_k is then approximated by ReLUs as above. Ridge functions are dense by a Fourier/Radon argument (Pinkus, 1999).

Depth separation

Composing the tent map t(x)=2relu⁡(x)−4relu⁡(x−12)t(x) = 2\operatorname{relu}(x) - 4\operatorname{relu}(x - \tfrac12) with itself kk times gives a sawtooth with 2k2^k linear pieces, using only 2k2k ReLUs. A one-hidden-layer network with NN units has at most N+1N + 1 pieces in 1-D. So it needs about 2k2^k units to match, and is otherwise far away in L1L^1 (Telgarsky, 2016). Some functions are exponentially cheaper to represent with depth (Practice Code 5; Eldan and Shamir, 2016).

Exercise 3.1: How many linear pieces can a one-hidden-layer ReLU network with N units have on ℝ?

Each unit adds at most one kink, so there are at most NN kinks and N+1N + 1 pieces. Depth multiplies, rather than adds, pieces.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Polynomial activations fail because the network's outputs lie in…
  2. 2. The 1-D ReLU proof relies on…
  3. 3. k composed tent maps (2k ReLUs) give how many pieces?

Level 4: Expert

★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.

Beyond existence: rates that beat the curse

Barron (1993): if ff’s Fourier transform has a finite first moment, Cf=∫∣ω∣∣f^(ω)∣ dω<∞C_f = \int|\omega||\hat f(\omega)|\,d\omega < \infty, then a one-hidden-layer sigmoid network with NN units achieves L2L^2 error O(Cf/N)O(C_f/\sqrt N). The rate doesn’t depend on the dimension dd. The proof is probabilistic: sample units at random from an integral representation, and the error averages out like Monte Carlo. Modern refinements define Barron spaces and show they’re the natural function spaces for shallow ReLU networks (E, Ma and Wu, 2022). Training only the output layer of random features gives the related kernel or random-features rates (Rahimi and Recht, 2008), which Exercise 2 explores.

🐍 Exercise 2 (research): random-feature approximation and target complexity
Fix a random ReLU first layer and fit only the output layer by least squares. Measure relative L² error against width for a smooth 2-D target and a high-frequency one, and see how complexity, not just universality, sets the width you need.

Universality across architectures and applications

  • Operators. Chen and Chen (1995) proved universal approximation of operators. That’s the theory behind DeepONet and neural operators for PDE surrogates (A3.4-4, A3.5-6). Kovachki et al. (2023) extended it to neural operators.
  • Sequence models and control. RNNs approximate dynamical systems on finite horizons, and transformers are universal approximators of sequence-to-sequence functions (Yun et al., 2020). In control, universal approximation of value functions and policies underlies neural-network MPC and approximate dynamic programming. Lipschitz and stability constraints (A3.5-3) are the price of safety.
  • Invariant and equivariant networks. DeepSets are universal for permutation-invariant functions (Zaheer et al., 2017). Equivariant networks are universal within their symmetry class, which matters for point clouds and molecules.
  • Honest takeaway. Universality rules out “the architecture can’t represent it” as an excuse. It does not explain why training finds good solutions or why they generalize. Those are optimization (A6) and learning-theory (B1, B2) questions.

References

  1. G. Cybenko (1989). “Approximation by superpositions of a sigmoidal function.” Mathematics of Control, Signals and Systems, 2.
  2. K. Hornik, M. Stinchcombe, H. White (1989). “Multilayer feedforward networks are universal approximators.” Neural Networks, 2(5).
  3. M. Leshno, V. Lin, A. Pinkus, S. Schocken (1993). “Multilayer feedforward networks with a nonpolynomial activation function can approximate any function.” Neural Networks, 6(6).
  4. A. Pinkus (1999). “Approximation theory of the MLP model in neural networks.” Acta Numerica, 8.
  5. A. Barron (1993). “Universal approximation bounds for superpositions of a sigmoidal function.” IEEE Transactions on Information Theory, 39(3).
  6. M. Telgarsky (2016). “Benefits of depth in neural networks.” COLT.
  7. R. Eldan, O. Shamir (2016). “The power of depth for feedforward neural networks.” COLT.
  8. R. DeVore, R. Howard, C. Micchelli (1989). “Optimal nonlinear approximation.” Manuscripta Mathematica, 63.
  9. W. E, C. Ma, L. Wu (2022). “The Barron space and the flow-induced function spaces for neural network models.” Constructive Approximation, 55.
  10. T. Chen, H. Chen (1995). “Universal approximation to nonlinear operators by neural networks with arbitrary activation functions and its application to dynamical systems.” IEEE Transactions on Neural Networks, 6(4).
  11. A. Rahimi, B. Recht (2008). “Random features for large-scale kernel machines.” NeurIPS.
  12. C. Yun et al. (2020). “Are transformers universal approximators of sequence-to-sequence functions?” ICLR.