Need to check one to one and onto functions

97 Views Asked by At

a) Give an example of a function from $\Bbb{Z}^+$ to $\Bbb{Z}^+$ that is neither one-to-one nor onto.

b) Let $g:A\to B$ and $f : B \to C$ be functions. Let $f\circ g$ be onto. Are both $f$ and $g$ necessarily onto?

I was thinking for

a) $f(n) = 1$

I clearly see that this is not one to one, since there is no unique codomain for each input. but im not sure about onto..

Wouldn't all values point to 1 which would make it onto? since the codomain is 1? or would it? im confused if there is no x value in the function.

3

There are 3 best solutions below

0
On

For a) the function would not be one to one. That is correct.

It appears you have conflated the codomain and the range of a function.

The codomain of $f$ is $\Bbb{Z}^+.$ The range of $f$ is $\{1\}\ne \Bbb{Z}^+.$

0
On

It seems that you may be misunderstanding what codomain is.

The codomain of a function $f$ is the set $Y$ that all the outputs of the function must fall into.

You are probably most familiar with functions in $\mathbb{R}^2$. For example the line $f(x)=x$ is a straight line through the origin with slope $1$. In most lower level classes, it was assumed that when talking about a function we assumed the domain to be all real numbers, denoted $\mathbb{R}$. In most cases, we also assumed the codomain to be $\mathbb{R}$ because for any $x$ we take and plug into our function $f(x)$, it better spit back out a real number. But don't confuse this with the range, which is the set of elements $\{y | f(x) = y \text{ for some } x \text{ in the domain } \}$

Now what does it mean for a function to be one-to-one and onto?

A function is one-to-one (or injective) if for two elements in the domain $x_1$ and $x_2$, $f(x_1) = f(x_2)$ implies that $x_1 = x_2$. A visual way to describe this for a continuous function in $\mathbb{R}^2$ is if the graph passes the horizontal line test (which is similar to the vertical line test, but now horizontal)

A function is onto (or surjective) if for all elements $y$ in the codomain $Y$ there exists an element $x'$ in the domain where $f(x') = y$. This means if I give you a particular element in the codomain, any element, there is a certain "$x$" you can plug into the function and spit out the particular element I asked for.

Your question asks you to find a function $f$ going from domain $\mathbb{Z}^+$ to codomain $\mathbb{Z}^+$, where it is neither one- to-one nor onto.

Your example actually works, $f(n) = 1$. Obviously the function will spit out $1$ no matter what positive integer you plug in. So we do have that, for example, $f(3) = f(5)$. But immediately we can say that this doesn't imply that $3=5$. So it isn't one-to-one.

Your function is not onto either. The only element in the codomain your function spits out is $1$. There's nothing we can plug into $f$ and get $2$ or $4$, for example.

Maybe if you understand a little better, you can give part B another try...

0
On

I think you are confusing co-domain with image/range. With a clearer understanding of what it means this should be much simpler.

If $f: A \to B$ then $A$ (what is mapped from; every element of $A$ is mapped) is the domain, and $B$ (what is mapped to) is the co-domain. It doesn't matter whether all the elements of $B$ are mapped to, $B$ is declared, by fiat, to be the "universe" where $A$ gets mapped.

The function is onto if all the elements of the co-domain $B$ are mapped to. And the function is not onto if not all the elements of $B$ are mapped to.

So $f(x) =1$ is EXTREMELY not onto, as none of the $z\in \mathbb Z^+$ except $1$ are mapped to.

That's all onto means.

then element $f(x)$ is called the image of element $x$. And if $C\subset A$ then $f(C) := \{f(c)|c\in C\}$ = the set of all points of where the points of $A$ are to, is called the image of the set $C$. And $f(A) = \{f(x)|x \in A\}$ is called either the image of $A$ or the range of the function.

Notice: $f(A) \subset B$. The range is always a subset of the co-domain. And notice that $f$ is onto if and only if $f(A) = B$. So a function is onto if the range/image is equal to the entire co-domain; and a function is not onto if the range/image is a proper subset of the co-domain.

Another way to tell a function is not unto is if any $y \in B$ is anot equalt to some $f(x)$ for some $x \in A$. In this case $f(x) =7$ has no solution so $f$ is not unto. There's nothing special about $7$. I could have tested any value other than $1$.

so if $f: \mathbb Z^+ \to \mathbb Z^+$ is defined by $f(z) = 1$ then $f(\mathbb Z^+) = \{1\} \subsetneq \mathbb Z^+$ so $f$ is not onto because the range, $\{1\}$ is not the entire co-domain, $\mathbb Z^+$.

One-to-one means that each element of the domain $A$ is mapped into a distinct point of $B$. There are several ways to think of this. You can say a function is onto if the image of each point in the domain is distinct. Or you can say a function is one-to-one if $x \ne w$ always means $f(x) \ne f(w)$. Or you can say a function is one-to-one if $f(x) = f(y)$ always means $x = y$.

Examples: $f:\mathbb Z^+ \to \mathbb Z^+$ via $f(x) =1$ is neither one-to-one nor onto. It is not one-to-one because if $x \ne y$ it does not meean $f(x) \ne f(y)$ if fact $f(x) = f(y) = 1$ always. And it is not onto as explained above.

$g:\mathabb Z^+ \to \mathbb Z^+$ via $g(z) = |z-5| + 1$ is onto but it is not one-to-one.

We know it is onto because every $y\in \mathbb Z^+$ is mapped to. We can prove this by consider for any $y \in \mathbb Z^+$, we ask ourselves if there is always an $x\in \mathbb Z^+$ where $g(x) = y$.

If so that would mean $|x-5| + 1 = y$ so $|x-5| = y-1$. If $x -5 \ge 0$ that would mean $x-5 = y-1$ so $x = y+4$ such an $x$ will always exist. So $g$ is unto. We don't even need to check if $x-5 < 0$.

To show it is not unto we need to check if $g(x) = g(w)=y$ must mean $x=w$. So if $f(x) = f(w) then $|x - 5| + 1 = |w-5| + 1$ so

$|x-5| = |w-5| and $(x-5) = \pm (w-5)$. If $x-5 = w-5$ then, yes, $x = w$. But if $x-5 = -(w-5)$ then $x+w = 10$. That that can happen if $w = 10-x$ and $x < 10$. For example: If $x = 2$ and $w=8$ then $g(x) = |2-5| = |-3| = 3$ and $f(w) = |8-5| = 3 = g(x)$. So $g$ is not onto.

$h: \mathbb Z^+\to \mathbb Z^+$ defined by $h(x) = x + 1$ is one-to-one but not onto.

It's not onto because if $f(x) = y$ then $x+1 = y$ and $x = y-1$ soif $y = 1$ then $y-1 = 0$ so there is not $x \in \mathbb Z^+$ so that $f(x) =1$. So $1$ is not mapped to.

It is one-to-one because if $h(x) = h(w)$ then $x +1 = w+w$ and $x = w$.

Finally $i: \mathbb Z^+ \to \mathbb Z^+$ defined by $f(x) =x$ is both one-to-one and onto. For obvioua reasons.