# Sets and functionsFunction Operations

## Restriction

It is frequently useful to focus on a subset of the domain of a function without changing the codomain elements that the function associates with those domain elements. For example, if we partition a grocery list with quantity counts among several shoppers, then each shopper will be interested in the *restriction* of the quantity count function to their own portion of the domain. In other words, they need to know how many of each of their items to pick up, and they don't need to know anything about the other shoppers' items.

**Definition** (Restriction)

If and , then the **restriction** of to is the function

defined by

**Exercise**

State a general relationship involving the terms *restriction*, *image*, and *range*.

*Solution.* If and , then the range of the restriction

is equal to the image . These sets are equal because they are both equal to the set of elements of which maps to from some element of .

## Composition

Sometimes the elements output by a function will themselves have associated data, and in this case we often want to connect each element in the domain of to these data.

For example, consider the *album* function from the set of songs to the set of albums. Evaluated on a song, the album function returns the album on which the song appeared. Consider also the *year* function from the set of albums to the set of years (which returns the year in which each album was released). We can determine the year in which a song was released by *composing* the album function and the year function.

**Definition** (Composition)

If and , then the function which maps to is called the **composition** of and .

**Exercise**

Show that composition is associative: for all functions , , and with the property that the codomain of is equal to the domain of and the codomain of is equal to the domain of .

*Solution.* We check that two functions are equal by checking that they have the same domain and codomain and that they map all input values to the same output values.

The domain of is the domain of , and the domain of is . Similarly both functions have a codomain equal to the codomain of .

Furthermore, maps to , which by definition of is equal to . Similarly, maps to . Therefore, these functions are equal, and we conclude that compositions are associative.

## Anonymous functions

If the rule defining a function is sufficiently simple, we can describe the function using **anonymous function notation**. For example, , or for short, is the squaring function from to . Note that bar on the left edge of the arrow, which distinguishes the arrow in anonymous function notation from the arrow between the domain and codomain of a named function.

**Exercise**

Suppose that is the function . Then =

*Solution.* We first substitute into the tripling function to get , and then we substitute that value into the square root function to get .

## Inverses

Suppose that is a function from the set of names of customers at a bank to the set of their primary checking account numbers. Specifically, suppose maps each customer name to that customer's primary checking account.

Since is bijective, we can ask to *reverse* the lookup that performs: given a primary checking account number, what is the corresponding customer name? This function from to is called the *inverse* of .

**Exercise**

Find the inverse of the function from the interval to the interval .

*Solution.* Given , we want to find the value of that maps to it. In other words, we want to solve for

**Exercise**

Select the functions which have inverses.

**Exercise**

Which of the following is equal to , if and are invertible functions for which the codomain of and the domain of are equal?

*Solution.* We have , so is the inverse of .

**Congratulations!** You've completed the Data Gymnasia *Sets and Functions* course.