48
$\begingroup$

In my discrete mathematics class our notes say that between set $A$ (having $6$ elements) and set $B$ (having $8$ elements), there are $8^6$ distinct functions that can be formed, in other words: $|B|^{|A|}$ distinct functions. But no explanation is offered and I can't seem to figure out why this is true. Can anyone elaborate?

$\endgroup$

6 Answers 6

77
$\begingroup$

A function on a set involves running the function on every element of the set A, each one producing some result in the set B. So, for the first run, every element of A gets mapped to an element in B. The question becomes, how many different mappings, all using every element of the set A, can we come up with? Take this example, mapping a 2 element set A, to a 3 element set B. There are 9 different ways, all beginning with both 1 and 2, that result in some different combination of mappings over to B.

enter image description here

The number of functions from A to B is |B|^|A|, or $3^2$ = 9.

$\endgroup$
4
  • 4
    $\begingroup$ Very thorough. Sadly I doubt the original poster will see it though. $\endgroup$
    – Simon S
    Commented Nov 8, 2014 at 23:54
  • 1
    $\begingroup$ Very good graphical approach. Helped me understand that the number of functions from set A is the number of functions counted silmutanuously $\endgroup$ Commented Mar 7, 2016 at 8:38
  • $\begingroup$ Congrats for your fifth badge ! $\endgroup$ Commented Mar 22, 2017 at 12:21
  • $\begingroup$ So if the output for 1 remains the same but the output of 2 changes then is it considered as a new function? So is this the reason why we are multiplying instead of adding? $\endgroup$
    – Kaushik
    Commented Aug 4, 2019 at 12:57
67
$\begingroup$

Let set $A$ have $a$ elements and set $B$ have $b$ elements. Each element in $A$ has $b$ choices to be mapped to. Each such choice gives you a unique function. Since each element has $b$ choices, the total number of functions from $A$ to $B$ is $$\underbrace{b \times b \times b \times \cdots b}_{a \text{ times}} = b^a$$

$\endgroup$
0
10
$\begingroup$

Let's say for concreteness that $A$ is the set $\{p,q,r,s,t,u\}$, and $B$ is a set with $8$ elements distinct from those of $A$. Let's try to define a function $f:A\to B$.

What is $f(p)$? It could be any element of $B$, so we have 8 choices.

What is $f(q)$? It could be any element of $B$, so we have 8 choices.

...

What is $f(u)$? It could be any element of $B$, so we have 8 choices.

So there are $8\cdot8\cdot8\cdot8\cdot8\cdot8 = 8^6$ ways to choose values for $f$, and each possible set of choices defines a different function $f$. So that's how many functions there are.

$\endgroup$
2
  • $\begingroup$ Is the set of all such functions denoted by $B^A$? $\endgroup$
    – John Mars
    Commented Feb 24, 2021 at 22:48
  • $\begingroup$ That is correct. $\endgroup$
    – MJD
    Commented May 27, 2022 at 10:36
3
$\begingroup$

You know that a function gives a unique value for each entry, if the function $f\colon A\to B$ where $|A|=n, ~|B|=m$, then for $a\in A$, you have $m$ values to assign. then for every $a\in A$, you can take |B| values, since $|A|$ have $n$ elements, then you have $|B|^{|A|}$ choices.

$\endgroup$
1
$\begingroup$

The cardinality of $B^A$ is the same if $A$ (resp. $B$) is replaced with a set containing the same number of elements as $A$ (resp. $B$).

Set $b = |B$|. When $b \lt 2$ there is little that needs to be addressed, so we assume $b \ge 2$. Assume $|A| = n$.

A well known result of elementary number theory states that if $a$ is a natural number and $0 \le a \lt b^n$ then it has one and only one base-$\text{b}$ representation,

$$\tag 1 a = \sum_{k=0}^{n-1} x_k\, b^k \text{ with } 0 \le x_k \lt b$$

Associate to every $a$ in the initial integer interval $[0, b^n)$ the set of ordered pairs

$$\tag 2 \{(k,x_k) \, | \, 0 \le k \lt n \text{ and the base-}b \text{ representation of } a \text{ is given by (1)}\}$$

This association is a bijective enumeration of $[0, b^n)$ onto the set of all functions
mapping $[0,n-1]$ to $[0,b-1]$.

Since $[0, b^n)$ has $b^n$ elements, we know how to count all the functions from one finite set into another.

$\endgroup$
0
$\begingroup$

It follows from the definition that there is a bijection from $\mathrm{Func}(A,B)$ to $\prod_{i \in A}B_i$ where each $B_i$ is a copy of $B$. Thus the cardinal of $\mathrm{Func}(A,B)$ is equal to the cardinal of $\prod_{i \in A}B_i$. In particular, when $A,B$ are finite sets, we have $$ \# \ \mathrm{Func}(A,B) = \# B^{\# A}. $$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .