next up previous
Next: About this document Up: My Home Page

Composition of Functions

If the range of a function tex2html_wrap_inline251 is a subset of the domain Y of a function tex2html_wrap_inline255 , we can compose the two functions f and g to obtain a function

displaymath225

defined by: tex2html_wrap_inline261 , for all tex2html_wrap_inline263 .

For example, let f be the successor function on the integers, i.e., f(n) = n+1, and g be the squaring function, tex2html_wrap_inline271 . Then

displaymath226

whereas

displaymath227

If domain and codomain of a function are identical, it can be composed with itself:

displaymath228

and

displaymath229

Perfect Shuffles

A perfect shuffle of a deck of cards splits the deck in half and then merges the two halves so that no two adjacent cards come from the same half.

The reason we use shuffles on a deck of cards is to mix them up.

So what happens if we do a series of eight consecutive perfect shuffles on a 52 card deck? The example below shows that we end up with the cards in the same order as we started!!!

What this shows is that the composition of eight shuffles gives the identity function:

displaymath230

Why do eight suffice? Observe that (except for the last card), the shuffle takes position x to position tex2html_wrap_inline275 . Further, tex2html_wrap_inline277 , so multiplying it eight times is like multiplying by 1, i.e. the identity function.

Properties of Composed Functions

Recall that the identity function tex2html_wrap_inline279 on a domain A is defined to be a function from A to A with tex2html_wrap_inline287 , for all elements x of the domain A.

Theorem

If f is a function from A to B, then

displaymath231

and

displaymath232

Certain properties of functions carry over to their composition.

Theorem

If f is a one-to-one function from A to B and g a one-to-one function from B to C, then tex2html_wrap_inline311 is a one-to-one function from A to C.

If f is an onto function from A to B and g an onto function from B to C, then tex2html_wrap_inline329 is an onto function from A to C.

The Inverse of a Function

If f is a bijective function from A to B, its inverse is a function tex2html_wrap_inline341 from B to A, defined by:

displaymath233

For example, if f is the function on the real numbers, defined by f(x)=4x-1, then tex2html_wrap_inline351 , for all real numbers y.

Note that the inverse of a bijective function is also bijective.

The above definition is valid since for a bijective function f the value f(x) is uniquely determined by x. But this is also the case for one-to-one functions.

Can we define an inverse for any one-to-one function f, even if f is not onto?

Yes, but in that case the inverse is a function from the range of f to the domain of f.

Application of Functions: Codes

Let tex2html_wrap_inline369 be the set tex2html_wrap_inline371 and tex2html_wrap_inline373 be the set of all finite sequences, or strings, of elements of tex2html_wrap_inline375 .

Let us map characters in tex2html_wrap_inline377 to bitstrings as follows.

tabular185

We can extend this mapping to a function on tex2html_wrap_inline379 by defining:

displaymath234

For example, the code C(eaabb) is the bitstring

displaymath235

Is the function C one-to-one? Onto?

In general, encoding functions need to be one-to-one, for otherwise decoding may be difficult, or impossible.

Character codes like this (ascii) is how text strings are represented in computers.

Prefix Codes

Now consider a different, variable-length, code:

tabular191

With this function we can encode eabbe by a shorter bitstring

displaymath236

But can we also decode strings?

No, the code could also represent the string baaabbbaa. In other words, the function is not one-to-one.

Let's look at another variable-length code.

tabular196

The encoding of eabbe by D' yields

displaymath237

Is this function one-to-one?

The answer is yes, as the function represents a so-called prefix code, that is, no codeword C(x) is a prefix of another codeword C(y), where x and y denote different symbols.

How are bitstrings decoded in this case?




next up previous
Next: About this document Up: My Home Page

Steve Skiena
Tue Aug 24 19:55:37 EDT 1999