[Math] Can you define a function f: N->N that is one-to-one and not onto

discrete mathematics

The book 'Discrete Math and its Application' has the following problem:

20. Give an example of a function from N to N that is
a) one-to-one but not onto.

Is it possible to define a function f:N->N, that is one-to-one but not onto?

For the function to be one-to-one every element in the domain has to be assigned exactly one unique element in the codomain. This also means that then there exists no element in the codomain that hasn't been assigned a value from the domain, thus it's onto since the range of the function equals the codomain. So it looks to me like it's impossible for the function to be both one-to-one and not onto.

The definition of a function that i'm working with is the following:

Let A and B be nonempty sets. A function f from A to B is an assignment of exactly one
element of B to each element of A. We write f (a) = b if b is the unique element of B
assigned by the function f to the element a of A. If f is a function from A to B, we write
f : A → B.

Best Answer

You are wrong when you say :

This also means that then there exists no element in the codomain that hasn't been assigned a value from the domain...

A function is injective (one to one) iff every element of its codomain is the image of at most one element of its domain, but this does not means that every element of the codomain is the image of some element of the domain.

There are many examples of such functions $f:\mathbb{N}\to \mathbb{N}$ e.g $f(x)=2x$ or $f(x)=x^3$, and also $f(x)=x^2$ that is not injective as a function $f: \mathbb{Z} \to \mathbb{Z}$.

Related Question