Contents
  1. Curve Representations
  2. Bezier Curves
  3. Parametric Surfaces
  4. B-Splines
  5. Kolmogorov-Arnold Networks and B-Splines
  6. Least Squares Fitting with B-Splines
  7. Knots
← All posts

Splines, Bezier Curves, and B-Splines

Splines are piecewise polynomial curves that join smoothly at knots. Bezier curves are defined by control points. B-splines generalise both and are the basis functions used in KANs and computer graphics.

Curve Representations

There are three ways to represent a curve:

  • Explicit: y=f(x)y = f(x). Easy to evaluate but yy may not be a function of xx (e.g. a circle).
  • Implicit: f(x,y)=0f(x, y) = 0. Works for closed curves but hard to sample points from.
  • Parametric: x=x(u)x = x(u), y=y(u)y = y(u) where uu is a parameter. Both xx and yy are functions of an independent variable uu. Most flexible. 0u10 \leq u \leq 1 typically.

A parametric curve: p(u)=(x(u)y(u))p(u) = \begin{pmatrix} x(u) \\ y(u) \end{pmatrix}, 0u10 \leq u \leq 1.

Bezier Curves

A Bezier curve of degree nn is defined by n+1n+1 control points P0,P1,,PnP_0, P_1, \ldots, P_n:

p(u)=k=0n(nk)(1u)nkukPk,0u1p(u) = \sum_{k=0}^{n} \binom{n}{k} (1-u)^{n-k} u^k P_k, \quad 0 \leq u \leq 1

The curve passes through P0P_0 (at u=0u=0) and PnP_n (at u=1u=1) but generally not through the intermediate control points. The control points act as a scaffold that shapes the curve.

Key properties:

  • The curve lies within the convex hull of the control points.
  • The tangent at P0P_0 is along P1P0P_1 - P_0, and at PnP_n along PnPn1P_n - P_{n-1}.
  • The curve is infinitely differentiable (smooth everywhere).

For 4 control points (n=3n=3, cubic Bezier): the most common form used in typography, animation, and vector graphics.

Parametric Surfaces

Extending to surfaces: p(u,v)p(u, v) where both uu and vv are parameters. Bezier surfaces use a grid of control points. The surface passes through corner control points only.

B-Splines

B-splines (Basis splines) generalise Bezier curves. They are defined by:

  • A set of control points P0,,PnP_0, \ldots, P_n.
  • A knot vector t0t1tmt_0 \leq t_1 \leq \ldots \leq t_m.
  • A degree kk.

The curve is:

p(u)=i=0nNi,k(u)Pip(u) = \sum_{i=0}^{n} N_{i,k}(u) P_i

where Ni,k(u)N_{i,k}(u) are the B-spline basis functions defined recursively (de Boor’s algorithm):

Ni,0(u)={1if tiu<ti+10otherwiseN_{i,0}(u) = \begin{cases} 1 & \text{if } t_i \leq u < t_{i+1} \\ 0 & \text{otherwise} \end{cases}
Ni,k(u)=utiti+ktiNi,k1(u)+ti+k+1uti+k+1ti+1Ni+1,k1(u)N_{i,k}(u) = \frac{u - t_i}{t_{i+k} - t_i} N_{i,k-1}(u) + \frac{t_{i+k+1} - u}{t_{i+k+1} - t_{i+1}} N_{i+1,k-1}(u)

Kolmogorov-Arnold Networks and B-Splines

In KANs, each edge holds a learnable function implemented as a B-spline. The activation function on each edge is:

ϕ(x)=wbsilu(x)+wsspline(x)\phi(x) = w_b \cdot \text{silu}(x) + w_s \cdot \text{spline}(x)

where spline(x)=iciBi(x)\text{spline}(x) = \sum_i c_i B_i(x) is a linear combination of B-spline basis functions. The coefficients cic_i are learned during training.

B-splines are used here because:

  • They are locally supported: each basis function is non-zero only over a small interval. Changing one coefficient affects only a local region of the function.
  • They are smooth: degree-kk B-splines are Ck1C^{k-1} continuous.
  • Grid extension is straightforward: add more knots to increase resolution without retraining from scratch.

Least Squares Fitting with B-Splines

Given data points (xi,yi)(x_i, y_i), fit a B-spline by minimising the sum of squared residuals:

mincyAc2\min_c \|y - Ac\|^2

where AA is the matrix of B-spline basis function evaluations:

Aij=Nj(xi)A_{ij} = N_j(x_i)

Each row corresponds to a data point. Each column corresponds to a basis function. The system ATAc=ATyA^T A c = A^T y (the normal equations) gives the least-squares solution.

Knots

Knots are the breakpoints where polynomial pieces join. Between two adjacent knots, the spline is a polynomial of degree kk. At knots, the pieces join with continuity constraints (how many derivatives match depends on the knot multiplicity).

  • k=3k = 3 and knot values 0,1,2,3,4,5,6,70, 1, 2, 3, 4, 5, 6, 7: cubic B-spline with 5 knot spans.
  • Increasing knot multiplicity decreases continuity at that knot (useful for corners).

The number of basis functions equals the number of control points: n+1=n + 1 = (number of knots) k1- k - 1.

← All posts