Skip to main content
Home
Pimath

Menu EN

  • Home
  • 🌐 EN
    • 🇮🇹 IT
    • 🇪🇸 ES
    • 🇵🇹 PT
    • 🇫🇷 FR
    • 🇷🇴 RO
  • 👨‍🎓 About Me
  • 🚧 Theory & Exercises
User account menu
  • Log in

Breadcrumb

  1. Home

Domain, Codomain, and Image of a Function: Definition and Examples

Profile picture for user Pimath
By Pimath, 10 June, 2026

To study a function correctly, one must carefully distinguish three fundamental sets: the domain, the codomain, and the image.

A function is not specified by the rule that assigns the value \(f(x)\) alone. To define it completely, one must also state the set of elements to which it may be applied and the set in which its values are declared to lie.

If

\[ f:A\to B, \]

then \(A\) is the domain of the function, \(B\) is its codomain, while the set of values actually attained by \(f\) is called the image of the function.

These three notions are closely related, yet in general they do not coincide. The domain determines which values of the independent variable are admissible; the codomain fixes the set in which the function is declared to take its values; the image, by contrast, gathers only those values that the function actually reaches.

Distinguishing among domain, codomain, and image is essential for understanding such fundamental properties as injectivity, surjectivity, bijectivity, the inverse function, and the composition of functions.


Contents

  • Domain, codomain, and image: the intuitive idea
  • Definition of the domain of a function
  • Definition of the codomain of a function
  • Definition of the image of a function
  • The difference between codomain and image
  • How to determine the domain of a function
  • How to determine the image of a function
  • Examples on domain, codomain, and image
  • Common mistakes to avoid

Domain, codomain, and image: the intuitive idea

To grasp intuitively the role played by the domain, the codomain, and the image, consider a function

\[ f:A\to B. \]

This notation means that the function \(f\) assigns to each element \(x\in A\) one and only one element \(f(x)\in B\).

The domain is the source set: it contains the elements to which the function may be applied.

The codomain is the target set: it is the set in which the function is declared to take its values.

The image, on the other hand, is the set of values actually obtained by applying the function to the elements of the domain.

 

In symbols, the image of \(f\) is

\[ f(A)=\{f(x)\in B\mid x\in A\}. \]

Since every value attained by the function belongs to the codomain, we always have

\[ f(A)\subseteq B. \]

This inclusion expresses a fundamental distinction: every value in the image belongs to the codomain, but it need not be the case that every element of the codomain belongs to the image.

For instance, if

\[ f:\mathbb R\to\mathbb R,\qquad f(x)=x^2, \]

then the domain is \(\mathbb R\) and the codomain is \(\mathbb R\). The function, however, takes only nonnegative values, so its image is

\[ f(\mathbb R)=[0,+\infty). \]

Here the codomain is \(\mathbb R\), whereas the image is merely \([0,+\infty)\).

Definition of the domain of a function

Let \(A\) and \(B\) be two nonempty sets. If

\[ f:A\to B \]

is a function, then the set \(A\) is called the domain of the function \(f\).

The domain is thus the set consisting of all elements to which the function assigns a value.

Equivalently, to say that \(A\) is the domain of \(f\) is to say that, for every \(x\in A\), there exists one and only one element \(y\in B\) associated with \(x\). In symbols:

\[ \forall x\in A,\quad \exists!\, y\in B \quad : \quad f(x)=y. \]

The domain therefore specifies which values of the independent variable may be considered. If an element does not belong to the domain, the function is not defined at that element.

For example, the function

\[ f:\mathbb R\to\mathbb R,\qquad f(x)=x^2+1 \]

has domain \(\mathbb R\), since to each real number \(x\) it assigns the real number \(x^2+1\).

By contrast, the function

\[ g:(0,+\infty)\to\mathbb R,\qquad g(x)=\log x \]

has domain \((0,+\infty)\), since the real logarithm is defined only for positive values of the variable.

The domain is not an incidental detail but an essential part of the function. Indeed, the same formula can define different functions when considered on different domains.

For example, the functions

\[ f:\mathbb R\to\mathbb R,\qquad f(x)=x^2 \]

and

\[ h:[0,+\infty)\to\mathbb R,\qquad h(x)=x^2 \]

