## What is a Function?

Published: Jul 20th, 2020

Learning Objectives
By the end of this lesson, you should be able to:
1. Define a function
2. Determine what is/isn't a function
3. Understand and be able to solve problems using function notation. In the last lesson, we discussed relations, and explained how a relation is a rule that associates elements in the domain with those in the range. A function is a unique type of relation. Like a relation, it assigns elements in the domain to those in the range. However, in order for a relation to be a function, it must assign each domain element to only ONE range element.

Now, in English. Consider the following example. A group of friends have gone trick-or-treating and have amassed a vast candy fortune. They each count the number of candies they have earned and compare, as shown to the right. If we consider each candy as equivalent, then we can also represent this relation using set notation as follows: $$\{(Orange\:Girl, 6\:candies),$$  $$(Red\:Boy, 5\:candies),$$ $$(Blue\:Girl, 6\:candies),$$ $$(Purple\:Boy, 3\:candies \}$$. This is a relation, as it maps each value in the domain (the person's name) to a value in the range (the number of candies they earned). However, it is not a function. This is because both Orange Girl and Blue Girl earned six candies, meaning that one value in the domain is being assigned to 2 different values in the range. This does not satisfy the definition of a function.

Now consider a different relation. A boy kicks a ball into the air. The graph plots its height on the y-axis versus the time on the x-axis. In this case, the diagram shows both a relation and a function. This is because for each time value, there is only one ball height.

We can graphically deduce if a relation is a function by the vertical line test, as shown in the animation. By definition, a function should, for any vertical line drawn, only intersect the line at one point. Otherwise, it's not a function; only a relation. Now that we understand what a function is not, we should move on to what a function is. That, is much more interesting!

An easy way to conceptualize a function is as a machine. For a given input, the function produces a single output (not necessarily a unique output, just the same output). For example, consider the animation to the right. For each input, the function produces only one output. This input is called the independent variable, and the output is called the dependent variable. We denote this machine-like relationship using function notation. Consider a function $$f$$ that doubles every real number input (for more on the different types of numbers, consult the next lesson!). We can denote this relationship by $$f(x) = 2x$$. For every input (denoted by x), the output, f(x), is double the input. We can alternatively represent this as $$y = 2x$$. Both forms are equivalent, and using one over the other (for this course) is just a matter of preference. However, one useful aspect of the function notation is its clarity. For example, say we wanted to double the number six. We can denote this by function notation as: $$f(6) = 2(6) = 12$$. As we can see, the "x" has been replaced by a six in each occurrence. Note: a function can be represented by any letter in the alphabet, not necessarily f.

Now that we understand how functions look and what is and isn't a function, how about some practice! Click the practice tab to the right to be redirected to a few questions to test your mettle. 