Consider $f:\{1,\cdots,n\} \to \{1,\cdots, m\}$ How many different functions f exist? Could someone please help me understand the question that I recently received in one of my courses at Uni:
Q:
Consider $f:\{1,\cdots,n\} \to \{1,\cdots,m\}$. That is for all $x ∈ \{1,\cdots,n \}$ a function value $f(x) ∈ \{1,\cdots,m\}$ is defined (note, both are discrete sets). How many different functions $f$ exist?
I nether understand the question, nor do I grasp the concept of functions and relations in regards to sets. When I think about functions, I think about polynomials and trigonometric functions. Therefore, for me, functions consist of a domain, a range, and a rule that explains how each element in the domain gets mapped to an element in the range. If I apply this reasoning to the problem given to me I would assume that at most there exists $n$ to the $m$ amount of functions, if there exists a function for each association between the input and the output. However, at the same time, it could be that each association between the input and the output is due to one function e.g. $\sin(x)$.
How many different functions exist? What am I not understanding?
 A: Let $|X| = m$ and $|Y| = n$. Then  No. of functions $f:X\to Y$ is $|Y|^{|X|} = n^m $
A: 
Therefore, for me, functions consist of a domain, a range, and a rule that explains how each element in the domain gets mapped to an element in the range.

You have to "understand" that a rule for a function does not have to be given by a nice expression like $f(x)=2x^2+3x+1$
It can also look like this $f(x)=\begin{cases}1\quad \text{if} x>0\\ 0\quad\text{else}\end{cases}$
Or in a case like in your task a function like $f:\{1,2,3\}\to \{1,2\}$ (so $n=2$ and $m=3$)
could be noted like this:
$f_1(1)=1$, $f_1(2)=1$, $f_1(3)=1$
of course there are more possibilities.
Many beginners would now make the mistake and only consider bijective functions, or forget some.
About functions there are kinda only two facts you have to keep in mind.
That the function is "left total" and "right exact". I do not know the exact english translation. This is more of a naive explanation anyways, but it should claryfy things.
Left total : Every element in the domain (left set) gets mapped onto something.
In the example above $f(1)=1$, $f(2)=2$ would not be a function, as 3 has no image.
Right exact : Every element in the domain is sent to one element only (in the right set).
So $f(1)=1$, $f(1)=2$, $f(2)=2$ would not be a function, because 1 gets mapped onto 1 and 2.
So to get a grasp of this problem, you could first work through the example given above and try to write down every possible function, like I did it.
Maybe you realize then, that this is more of a combinatorical problem.
Keeping the facts above in mind, how many possibilities do you have to map an element from the domain onto?
