Number of functions with certain property

69 Views Asked by At

Let $f : \{1,2,3\}\rightarrow\{1,2,3\}$ be a function. Then the number of functions $g : \{1,2,3\}\rightarrow \{1,2,3\}$ such that $f(x) = g(x)$ for at least one $x$ belonging to $\{1,2,3\}$ is what?

My reasoning was that total number of functions $f$ will be $3^3$ and for each of these functions I can have $g$ take exactly the same values as $f$ does so the answer would be $27$ but this answer is not correct, can someone please provide the solution.

3

There are 3 best solutions below

7
On BEST ANSWER

In general, the number of functions $\{1,...,n\} \to \{1,...,m\}$ is $m^n$.

Hence the number of functions in this case is $3^3$.

Remember $f$ is one specific function.

It is easier to count the number of $g$s that do not equal $f$ anywhere.

In particular, the range of such a $g$ must have size $2$ not $3$, hence the number of such functions is $2^3$.

Hence the number of the other $g$s, which is what you are looking for, is $3^3-2^3$.

Elaboration: What I mean is that $g(k)$ takes the values $\{1,2,3\} \setminus \{f(k)\}$, and for all $k$ we have $| \{1,2,3\} \setminus \{f(k)\} | = 2$.

3
On

It is more important to understand why your answer does not work.

Let's say that $f(1)=1, f(2)=2$ and $f(3)=3$

Then if you have $g(1)=2, g(2)=3$ and $f(3)=1$ (this is one of the $27$ possble functions for $g$), you have no $x$ such that $f(x)=g(x)$. So, not all $27$ possible functions for $g$ will have at least one 'match' with $f$.

Do you see how you can correct for this?

0
On

Probably it is easier to count the number $a$ of functions $g$ such that $g(x)\not=f(x)$ for all $x\in\{1,2,3\}$ first. Then the set of functions you are looking has cardinality $b-a$ where $b$ denotes the number of all functions mapping $\{1,2,3\}$ Info itself.