# We havef:{1,2,3}->{1,2} and g:{1,2,3}->{1,2,3,4}.How many injective f and g funtions exist?

Jul 10, 2018

$f$ can't be injective.

$g$ can be injective in $24$ ways.

#### Explanation:

A function is injective if no two inputs provide the same output. In other words, something like

$f \left(x\right) = f \left(y\right) , \setminus \quad x \setminus \ne y$

can't happen.

This means that, in the case of finite domain and codomain, a function can be injective if and only if the domain is smaller than the codomain (or, at most, equal), in terms of cardinality.

This is why $f$ can never be injective. In fact, you can fix $f \left(1\right)$ as you like. Say $f \left(1\right) = 1$, for example. When choosing $f \left(2\right)$, we can't say again that $f \left(2\right) = 1$, or $f$ wouldn't be injective. But when it comes to $f \left(3\right)$ we have no choice, if we say $f \left(3\right) = 1$ we have $f \left(1\right) = f \left(3\right)$, and if we say $f \left(3\right) = 2$ we have $f \left(2\right) = f \left(3\right)$.

In other words, we must assing one of two possible ouputs to each of the three inputs. It should be evident that the inputs can't provide different outputs.

On the other hand $g$ can be injective, since there is "enough space": each of the three inputs can choose one of the four outputs in such a way that no different inputs provide the same output.

But in how many ways? Well, suppose we start again with $f \left(1\right)$. We can choose any of the four ouputs for this input, so we can choose $f \left(1\right)$ in four ways.

When it comes to $f \left(2\right)$, we lose some freedom: we can assign any value to $f \left(2\right)$, except for the one we assigned to $f \left(1\right)$, so we're left with two choices. For example, if we fixed $f \left(1\right) = 2$, then $f \left(2\right)$ can either be $1$, $3$ or $4$.

By the same logic, we have two choices for $f \left(3\right)$: from the four possible choices, we rule out those already assigned to $f \left(1\right)$ and $f \left(3\right)$.

So, we can define $g$ in $4 \cdot 3 \cdot 2 = 24$ ways such that $g$ is injective.