# Number of functions from a set to another

How many functions are there from a set with $$n$$ elements to another with $$m$$ elements?

The answer is $$m^n$$ but this doesn't seem to account for the fact that an element might not have an image by that function, right?

For each element of the domain of the function, there are $$m+1$$ ways of it being "mapped"; the $$1$$ accounts for it not being mapped. So shouldn't the result be $$(m+1)^n$$?

You may have seen some examples of partial functions that weren't explicitly called so, though. Like the partial function $$f$$ from $$\Bbb R$$ to $$\Bbb R$$ given by $$f(x) = \frac1x$$, or other rational functions. These are often called "functions" throughout school, and proper care to the definition of a function and restricting the domain appropriately is often not taken until late high school or university.
• Just for added clarity: the nomenclature, especially through high school, may get a little fuzzy. $f(x)=\frac1x$ is sometimes a function, if we define the domain to be $\mathbb R\setminus \{0\}$, and in fact, I think that's how most students are first introduced to it. It is only a partial function if you map from $\mathbb R$. – 5xum Apr 29 '20 at 7:33