I am working on a question about domain and codomain. So far, I know that domain is all the $x$ values of the function, and that the codomain is all the possible values that could be in the domain, and I also know that for it to describe a function it has to be a one to one relation. But what I'm not understand is how to read that from a question such as $f: \mathbb{N} \to \mathbb{N}$ where $f(n) = \sqrt{n}$, I don't see where to get the domain and codomain from it.


  • $\begingroup$ A function can also be many to one (it will just not be invertible). $\endgroup$ – The Long Night Nov 1 '18 at 14:42
  • $\begingroup$ ok , I am just very confused on what makes the domain and co domain in this question $\endgroup$ – Breanna Nov 1 '18 at 15:02
  • $\begingroup$ See my answer, basically, you have to keep in mind the two golden conditions (no negative numbers in square roots and no division by 0), while adjusting according to the question. $\endgroup$ – The Long Night Nov 1 '18 at 15:30
  • $\begingroup$ This tutorial explains how to typeset mathematics on this site. $\endgroup$ – N. F. Taussig Nov 1 '18 at 16:50

Let's consider some definitions.

Definition. An ordered pair $(a, b)$ is a set of two elements with the property that $(a, b) = (c, d)$ if and only if $a = c$ and $b = d$.

Definition. Let $A$ and $B$ be sets. The cross-product of sets $A$ and $B$, denoted $A \times B$, is the set of ordered pairs $$A \times B = \{(a, b) \mid a \in A, b \in B\}$$

Definition. A relation $R$ from a set $A$ to a set $B$ is a subset of $A \times B$.

Definition. A function $f: A \to B$ is a relation from set $A$ to set $B$ in such that for every $a \in A$, there exists exactly one ordered pair $(a, b) \in f$.

Definition. Let $f: A \to B$ be a function. If $b \in B$ is the unique element assigned to $a \in A$ by $f$, we write $f(a) = b$ and say that $b$ is the image or value of $a$ under $f$.

Definition. Let $f: A \to B$ be a function from set $A$ to set $B$. The set $A$ is called the domain of $f$ and $B$ is called the codomain of $f$. The range, denoted $f(A)$, is the set of images of the elements of $A$. $$f(A) = \{f(a) \mid a \in A\}$$

Note that the domain is the set of input values, the range is the set of output values, and the codomain is a set that contains the set of output values.

*Definition.** The graph of function $f: A \to B$ is the set of ordered pairs $(a, b)$ such that $f(a) = b$.

Note that a function is specified by its domain, codomain, and graph.

Is $f: \mathbb{N} \to \mathbb{N}$ defined by $f(n) = \sqrt{n}$ a function.

We are given the domain $\mathbb{N}$ and codomain $\mathbb{N}$. If $f$ is a function, then for each $n \in \mathbb{N}$, there must exist an ordered pair $(n, \sqrt{n})$, where $n \in \mathbb{N}$ and $\sqrt{n} \in \mathbb{N}$. Since $2 \in \mathbb{N}$ and $\sqrt{2} \notin \mathbb{N}$, this is impossible, so $f$ is not a function.


You could define $f(x) = \frac{1}{\sqrt{x}}$ for complex numbers different from 0, but depending of your problem you can consider only positive real number, natural numbers, rational number, so on. And about the codomain, who it is written on your question is not true, since the multiplicative inverse of the square root of a natural number is not always a natural number, so the codomain cannot be $\mathbb{N}$. And about a function being a relation one to one is not necessaraly true, since $f(x) = x^{2}$ is a function but not one to one, i.e, not injective.

  • $\begingroup$ so does it being a natural number make it not a function or does that only apply to the co domain ? $\endgroup$ – Breanna Nov 1 '18 at 15:01
  • $\begingroup$ If you keep this definition $f:N\rightarrow N$ defined that way, it is not a function. But if you fix that like $f:N\rightarrow R$ it turns out to be a fucntion $\endgroup$ – Reinaldo R. Nov 1 '18 at 15:03
  • $\begingroup$ ok I think I am starting to get it , for clarification , the domain in this case would be the natural numbers and the co domain is the f (n)?, if I am wrong please correct me $\endgroup$ – Breanna Nov 1 '18 at 15:05
  • $\begingroup$ As in my answer, the domain may change depending of your context, but the codomain is going to be any set whose contains $f(N)$ $\endgroup$ – Reinaldo R. Nov 1 '18 at 15:16

In your case, you have $f:\mathbb{N} \to \mathbb{N}$, $f(n)=\sqrt{n}$.

Here, all natural numbers are valid arguments for the square root(no square roots of negative numbers or division by $0$), so domain will be $\mathbb{N}$. But there is a catch! All natural numbers do not give square roots lying in $\mathbb{N}$. Let us cine back to this after dealing with the range.

However, the co-domain is $\mathbb{N}$ ad given in the function definition.

Now, for the range, note that the function shall map real numbers onto their square roots which also have to be natural numbers. Clearly, the function shall map onto natural numbers which are square roots if other natural numbers.

We can now see that the d domain consists of all natural numbers having natural square roots, while the range of all natural numbers which are square roots of the natural numbers from the domain. But notice that, the all natural numbers are square roots of some or the other natural numbers ( can you see why?).


$D(f) =\{ n | \sqrt{n} \in \mathbb{N} \} = \{ n^2 | n \in \mathbb{N} \} = \{ 1,4,9,..\}$ and,

$R(f) = \mathbb{N} =$ Codomain$(f)$.

Now, can you see how if we take the function to be $f : \mathbb{R^{*}} \to \mathbb{R^{*}}$, you will have -

$D(f) = R(f) = C(f) = \mathbb{R^{*}}$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.