share the same formula but are not the same function, because their domains differ.

This difference also bears on the properties of the function. Indeed, \(f\) is not injective, since \(f(-1)=f(1)\), whereas \(h\) is injective on the domain \([0,+\infty)\).

Definition of the codomain of a function

Let \(A\) and \(B\) be two nonempty sets. If

\[ f:A\to B \]

is a function, then the set \(B\) is called the codomain of the function \(f\).

The codomain is thus the target set of the function, that is, the set in which all values of the function are declared to lie.

In symbols:

\[ \forall x\in A,\quad f(x)\in B. \]

The codomain fixes the ambient set in which the function is declared to take its values. Nevertheless, the fact that an element belongs to the codomain does not necessarily mean that it is reached by the function.

For example, consider

\[ f:\mathbb R\to\mathbb R,\qquad f(x)=x^2. \]

The codomain is \(\mathbb R\). The function, however, takes no negative values, since \(x^2\ge 0\) for every \(x\in\mathbb R\). Numbers such as \(-1\), \(-2\), or \(-10\) therefore belong to the codomain but are not values of the function.

The codomain, like the domain, is part of the definition of the function. The same formula and the same domain can give rise to different functions if the codomain changes.

For example, the functions

\[ f:\mathbb R\to\mathbb R,\qquad f(x)=x^2 \]

and

\[ g:\mathbb R\to[0,+\infty),\qquad g(x)=x^2 \]

have the same formula and the same domain, but different codomains.

This difference becomes especially important in the study of surjectivity: a function is surjective when its image coincides with its codomain.

Definition of the image of a function

Let \(A\) and \(B\) be two nonempty sets and let

\[ f:A\to B \]

be a function. The image of the function \(f\) is defined to be the set of all values that \(f\) takes on the elements of the domain.

In symbols:

\[ f(A)=\{f(x)\in B\mid x\in A\}. \]

Equivalently, an element \(y\in B\) belongs to the image of \(f\) if and only if there exists at least one element \(x\in A\) such that \(f(x)=y\). In symbols:

\[ y\in f(A)\iff \exists x\in A \quad : \quad f(x)=y. \]

The image is thus the set of values actually reached by the function. By definition, it is always a subset of the codomain:

\[ f(A)\subseteq B. \]

This inclusion may be strict or it may be an equality. If \(f(A)\subsetneq B\), some elements of the codomain are not reached. If instead \(f(A)=B\), every element of the codomain is the image of at least one element of the domain.

Consider, for example,

\[ f:\mathbb R\to\mathbb R,\qquad f(x)=x^2+1. \]

For every \(x\in\mathbb R\) we have \(x^2\ge 0\), and hence

\[ x^2+1\ge 1. \]

It follows that all values of the function are greater than or equal to \(1\).

Conversely, if \(y\ge 1\), then \(y-1\ge 0\) and we may choose

\[ x=\sqrt{y-1}. \]

This gives

\[ f(x)=f(\sqrt{y-1})=(\sqrt{y-1})^2+1=y. \]

Therefore

\[ f(\mathbb R)=[1,+\infty). \]

In this example the codomain is \(\mathbb R\), whereas the image is \([1,+\infty)\).

The difference between codomain and image

The difference between codomain and image is one of the most delicate points in the study of functions.

If

\[ f:A\to B, \]

then the codomain is the set \(B\), prescribed in the definition of the function. The image, by contrast, is the set

\[ f(A)=\{f(x)\in B\mid x\in A\}, \]

that is, the set of values actually attained by the function.

We always have

\[ f(A)\subseteq B, \]

but not necessarily \(f(A)=B\).

For example, the function

\[ f:\mathbb R\to\mathbb R,\qquad f(x)=x^2 \]

has codomain \(\mathbb R\) but image \([0,+\infty)\). Indeed, no negative real number is the square of a real number.

If instead we consider

\[ g:\mathbb R\to[0,+\infty),\qquad g(x)=x^2, \]

then the image coincides with the codomain:

\[ g(\mathbb R)=[0,+\infty). \]

The two functions have the same formula and the same domain but different codomains. As a consequence, the first is not surjective, whereas the second is.

