Linear Algebra
8.25 min read

Constant Functions

The simplest scalar-valued function is a constant function: it outputs the same number cc regardless of the input x\mathbf{x}. Written as f(x)=cf(\mathbf{x}) = c for all xRn\mathbf{x} \in \mathbb{R}^n. The graph of a constant function is a flat horizontal hyperplane at height cc.

Constant functions are degree 0 — no variables appear at all. They serve as the baseline case when classifying functions by their polynomial degree. A function that looks like f(x)=5f(\mathbf{x}) = 5 is constant; a function like f(x)=5+x1f(\mathbf{x}) = 5 + x_1 is not, because it changes as x1x_1 changes.

Formal View

Definition 8.2 — Constant Function
A function f:RnRf: \mathbb{R}^n \to \mathbb{R} is constant if there exists cRc \in \mathbb{R} such that f(x)=cf(\mathbf{x}) = c for all xRn\mathbf{x} \in \mathbb{R}^n. It has polynomial degree 0.

Why This Matters

Constant functions appear as trivial edge cases in classification theorems and as offsets in affine functions.

  • A constant bias term bb in a neural network layer: f(x)=wx+bf(\mathbf{x}) = \mathbf{w}^\top \mathbf{x} + b has both a linear part and a constant part.
  • Regularization penalties that add a fixed constant to a loss function.
  • Lower bounds in optimization: proving a cost function is at least c>0c > 0 everywhere.

Quiz

Question 1

The function f(x1,x2)=7f(x_1, x_2) = 7 is a constant function on R2\mathbb{R}^2.

Question 2

What is the polynomial degree of a constant function?

Common Mistakes

  • Calling f(x)=c+x1f(\mathbf{x}) = c + x_1 a "constant" function — only the cc part is constant; the function itself varies with x1x_1.
  • Confusing a constant function with a zero function — a constant function outputs cc which may be nonzero, while the zero function outputs 0.