In mathematics, a function f from a topological space A to a set B is called locally constant, iff for every a in A there exists a neighborhood U of a, such that f is constant on U.

Every constant function is locally constant.

Every locally constant function from the real numbers R to R is constant. But the function f from the rationals Q to R, defined by f(x) = 0 for x < &pi, and f(x) = 1 for x > π, is locally constant (here we use the fact that π is irrational and that therefore the two sets {xQ : x < π} and {xQ : x > π} are both open in Q.

Generally speaking, if f : AB is locally constant, then it is constant on any connected component of A. The converse is true for locally connected spaces (where the connected components are open).

Further examples include the following:

  • Given a covering p : CX, then to each point x of X we can assign the cardinality of the fibre p-1(x) over x; this assignment is locally constant.
  • A map from the topological space A to a discrete space B is continuous if and only if it is locally constant.