{
  "id": "function-codomain",
  "title": "Codomain of a Function",
  "lang": "en",
  "source_lang": "en",
  "summary": "The codomain of a function is its specified target set, which contains every output but need not consist entirely of outputs actually attained.",
  "category": "mathematics",
  "subcategory": "analysis",
  "type": "concept",
  "aliases": [
    "Target set of a function"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/function-codomain/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/function-codomain/",
      "json": "https://aiwiki.page/zh/function-codomain.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The codomain of a function is the set specified as the target of a function. In the notation \\(f:A\\to B\\), the set \\(A\\) is the domain and \\(B\\) is the codomain: every input belongs to \\(A\\), and its output must belong to \\(B\\). The codomain need not equal the set of outputs actually attained, called the image of the function. This distinction is essential to defining surjectivity, specifying inverse functions, and describing maps between mathematical structures."
    },
    {
      "heading": "Definition and notation",
      "text": "A function\n\n\\[f:A\\to B\\]\n\nassigns to each element \\(a\\in A\\) exactly one element \\(f(a)\\in B\\). Its image is\n\n\\[f(A)=\\{f(a):a\\in A\\}.\\]\n\nConsequently,\n\n\\[f(A)\\subseteq B.\\]\n\nThe codomain specifies where outputs are allowed to lie; the image records which outputs actually occur. An element of the codomain may have no input mapping to it.\n\nThe word range is used inconsistently: some texts use it for the image, while others use it for the codomain. When that terminology is not explicitly defined, “image” and “codomain” provide a clearer distinction.\n\nA rule or formula alone generally does not determine a codomain. For example, \\(f(x)=x^2\\) can describe functions between several different sets, depending on the specified inputs and target."
    },
    {
      "heading": "Examples",
      "text": "Consider the function on the real numbers\n\n\\[f:\\mathbb{R}\\to\\mathbb{R},\\qquad f(x)=x^2.\\]\n\nIts codomain is \\(\\mathbb{R}\\), but its image is\n\n\\[f(\\mathbb{R})=[0,\\infty).\\]\n\nNegative numbers belong to its codomain even though none is an output.\n\nThe function\n\n\\[g:\\mathbb{R}\\to[0,\\infty),\\qquad g(x)=x^2\\]\n\nhas the same domain and assignment rule, but a different codomain. Every element of this codomain is attained.\n\nChanging the underlying number system can also change the image. The map\n\n\\[h:\\mathbb{C}\\to\\mathbb{C},\\qquad h(z)=z^2\\]\n\nhas all the complex numbers as both its image and its codomain, since every complex number has a complex square root.\n\nA finite example makes the distinction explicit. Let\n\n\\[A=\\{1,2,3\\},\\qquad B=\\{u,v,w\\},\\]\n\nwith\n\n\\[f(1)=u,\\qquad f(2)=v,\\qquad f(3)=u.\\]\n\nThe codomain is \\(\\{u,v,w\\}\\), whereas the image is \\(\\{u,v\\}\\)."
    },
    {
      "heading": "Role in surjectivity and invertibility",
      "text": "A function is surjective, or onto, precisely when its image equals its codomain:\n\n\\[f(A)=B.\\]\n\nEquivalently,\n\n\\[\\forall b\\in B\\;\\exists a\\in A:\\ f(a)=b.\\]\n\nSurjectivity therefore depends on the specified codomain. The real squaring function is not surjective onto \\(\\mathbb{R}\\), but it is surjective onto \\([0,\\infty)\\).\n\nBy contrast, injectivity depends on whether distinct inputs have distinct outputs:\n\n\\[f(a_1)=f(a_2)\\implies a_1=a_2.\\]\n\nChanging only the codomain, while retaining the same domain and output assignments, does not change injectivity.\n\nA bijection is both injective and surjective. A two-sided inverse\n\n\\[f^{-1}:B\\to A\\]\n\nexists exactly when \\(f:A\\to B\\) is bijective. Thus, the codomain helps determine whether an inverse is defined on the whole stated target.\n\nFor example,\n\n\\[q:[0,\\infty)\\to[0,\\infty),\\qquad q(x)=x^2\\]\n\nis bijective, with inverse \\(q^{-1}(y)=\\sqrt{y}\\). If its codomain is enlarged to \\(\\mathbb{R}\\), keeping the same domain and assignments, it is no longer surjective and has no two-sided inverse on that codomain."
    },
    {
      "heading": "Codomain and the formal definition of a function",
      "text": "There are different conventions for what information constitutes a function.\n\nUnder one common convention, a function includes its domain, codomain, and assignment rule. It can be represented as a triple\n\n\\[(A,B,G),\\]\n\nwhere\n\n\\[G=\\{(a,f(a)):a\\in A\\}\\]\n\nis its graph, a subset of the Cartesian product \\(A\\times B\\). On this convention, changing the codomain produces a different function, even if every input retains the same output.\n\nUnder another convention in set theory, a function is identified with its graph, subject to the requirement that every input have exactly one output. The graph determines the domain and image, but does not select a unique codomain: any set containing the image can serve as a target.\n\nThese conventions describe the same assignments differently. Statements about equality of functions must therefore be interpreted according to whether the codomain is included in the function’s defining data."
    },
    {
      "heading": "Changing the codomain",
      "text": "Suppose \\(f:A\\to B\\), and let \\(C\\) satisfy\n\n\\[f(A)\\subseteq C\\subseteq B.\\]\n\nThe same assignments define a function\n\n\\[f_C:A\\to C.\\]\n\nThis operation is called corestriction. It changes the codomain rather than the domain; restricting the domain instead changes the set of permitted inputs.\n\nEvery function can be corestricted to its image:\n\n\\[\\widetilde f:A\\to f(A),\\qquad \\widetilde f(a)=f(a).\\]\n\nThis function is automatically surjective. If \\(i:f(A)\\to B\\) is the inclusion map, then\n\n\\[f=i\\circ\\widetilde f.\\]\n\nThis factorization separates reaching the attained values from including those values in the original codomain.\n\nA set that omits even one attained output cannot be a codomain for the unchanged assignment rule."
    },
    {
      "heading": "Composition and structured target spaces",
      "text": "For composition, the standard notation\n\n\\[f:A\\to B,\\qquad g:B\\to C\\]\n\ngives\n\n\\[g\\circ f:A\\to C,\\qquad (g\\circ f)(a)=g(f(a)).\\]\n\nThe matching intermediate set ensures that \\(g\\) is defined at every output of \\(f\\). At the level of evaluating assignments, the weaker condition \\(f(A)\\subseteq\\operatorname{dom}(g)\\) suffices. In category theory, composition is specified through matching source and target objects.\n\nThe codomain can also carry structure relevant to the function:\n\n- A linear map \\(T:V\\to W\\) has a specified target vector space \\(W\\). Its image may be a proper linear subspace of \\(W\\).\n- For a continuous map \\(f:X\\to Y\\), the topology on the target space \\(Y\\) enters the definition of continuity.\n- A measurable function has a target equipped with a specified collection of measurable sets. A real-valued random variable, for example, is ordinarily defined with codomain \\(\\mathbb{R}\\), even when it takes only finitely many values.\n\nIn such settings, the target is not merely a container for output values: its mathematical structure is part of the specification of the map."
    }
  ],
  "links": [
    "mathematical-function",
    "domain-of-a-function",
    "image-of-a-function",
    "real-number",
    "complex-number",
    "surjective-function",
    "injective-function",
    "bijective-function",
    "inverse-function",
    "graph-of-a-function",
    "subset",
    "cartesian-product",
    "set-theory",
    "function-composition",
    "category-theory",
    "linear-map",
    "vector-space",
    "continuous-function",
    "topological-space",
    "measurable-function",
    "random-variable"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}