### Set Operations on Functions

Functions are sets, so we can try to combine them like we combine sets. That is, we can ask the following questions:

- Is the complement of a function necessarily a function?
- Is the intersection of two functions necessarily a function?
- Is the union of two functions necessarily a function?
- Is the set product of two functions necessarily a function?

Let's investigate the first three; the last one I'll leave for homework.

To start with, let's pick two functions and run with them. How about: and .

The complement of is , shown here in hatching:That's definitely not a function: it badly fails the vertical line test.

What about intersection?

The intersection is just two points; so is not a function from to . But *is* a function from a smaller set.

Let's look at :

It also fails the vertical line test. But:

**The Pasting Lemma (in the category of** **sets)**. Let and be two functions. Then if and only if .

**Proof. **This is a biconditional, so we have two directions:

() Assume . We need to show is a function; to do this, there are two clauses.

(clause 1: domain) Let . Then either or .

If , then because , . Then .

If , then because , . Then .

In either case, there's an element of so that . That's clause 1 of the definition of function.

(clause 2: unambiguousness) Let and be such that and . There are four cases:

If and , then the fact that is a function implies .

If and , then the fact that is a function implies .

If and , then we have and , so . But then . So . So . Since is a function, .

If and , then we have and , so . But then . So . So . Since is a function, .

In any of these four cases, , which is what we needed for clause 2 of the definition of function.

() In this direction, we need to show two functions are equal. So we should probably use the TAWFAE. I'll leave this direction to you.

Why does this theorem bear such a silly name? Consider this diagram, which tells you how to build a cube from a piece of paper. In order to attach the sides, you have to paste the red tab to the back of one of the appropriate square (I've indicated where the red tab gets attached by coloring it green). We won't succeed in pasting unless the red tab and the green target match up.

That's what the condition ensures: that the functions and agree on the overlap of their domains.

Again, an example from precalculus mathematics: when we define a function piecewise, like

we usually want to make sure that the two pieces have *nonoverlapping* domains. This corresponds, in the Theorem above, to the case that . If we weren't so careful, we might have a situation like this:

where it's ** ambiguous **what is:

### Composition of Functions

Because functions are relations, we can consider their composites. We have the following nice theorem:

**The Composition of Functions Is a Function. **If and , then .

**Proof. **There are two things to show:

(clause 1: domain) Let . Then, because is a function, . Since and is a function, . Then . .

(clause 2: unambiguousness) Given so that and . We need to show .

Since , there is some with and . We also have with and .

Since is a function, . So we have . But since is a function, and forces . .

**Important Formula.** If and are functions, so that is a function, then .

**Proof. **What does it mean for ? It means . But that means and . So and . By substituting, we obtain .

This formula explains the "backwards" looking choice of how we write compositions: even though come first, we write . The only way out of this would be to switch our function notation to something like , so that the composite would be . (Some people do this, and it has a name: *reverse Polish notation*. But most normal people don't do it.)