Skip to content

Instantly share code, notes, and snippets.

@shoooe
Last active May 9, 2021 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoooe/eb0c209ea842fa09eaa9 to your computer and use it in GitHub Desktop.
Save shoooe/eb0c209ea842fa09eaa9 to your computer and use it in GitHub Desktop.

Why is the codomain useful?

In set theory we have that a domain is the set of all inputs for which a function is defined and the image is the set of possible outputs given those inputs. You would think this would be enough, but no: we also have the concept of codomain, which is the set of all possible outputs and some.

This also leads to the distinction between "surjective" functions and non-"surjective" functions (functions that have the image being equal to the codomain and those that don't, respectively). This distinction seems to provide no useful information about the function itself.

Now, let's make an example, we have:

ƒ : {a, b, c, d} -> {1, 2, 3, 4}
ƒ a = 1
ƒ b = 2
ƒ c = 3
ƒ d = 4

This is a surjective well-defined function. The domain is {a, b, c, d} and the image/codomain is {1, 2, 3, 4}.

By just changing the "type" of the function definition, we have:

ƒ : {a, b, c, d} -> R
ƒ a = 1
ƒ b = 2
ƒ c = 3
ƒ d = 4

This now becomes a non-surjective function, which has:

  • domain: {a, b, c, d}
  • image: {1, 2, 3, 4}
  • codomain: {0, 1, 2, 3, ...}

The codomain seems to tell me precisely 0 additional information about how the function behaves or about anything else really.

So my question is, why was the concept of codomain even defined and why or how is it useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment