# An Intuitive Introduction to Functions

Here we will introduce the concept of Function in a friendly, commonsense manner. For a more formal and complete discussion, please see the article titled Relations and Functions.

## Functions in a General Sense

### A First Example

One of the most useful analogies to use when describing functions is that of an "input/output machine" (something akin to a factory). The idea is that you begin with a set of potential inputs and a set of potential outputs. Then you define the function as a machine that produces a certain output for specific input. One way to illustrate this is the Venn Diagram below. The set on the left is the set of possible inputs, and the set on the right is the set of possible outputs. Each arrow shows which input is associated with which output. The arrows as a whole "are the function." This means that the arrows show which inputs produce which outputs. For instance if one inserted triangle as an input to this function the function would output red. The function illustrated here has an overarching pattern or rule which dictates what the output should be for each input. Take a moment and see if you can spot it? The pattern is that the the function outputs the colour of the shape inputted. Not all functions have a nice rule like this (the function can be arbitrarily defined), but virtually all of the functions used in practical applications do.

In our example you can see that all of the possible inputs are used (have an arrow pointing from them) and 3 of the five outputs are used (have an arrow pointing to them). The other two potential outputs turn out not to be outputs of this function. Whether or not all the elements of the input or outputs sets get used is not important. What is important is that for each input you have only one possible output.

Another interesting point to consider is that if we know the output set is the set of colours, is it really necessary to list the colours we could output before hand? The required information is actually entirely available in the input set. We can see the colour of the triangle, the rectangle etc, so given the rule (take the colour of the input shape) and the general description of allowed outputs (the output set is the set of colours) we can infer the specific outputs required. This saves us from dealing with extra unused potential outputs. It is a trick you will see extensively in your future functions education.

### Another Example (Presented in Other Useful Forms)

### A Non-Example

## Using a Function's Output as Another Function's Input (Function Composition)

Sometimes we want to chain function together. This is analogous to a production line in a factory, or a series of steps to be followed in a procedure (like cooking). An example follows. INSERT TABLE EXAMPLE

When we feed functions into each other in this manner it is called **Function Composition**.