Is this function surjective or injective? [closed]

I have the following function $$f: \Bbb{Z} \times \Bbb{N} \to \Bbb{Q}, f(m,n) = m/n$$. Is this function injective or surjective? How can I prove it? I'm new to discrete maths so please bear with me.

• Do you know what injective and surjective mean? If you do, checking the definition would help. (The surjective part is kind of the definition of $\mathbb{Q}$, and the injective part is obvious if you know the definition)
– Lab
Commented Oct 30, 2021 at 4:09
• Given an element $q$ of $\mathbb Q$, can you find an integer $m$ and a natural number $n$ such that $m/n = q$? If so, you've just shown that $f$ is surjective. Commented Oct 30, 2021 at 4:09
• Can you find multiple ways to write $1$ as an integer $m$ divided by a natural number $n$? If so, you've just shown that $f$ is not injective. Commented Oct 30, 2021 at 4:10
• @AlexG. thanks sir. Commented Oct 30, 2021 at 4:26

First of all, recall the meaning of injective and surjective

1. Surjective means that the image of the function is the entire codomain (in your case $$\mathbb Q$$)
2. Injective means there are not two elements in the domain of the function for which map to the same point of the codomain.

Your function is surjective and not injective.

1. It's surjective because every rational number can be represented by an integer divided by a natural number
2. It's not injective because $$1/2 = 2/4 \implies f(1,2) = f(2,4)$$, but $$(1,2)$$ and $$(2,4)$$ are different points in $$\mathbb Z \times \mathbb N$$
• Thank you kind sir. Commented Oct 30, 2021 at 4:24

To prove surjection, we must show that for every element of the codomain, the function maps at least one element of the domain to it. It then suffices to show that given any arbitrary element $$q \in \mathbb{Q}$$, we can produce an element $$(m,n) \in \mathbb{Z} \times{\mathbb{N}}$$ such that $$f(m,n)=q$$.

Proof: Let $$q \in \mathbb{Q}$$, then by definition $$q= \frac{a}{b}$$ for some $$a,b \in \mathbb{Z} \left(b \neq 0\right)$$. If $$b>0$$, let $$m=a$$ and $$n=b$$. Then clearly $$m \in \mathbb{Z}$$ and $$n \in \mathbb{N}$$ so we will have $$f(m,n)=f(a,b)=\frac{a}{b}=q$$ as desired. Otherwise if $$b<0$$ let $$m=-a$$ and $$n=-b$$, then we will have $$m \in \mathbb{Z}$$ and $$n \in \mathbb{N} \implies f(m,n)=f(-a,-b)=\frac{-a}{-b}=\frac{a}{b}=q$$, as desired. $$\Box$$

Now to prove $$f$$ is injective, we must consider whether each element of the domain is mapped by the function to no more than 1 element of the codomain. To show that $$f$$ is not injective, it suffices then to find one counter example of two elements in the domain which $$f$$ maps to the same element of the codomain. This simply takes some guess and check, and there are usually many possible examples.

Proof: Consider $$(2,3), (4,6) \in \mathbb{Z} \times{\mathbb{N}}$$. Then we have, $$f(2,3)=\frac{2}{3}=\frac{4}{6}=f(4,6)$$ Since $$(2,3) \neq (4,6)$$ but $$f(2,3)=f(4,6)$$ conclude $$f$$ is not injective. $$\Box$$