In short, the codomain is fixed when the function is defined; the image, on the other hand, must be determined by examining the values that the function actually takes on the domain.

How to determine the domain of a function

To determine the domain of a function means to identify all values of the independent variable for which the function is defined.

When a function is given in the form

\[ f:A\to B, \]

the domain is already specified: it is the set \(A\).

For example, if

\[ f:[0,+\infty)\to\mathbb R,\qquad f(x)=\sqrt x, \]

then the domain of the function is \([0,+\infty)\).

In many exercises, however, only the expression of the function is given, for instance

\[ f(x)=\frac{1}{x-2}. \]

In this case, unless stated otherwise, one looks for the largest subset of \(\mathbb R\) on which the expression makes sense. This set is called the natural domain, or domain of definition, of the function.

To determine the natural domain of a real-valued function of a real variable, one must impose all conditions that make the evaluation of the expression possible.

The most common restrictions are the following.

  • Denominators: the denominator of a fraction must be nonzero.
  • Even-index roots: the radicand must be greater than or equal to zero.
  • Logarithms: the argument of the logarithm must be strictly positive.

For example, for

\[ f(x)=\frac{1}{x-2} \]

one must impose

\[ x-2\ne 0, \]

hence \(x\ne 2\). The natural domain is

\[ \mathbb R\setminus\{2\}. \]

For

\[ g(x)=\sqrt{x-3} \]

one must impose

\[ x-3\ge 0, \]

hence \(x\ge 3\). The natural domain is

\[ [3,+\infty). \]

For

\[ h(x)=\log(x+1) \]

one must impose

\[ x+1>0, \]

hence \(x>-1\). The natural domain is

\[ (-1,+\infty). \]

In general, the natural domain is obtained by translating all the restrictions present in the expression of the function into mathematical conditions and then solving the resulting system of conditions.

One must, however, distinguish the natural domain from the prescribed domain. If a function is declared explicitly together with a domain, then the domain of the function is the one specified, even when the formula would make sense on a larger set.

For example,

\[ f:[0,+\infty)\to\mathbb R,\qquad f(x)=x^2 \]

has domain \([0,+\infty)\), even though the formula \(x^2\) makes sense for every \(x\in\mathbb R\).

How to determine the image of a function

To determine the image of a function means to identify all and only the values that the function takes as the independent variable ranges over the domain.

If

\[ f:A\to B \]

is a function, then an element \(y\in B\) belongs to the image of \(f\) if and only if there exists at least one \(x\in A\) such that

\[ f(x)=y. \]

Determining the image therefore amounts to establishing for which values of \(y\) the equation

\[ y=f(x) \]

admits at least one solution \(x\) in the domain of the function.

Unlike the natural domain, which is often found by imposing existence conditions on the expression, the image requires studying the values actually attained by the function. The method therefore depends on the type of function under consideration.

For example, consider

\[ f:\mathbb R\to\mathbb R,\qquad f(x)=x^2. \]

Set

\[ y=x^2. \]

This equation has real solutions if and only if \(y\ge 0\). Indeed, if \(y\ge 0\) one may take \(x=\sqrt y\); if \(y<0\), there is no real number \(x\) with \(x^2=y\).

Therefore

\[ f(\mathbb R)=[0,+\infty). \]

Now consider

\[ g:[0,+\infty)\to\mathbb R,\qquad g(x)=x+1. \]

Since \(x\ge 0\), we have

\[ x+1\ge 1. \]

Conversely, if \(y\ge 1\), then choosing \(x=y-1\) gives \(x\in[0,+\infty)\) and

\[ g(x)=x+1=(y-1)+1=y. \]

Hence

\[ g([0,+\infty))=[1,+\infty). \]

Geometrically, the image of a function is the set of ordinates of the points of its graph. For this reason it can, in some cases, be read off directly from the graph.

For more complicated functions, by contrast, it may be necessary to study monotonicity, locate maxima and minima, or invoke specific properties of the function at hand.

In any case, the image is not obtained by simply reading off the declared codomain: it must be determined by examining the values genuinely reached by the function on its domain.

Examples on domain, codomain, and image

We now look at several examples in which the domain, codomain, and image are determined explicitly. The aim is to identify precisely the source set, the target set, and the set of values actually attained.


Example 1. Consider the function

\[ f:\mathbb R\to\mathbb R,\qquad f(x)=x+2. \]

The domain is \(\mathbb R\), since the function is defined for every real number \(x\). The codomain is \(\mathbb R\), since the function is declared to take real values.

To determine the image, set

\[ y=x+2. \]

For every \(y\in\mathbb R\), choosing \(x=y-2\) yields

\[ f(x)=f(y-2)=(y-2)+2=y. \]

Thus every real number is attained by the function. Therefore

\[ f(\mathbb R)=\mathbb R. \]

In this case the image coincides with the codomain.


Example 2. Consider the function

\[ f:\mathbb R\to\mathbb R,\qquad f(x)=x^2+1. \]

The domain is \(\mathbb R\) and the codomain is \(\mathbb R\).

Since \(x^2\ge 0\) for every \(x\in\mathbb R\), we have

\[ x^2+1\ge 1. \]

Conversely, if \(y\ge 1\), choosing \(x=\sqrt{y-1}\) gives

\[ f(x)=f(\sqrt{y-1})=(\sqrt{y-1})^2+1=y. \]

Hence

\[ f(\mathbb R)=[1,+\infty). \]

The image is a proper subset of the codomain.


Example 3. Consider the function

\[ g:[0,+\infty)\to\mathbb R,\qquad g(x)=x^2+1. \]

The domain is \([0,+\infty)\), while the codomain is \(\mathbb R\).

Here too \(x^2+1\ge 1\). Moreover, for every \(y\ge 1\), choosing \(x=\sqrt{y-1}\) gives \(x\in[0,+\infty)\) and

\[ g(x)=x^2+1=y. \]

Therefore

\[ g([0,+\infty))=[1,+\infty). \]

The function has the same image as in the previous example, even though it is defined on a different domain.


Example 4. Consider the function

\[ h:[0,+\infty)\to[1,+\infty),\qquad h(x)=x^2+1. \]

The domain is \([0,+\infty)\) and the codomain is \([1,+\infty)\). As seen in the previous example,

\[ h([0,+\infty))=[1,+\infty). \]

In this case the image coincides with the codomain. The function \(h\) is therefore surjective.


Example 5. Consider the function

\[ p:\mathbb R\setminus\{0\}\to\mathbb R,\qquad p(x)=\frac{1}{x}. \]

The domain is \(\mathbb R\setminus\{0\}\), since the expression \(\frac{1}{x}\) is not defined for \(x=0\). The codomain is \(\mathbb R\).

For every \(x\ne 0\) we have \(\frac{1}{x}\ne 0\), so \(0\) does not belong to the image.

Conversely, if \(y\ne 0\), choosing \(x=\frac{1}{y}\) gives \(x\ne 0\) and

\[ p(x)=p\left(\frac{1}{y}\right)=\frac{1}{\frac{1}{y}}=y. \]

Hence

\[ p(\mathbb R\setminus\{0\})=\mathbb R\setminus\{0\}. \]

The image is thus a proper subset of the codomain, because the codomain contains \(0\) while the image does not.

Common mistakes to avoid

We summarize a few common mistakes in the study of domain, codomain, and image.

  • Confusing the codomain with the image. The codomain is the target set prescribed in the definition of the function; the image is the set of values actually reached.
  • Believing that the formula alone determines the function. The same formula can define different functions if the domain or the codomain changes.
  • Confusing the prescribed domain with the natural domain. If the domain is indicated in the notation \(f:A\to B\), then the domain is \(A\). The natural domain is sought only when an expression alone is given.
  • Forgetting that the image depends on the domain. Changing the domain may change the set of values attained by the function.
  • Deciding surjectivity without looking at the codomain. A function is surjective if and only if its image coincides with the codomain.

In conclusion, domain, codomain, and image are three distinct ingredients in the theory of functions. The domain tells us where the function is defined; the codomain tells us where the function is declared to take its values; the image tells us which values are actually reached.


Your feedback is important to us! Leave a comment and help us improve this content. Thank you!

Feedback

Support us by liking the page:
Or, share:

Tags

  • Mathematical Analysis 1

Support us by liking the page:
Or, share:

Copyright © 2026 | Pimath | All Rights Reserved