In mathematics, codimension is a basic geometric idea that applies to subspaces in vector spaces, to submanifolds in manifolds, and suitable subsets of algebraic varieties.
The dual concept is relative dimension.
Codimension is a relative concept: it is only defined for one object inside another. There is no “codimension of a vector space (in isolation)”, only the codimension of a vector subspace.
If W is a linear subspace of a finite-dimensional vector space V, then the codimension of W in V is the difference between the dimensions:
It is the complement of the dimension of W, in that, with the dimension of W, it adds up to the dimension of the ambient space V:
Similarly, if N is a submanifold or subvariety in M, then the codimension of N in M is
Just as the dimension of a submanifold is the dimension of the tangent bundle (the number of dimensions that you can move on the submanifold), the codimension is the dimension of the normal bundle (the number of dimensions you can move off the submanifold).
More generally, if W is a linear subspace of a (possibly infinite dimensional) vector space V then the codimension of W in V is the dimension (possibly infinite) of the quotient space V/W, which is more abstractly known as the cokernel of the inclusion. For finite-dimensional vector spaces, this agrees with the previous definition