# 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).

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:

• Does this make the defi­ni­tion of the codomain some­what ar­bi­trary?

The squares of re­als hap­pen to be a sub­set of the re­als, but they’re also a sub­set of all com­plex num­bers. Why say the codomain is $$\mathbb R$$ rather than $$\mathbb C$$?

• Nar­row­ness is a virtue, es­pe­cially in math­e­mat­ics. The tighter and more pre­cise you can make your state­ment, the more you could say about it.

• But wouldn’t fol­low­ing that prin­ci­ple lead you to say the codomain is the pos­i­tive re­als, since that’s the small­est set that con­tains the image (i.e. it is the image)?

• Yes, but the differ­ence be­tween re­als and pos­i­tive re­als isn’t that big. How­ever, I might be con­fused on this whole topic (see the other com­ment I tagged you in).

• Fixed. (Would be nice to have a way to re­solve these com­ments.)

• Yes, I think I should have used “ques­tion/​ob­jec­tion” rather than com­ment. (But I’m try­ing do what feels nat­u­ral rather than us­ing my in­side in­for­ma­tion on how the plat­form is sup­posed to work.)