Codomain (of a function)

The codomain \(\operatorname{cod}(f)\) of a func­tion \(f : X \to Y\) is \(Y\), the set of pos­si­ble out­puts for the func­tion. For ex­am­ple, the codomain of con­cat is the set of all strings, and the codomain of the func­tion \(+\) is the set of all num­bers.

Vi­su­al­iz­ing a func­tion as a map that takes ev­ery point in an in­put set to one point in an out­put set, the codomain is the out­put set (pic­tured on the right in blue in the image be­low).

Domain, Codomain, and Image

The codomain of a func­tion is not to be con­fused with the image of a func­tion, which is the set of points in \(Y\) that can ac­tu­ally be reached by fol­low­ing \(f\), and which may not in­clude the whole set \(Y\). For ex­am­ple, con­sider all the func­tions that take a real num­ber as in­put and pro­duce an­other real num­ber. Many of those func­tions can­not be made to pro­duce ev­ery pos­si­ble real num­ber: For ex­am­ple, the func­tion \(\operatorname{square} : \mathbb R \to \mathbb R\) only pro­duces non-nega­tive num­bers. For more on the dis­tinc­tion, see the page on codomain vs image.

Add a lens talk­ing about how codomains are ar­bi­trary but of­ten nat­u­ral/​use­ful. Use ex­am­ple like how we can con­sider \(+\) to have codomain \(\mathbb N\), \(\mathbb Z\), etc., and ex­am­ples like Ack­er­man where the codomain “nat” makes by far the most sense (though “int” is fine too).

Children:

Parents: