Can someone please explain to me in layman what each means? Perhaps with some examples with functions (inputs to outputs/numeric values in them)? Especially range, image, and preimage. So far this is my understanding:

  • Domain is basically the input $x$ in $f(x)$.
  • Codomain is what $f(x)$ produces as an output such as $y$ when $f(x) = y$.
  • Range sounds like codomain but with some restriction?
  • Image I have little understanding of but I think it is basically a relation between domain to codomain given that we take a subset of our function (Eg; it is the input to output process of our function given we put a restriction on the domain as $x$ can only go from $0$ to $1$).
  • Preimage is just walking backward on the "image" process? (Inverse image?) Going from our "subsetted" output back to our "subsetted" input?

I am very frustrated that I can't seem to grasp these basic concepts so I would greatly appreciate any help from anyone who can break this down for me and help me understand it without too much mathematical notation. Thank you!

  • $\begingroup$ Domain of a function. $\endgroup$ Commented Jun 30, 2019 at 12:06
  • $\begingroup$ Codomain of a function. $\endgroup$ Commented Jun 30, 2019 at 12:06
  • $\begingroup$ Range or image. $\endgroup$ Commented Jun 30, 2019 at 12:07
  • $\begingroup$ There you can find the definitions: mathematics needs definitions. $\endgroup$ Commented Jun 30, 2019 at 12:15
  • $\begingroup$ A function $f$ from natural numbers to natural numbers like $x^2$ has as Domain (i.e. the set of "input values") the set $\mathbb N$ and has as Codomain again $\mathbb N$, because all the "output values" are inside $\mathbb N$. $\endgroup$ Commented Jun 30, 2019 at 12:16

2 Answers 2


Consider a function for example $f:R\to R$ defined by $f(x)=x^2$. The domain is the largest possible set of inputs which in this case the set of all real numbers. The codomain is given as $R$, the set of all real numbers. The range is the set of all possible outputs which is the interval $[0,\infty)$.

The image of a subset $A$ of of real numbers is $f(A)$ which is the set of all $f(x)$ where $x\in A$. For example, $f((-1,1))=[0,1)$.

The pre-image of a subset $B$ of the range is the set $f^{-1}(B)$ of all inputs $x$ such that $ f(x)$ is in $B$. For example $f^{-1}([1,4])=[-2,-1]\cup [1,2]$.

  • 1
    $\begingroup$ @Q_A_B_70 Remember that $(-1, 1) = \{x \in \mathbb{R} \mid -1 < x < 1\}$. The square of a number with absolute value less than $1$ must be at least $0$ and less than $1$. Since $f$ is continuous, $f(0) = 0$, and $f(1) = 1$, the function assumes every value between $0$ and $1$, including $0$ but not including $1$ on the interval $[0, 1)$. $\endgroup$ Commented Jun 30, 2019 at 13:12
  • 1
    $\begingroup$ I think it should be $f(\,(-1,1)\,)$. The outer pair of parentheses being the function application, the inner pair being the open interval. $\endgroup$
    – celtschk
    Commented Jun 30, 2019 at 13:29
  • 2
    $\begingroup$ "The domain is the largest possible set of inputs" is complete nonsense. This is the way it is probably taught in some countries below university level, but it is plainly incorrect. The domain of a function comes with the definition, and must be specified, not something that can be determined a posteriori. According to this "definition", why can't I take the domain of $x\mapsto x^2$ to be $\mathbb C$? $\endgroup$
    – YiFan Tey
    Commented Oct 7, 2022 at 12:19

In mathematics, a function aims to establish a relationship between an input and an output value. Let us denote the input value as $x$ and suppose that it is real-valued, that is, $x \in \mathbb{R}$. By "$x \in \mathbb{R}$" we mean that "the variable $x$ can take any value in the Real set".

Now consider that we want to apply the function $f$ to $x\in \mathbb{R}$ in order to obtain a real-valued output, $y\in \mathbb{R}$. When we define that the output of $f$ is real, we are actually defining its codomain. By definition, the codomain is the set where the output function is allowed to fall.

Our function (input-output relationship) is given by $y=f(x)=\sqrt{x}$. Note that we have one limitation: although $x$ can take any value in the real set, the function $f$ only accepts nonnegative real-valued values since negative values of $x$ would yield imaginary values, which do not belong to $\mathbb{R}$ (the codomain of $f$). This "input set limitation of $f$" is exactly the domain of $f$. With the definition of both domain and codomain of $f$, we can denote $f$ as $f: \mathbb{R}_+ \rightarrow \mathbb{R}$[¹]. You can read this as $f: \text{domain} \rightarrow \text{codomain}$. We can conclude that a function is completely defined only when we also define its domain and codomain, where these sets are part of the definition of $f$ rather than a property of it [1]. We can denote the domain of $f$ as $\text{dom }f = \mathbb{R}_{+}$ or $\text{dom}(f) = \mathbb{R}_{+}$, it depends on the author. As far as I know, there is no notation to denote the codomain of $f$ [2].

Note that, although the codomain of $f$ is $\mathbb{R}$, it will only yield nonnegative values. This whole set of nonnegative values is exactly the "image of $f$ set" or range. By definition, the image of $f$ is the set of all output values that $f$ may produce [3], that is, it is the set $f(\text{dom }f) = \{f(x) \mid x \in \text{dom }f\}$. The range is a subset of the codomain (in some cases, it may cover all the codomain). The mathematical notation for the image of $f$ or the range is $\text{ran }f = \mathbb{R}_+$ or $\text{ran}(f) = \mathbb{R}_+$ [4], $\text{range }f = \mathbb{R}_+$ or $\text{range}(f) = \mathbb{R}_+$ [5], or $\text{im }f = \mathbb{R}_+$ or $\text{im}(f) = \mathbb{R}_+$. The notation varies considerably depending on the author. You can also use the term "image" in elementwise manner, that is, if $f(a)=b$, you can (and should) say that "$b$ is the image of $a$". The term "range" is not used in elementwise manner [6, appendix B.3].

To make the understanding of preimage clearer, it is convenient to introduce another definition of set theory that was not asked. In many fields of Mathematics, such as Optimization Theory, we are only interested in a subset of the domain rather than the whole domain. Formally, we must define another function, $f\mid_A$, where its domain $A$ is a subset of $\text{dom } f$, that is, $A\subseteq \text{dom }f$. $f\mid_A$ is referred as the restriction of the function $f$ in $A$ [7]. But for most cases, it is more convenient to work with $f$ itself and assume that we are only interested in what happens with the region of interest, $A$. In this case, the image of $A$ is denoted as $B = f(A) = \{f(x)\mid x\in A\}$, and its preimage (or inverse image) is defined as $f^{-1}(B) = \{x \in \text{dom }f\mid f(x) \in B\}$, where $f^{-1}$ is the inverse function of $f$. Note that $f^{-1}(B)$ is not necessarily equal to $A$, it depends whether the function $f$ is biunivocal.


[¹]: I am using the French notation to denote the nonnegative sets, the notation of this set may vary by author.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .