In the study of algebra, students are first exposed to the use of variables, such as *x*, to represent quantities that are unknown or that might change over time. This idea comes naturally to some students, but for others, a great deal of effort is expended to understand the concept.

The next major hurdle in algebra comes with the introduction of functions. Just as a variable represents a number, a function represents an expression or operation that is performed on a number. This page introduces the concept of the function, giving a variety of ways for the student to think about functions.

## Function DefinitionEdit

A function definition -- the definition of the function named "f" -- looks like this:

*f*(*x*) =*expression*,

where *expression* is an algebraic expression that has some value, usually depending on x. Students sometimes question the meaning of "x" in the function definition, because they rightly discern that its use is different from the use of x they're familiar with. Here, the variable "x" is called a parameter of the function, and it has meaning only within the function definition itself. To shed light on the meaning of a function definition and the special role of the parameter, let's start with an example:

### ExampleEdit

Here is a function definition:

*f*(*x*) =*x*²+3

This means that the function has the effect of squaring its parameter, and then adding three. Since x is a parameter, it is intended to show that f would yield the same result for anything used in place of x. For example, f(4) = 4²+3, so f(4) is 19.

### Test your understandingEdit

Refer to this definition:

f(x) = x²+3

Does this define f(x)? Or does it define f?

Perhaps the question looks meaningless to you, so bear with me for a minute. The point I'm making is that the definition of the function has nothing to do with any variable, x, that may have been discussed prior to (or even subsequent to) the definition of the function. The meaning of x exists only within the definition itself, and serves to define the function, f. The answer to the question is that the definition defines f.

Now, refer to these two definitions:

f(x) = x²+3 g(y) = y²+3

The first one defines a function, f, and the second one defines a function, g. Are these functions different?

At first, you might be tempted to say that f depends on x, and g depends on y, so they are different. But if you said that, you would be wrong, because f doesn't depend on x at all. Rather, the parameter, x, is used simply to define f. And a different parameter, y, is used to define g. The choice of parameter is arbitrary, and doesn't figure into the definition of the function at all. The answer: these two functions, f and g, are the same.

## Ways to think of functionsEdit

The concept, *function*, is so open-ended that there is a seemingly endless parade of ways to look at them.

### A function as a black boxEdit

One way to think of a function is as a "black box" -- that is, a box that does some kind of operation on its input, and produces a number as a result. For example, suppose f is a function. When it accepts 2 as input, it spits out 7 as output. When 3 goes in, 12 comes out. When 4 goes in, 19 comes out. We could draw a picture that looks like this to illustrate f:

- 2 —> [ f ] —> 7
- 3 —> [ f ] —> 12
- 4 —> [ f ] —> 19

Do you recognize this function, f, as the same one we have used in previous examples? In each case, the function works by squaring its input value, and then adding three. The diagram, above, shows what happens to each of three input values. Algebraically, we would write it this way:

- f(2) = 7
- f(3) = 12
- f(4) = 19

These are two equivalent ways to represent what the function, f, does to each of three input values.

### A function as an algorithmEdit

Another way to think of a function is as an "algorithm" -- a series of steps that are performed in a particular order to get a result that depends on the input. If f is a function that squares its input and then adds three, this is an algorithm that tells you what f would do to any input. What would f(5) be? Well, start with 5, then square it. That gives you 25. Then add three. The result is 28. So f(5) = 28.

### A function as a setEdit

You can also think of a function as a set of pairings. ^{[improvement needed: You can help]} Each element of the domain is paired with exactly one element of the range. ^{[improvement needed: elaborate]}

### Implicitly defined functionsEdit

Variables *x* and *y* are often used in an expression in which *y* is considered a function of *x*, so you could write *y*(*x*) = *x*², for example. Also, in parametric equations, it is common for *x* and *y* to both be functions of *t*, and the function notation is, for simplicity, left off. This is especially helpful in the analysis of related rate problems.

## Plotting a functionEdit

We've explored three different ways to depict a function: with a formal definition using a parameter, as a "black box" that accepts a number as input and produces a number as output, and as an algorithm. Yet another way to depict a function is by plotting its input and output on the x-axis and y-axis, respectively.

- f(x) = x²+3

You may recognize this as the graph of y=x²+3. This is to be expected, because it is customary to plot the value (the output) of the function on the y axis, and the parameter (the input) of the function on the x axis. This is probably the reason that "x" is used so frequently as the parameter in formal definitions of functions, although, as we have seen, we don't have to use x for this purpose.

### InverseEdit

If we view a function as an algorithm, can we make it go backwards? That is, can we start with the result, and "undo" each of the steps, giving us back the original input? Let's define h is the inverse of f. Whereas f squares the input and then adds three, h subtracts three, and then finds the square root of the input. Notice that each step is undone, and the order is the reverse order. So if we start with 28 and run it through the function, h, we subtract 3 giving 25, then find the square root, 5. So h(28) = 5. Here it is in a chart:

^{[improvement needed: add table]}
Function h is the inverse of function f
f squares its input, then adds 3 h subtracts 3, then finds the square root
f(x) = x²2+3 h(x) = sqrt(x-3)
f(2) = 7 h(7) = 2
f(3) = 12 h(12) = 3
f(4) = 19 h(19) = 4

One way to plot the inverse of a function is to simply relabel the axes. Look at the plot, above. What was called "x" can now be called "h(x)", and what was called "f(x)" can now be called "x". You see, by relabeling the axes we simply interchange the input and the output of the function. But then the axis labeled "x" is the vertical axis, which can be confusing, because we normally think of that as the "y" axis. So we complete the process of plotting the inverse by interchanging the axes, like this:

h(x) = sqrt(x-3)

### Injective, Surjective, etc.Edit

A function from set A (the domain) to set B (the range, or codomain) is...

injective, or one-to-one, if each element of B is mapped from at most one element of A. If f is injective, then f(x)=f(y) implies x=y.

surjective, or onto, if each element of B is mapped from at least one element of A.

bijective (both one-to-one and onto) if each element of B is mapped from exactly one element of A.

### Composition of functionsEdit

Suppose we define functions f and j as follows:

f(x) = x2+3 j(x) = x-2

Can you write the black box diagrams of f(2), f(3), and f(4)? I'll repeat them here:

2 —> [ f ] —> 7 3 —> [ f ] —> 12 4 —> [ f ] —> 19

Now, can you write the black box diagrams of j(7), j(12), and j(19)? Here they are:

7 —> [ j ] —> 5

12 —> [ j ] —> 10 19 —> [ j ] —> 17

Now what if these black boxes were put end-to-end so the output of f were fed directly into j? It would look like this:

2 —> [ f ] —> 7 —> [ j ] —> 5 3 —> [ f ] —> 12 —> [ j ] —> 10 4 —> [ f ] —> 19 —> [ j ] —> 17

Now what if we bolted f and j together so we couldn't see anything in between them? It would look like this:

2 —> [ f ] [ j ] —> 5 3 —> [ f ] [ j ] —> 10 4 —> [ f ] [ j ] —> 17

This is what we mean by the "composition" of j and f -- the output of f goes directly into j as if f and j were one function. We write it this way:

(j o f) is the composition of j and f. (j o f)(x) is the same as j(f(x))

### Simplifying a composition of functionsEdit

Here's another way to look at it: Remember that j(x) = x-2. This means j(3) = 3-2, and j(11) = 11-2. It also means that j(elephant) = elephant-2, and j(Empire State Building) = Empire State Building - 2. OK, I'm using extreme examples to make a point: no matter what you feed into j, you get a result that's smaller by 2. So f(x) is no exception. I'm treading lightly, because I know from experience this causes great consternation:

j(f(x)) = f(x)-2

Here we are feeding f(x) into j, and getting a result that is f(x) minus 2. It's no different from any of the other examples in that regard. Now, f(x) is defined as x2+3, so j(f(x)) = f(x)-2 = x2+3-2. This can be further simplified as x2+1.

Recall our definitions of f and j:

f(x) = x2+3 j(x) = x-2

Putting it all together,

j(f(x)) = f(x)-2, from the definition of j

= (x2+3)-2, from the definition of f = x2+1, by algebraic simplification

## Domain, Range, and MappingEdit

So far we've looked at functions in four ways -- by its formal definition, as a black box, as an algorithm, and as a graph. Yet another way to look at a function is as a mapping from one set to another. The set of possible input values is called the "domain" of the function. The set of possible output values is called the "range" of the function. The function maps each element of the domain to one element of the range.

Using set-builder notation {a : a has a certain property} means the set of all elements, a, such that a has a certain property,

The domain of the function, f, is domain(f) = {x : f(x) is defined}

The range of f, range(f) = {f(x) : f(x) is defined}

Functions can be defined by closed formula, by cases, recursion, or general axiom(s).

The notation f: A —> B means domain(f) = A and range(f) is a subset of B

Composition of functions, f o g, is defined whenever domain(f) is a subset of range(g), by the equation

(f o g)(x) = f(g(x))

#### Composition is associative but not commutativeEdit

Two functions, f and g, are inverses when

f(g(x)) = x for any x in domain(g), and g(f(y)) = y for any y in domain(f)

In these circumstances domain(f) = range(g) and domain(g) = range(f). A function has an inverse if and only if it is one to one.

The inverse function to f is written f~ or f-1.

The identity function on a set A, IA, is defined

IA : A —> A IA(x) = x

The following laws hold, at least where the left hand side of the equation is defined.

f~~ = f IA~ = IA f o IA = f IA o f = f (f o g)~ = g~ o f~ (f o g) o h = f o (g o h)

## Periodic FunctionsEdit

Functions that take on values that repeat themselves again and again at regular intervals are called "periodic" functions. An example of a periodic function is

a sin(b x)

Here, the period of the function (measured horizontally from crest to crest of the wave) is 2π/b, and the amplitude, measured vertically from the midline to the crest, is a.

Students sometimes have difficulty visualizing why the function containing bx (with x multiplied by b) results in a graph in which the labels of the x values are divided by b. The reason for this is that the argument (input) to the function is 2π when the x value is 2π/b. In other words, we have to divide the x value by b to counteract the fact that it's multiplied by b later on.

## Graphing the Cosine FunctionEdit

Cosine is a "sinusoidal" function, meaning it has the shape of a "sine wave". The general form of a sinusoidal function is:

f(t) = a cos(bt+c) + d, where

|a| is the amplitude of the function, a<0 to "flip" the function upside down, b is 2π/period c is the phase shift (in radians), i.e. how far to the left (right if c<0) the graph is shifted d is the vertical shift, i.e. how far up (down if d<0) the graph is shifted.

For a detailed explanation of this, see . . . . . . (this page needs to be updated to provide a step-by-step procedure for beginning students to graph the following: sin, cos, tan, csc, sec, cot)

Internet references Visual Calculus: Composition of Functions, Domain and Range

Translations of Sine and Cosine Curves explains: If the graphs of y = A Sin Bx and y = A Cos Bx are translated h units horizontally and k units vertically, then the resulting graphs have the equations: y-k=A Sin B(x-h) and y-k=A Cos B(x-h)

Graphing the sec, cot, and tan functions

Graphing the tangent, cotangent, secant, and cosecant functions

Mathworld: Domain and Range defines the concepts as they are ordinarily used, and then proceeds to catalog all the other less common definitions -- just read the first paragraph or so of each of these pages.

Mathworld: Periodic Function defines and illustrates periodic functions

Mathwords: Periodic Function, Period

The Math Page: Graphs of the Trig. Functions explains how to calculate the period of trig functions.

Wikipedia: Function (mathematics)

The following seem to be unavailable, which is a shame...

Graphing the Sine and Cosine Functions is an excellent demonstration of the effect of each of the constants in f(t) = a cos(bt+c) + d.