# Functions

A function is much like a computer program. The **function** is a rule (e.g., an equation) that takes some inputs (numbers) and produces some output, another number. One kind of function is the type where we put one real number in and get one real number out. These are usually written, *y* = *f*(*x*), where *x* is the number we put in, *y* is the number we get out, and *f*(*x*) is the rule that says how to get from *x* to *y*. In this case, we say that *y* *is a function of* *x*.

A function is a special kind of relation where each input is only allowed to have one output. Any equation containing only the variables *x* and *y* describes a relation between *x* and *y*. If the equation allows only one value of *y* for each value of *x*, the equation describes *y* as a function of *x*.

Since the number we get out depends on what we put in, we call *y* the **dependent** variable and *x* the **independent** variable. One way to remember this is that the *in*dependent variable is the *in*put, while the dependent variable is the output. If there was such a word as "outdependent", those clever mathematicians would have used it.

The set of numbers that can be given as inputs is called the **domain** of the function, while the set of numbers that are outputs of the function is called the **range** of the function.

### Sample Problem

The equation *y* = *x*^{2} defines *y* as a function of *x*. The variable *x* is independent and the variable *y* is dependent.

While *x* is usually the independent variable, we can also switch the letters around. If an equation allows only one value of *x* for each value of *y*, we could say the equation defines *x* as a function of *y*. Letters are just letters, after all. They are used to represent numbers. We could write *y* as a function of a purple elephant, if we wanted.

### Sample Problem

The equation *x* = *y*^{2} defines *x* as a function of *y*, because for each *y* there is only one possible value of *x*. If we take *y* as the independent variable and *x* as the dependent variable, we have a function *x* = *f*(*y*).

### Sample Problem

The same equation *x* = *y*^{2} does not define *y* as a function of *x* because for each value of *x* there are two possible values of *y* ( and ).

### Sample Problem

The equation *x* = *y* describes *x* as a function of *y* and also describes *y* as a function of *x*.

### Sample Problem

The equation *x*^{2} = *y*^{2} does not describe *x* as a function of *y*. How do we know for sure? Try a couple numbers in the equation. If *y* = 2 then *x* can be either 2 or -2. For any value of *y* there are two possible values of *x*. This equation doesn't describe *y* as a function of *x* either, because for any value of *x* there are two possible values of *y*. If *x* = 2 then *y* = ± 2.