# What is a Function, Really?

A recent question, from Anindita, touched on the relationship of functions, relations, and rules. I referred to several answers we’ve given, which I’d long planned to put into a post (or two). This is it! We’ll start with a set of questions about what functions are.

## A function is a set of rules?

All About Functions

Hi Doc,

I would like a complete explanation of functions.

Doctor Matthew provided an explanation (though not nearly complete!):

Functions are one of the most important ideas in mathematics.

One of the simplest ways to think about functions is as a machine: you put something into the machine, and it spits something back out.  For example, when I used to go to the zoo, they had these cool machines that would make plastic gorillas while you watched. You'd put three quarters into the machine and two minutes later a hot plastic gorilla would fall out of the machine. This is like a function: the input to the function was three quarters, and the output of the function was a plastic gorilla.

Observe that this machine doesn’t change the coins into a gorilla; if you give it certain coins as input, it gives you a gorilla as output. That’s all that matters.

So in general, a function is a set of rules for taking input and producing output. Most of the time when you talk about functions in math the input and output are numbers. If I've got a function called Fred, and I input the number 5, Fred might output 10. If I input the number 3, Fred might output 6. It just so happens that Fred is the "take a number and double it" function. You could write this as Fred(x) = 2x, which says that whatever the value of x is, the value of "Fred of x" will be twice it.

As we’ll be seeing, it is not the “rules” that really matter, just that a given input results in a given output. We give the function a name (typically something like “f” or “sine” rather than “Fred”), and the notation $$f(x)$$ means that $$x$$ represents the input, and the expression tells how to make the corresponding output; for example, $$Fred(3) = 6$$.

You could also imagine functions that take more than one number as their input, like f(x,y) = x+y. That means that if you give the function numbers 8 and 5 as input, the function spits out the number 13 as output.

There's a lot more about functions out there, certainly lots more than we can tell you right now, but there's a lot more information in our archives.

That’s a high-altitude overview. Let’s get more specific.

## Functions can be expressions, or …

Here is a question from 2001:

What is a Function?

I can't exactly understand the meaning of function. I mean I've read many definitions and I've asked many teachers, but I still don't completely understand. Is there a better definition you can give me?

Thank you very much for your time.

Hi, Anjali,

There are many ways to define functions, depending on how precise we want to be, and how we are approaching the subject. But the basic idea is simple: a function is something that takes some sort of "input" (usually numbers in algebra, but it can be anything else), and for each possible input produces some "output." For example, any algebraic expression involving one or more variables can be seen as a function; for any set of values of the variables, the expression produces a single value. This expression is a function of a single variable x:

3x - 1

Keep in mind that an expression is just one way to define a function. The important thing is that this expression is a function, even if we haven’t yet called it that!

We can explicitly call this a function by naming it (I'll call it "L" just to be different) and defining the value of the function for any input. We do this by stating that its value for any value of the input is the value of our expression when x has that value:

L(x) = 3x - 1

This says that for any value of the variable x (the input), the value of the function (the output) is 3 times x, minus 1.

You don't have to use an expression like this to define a function; any description of how to get the output from the input will work. But this is the usual way you will see functions defined.

Alternative ways to define a function would be to make a table of values, like this:

or a graph, like this, which represents the same function:

Or we could just describe a physical or other process:

Let ABCD(t) be the value (in U.S. dollars) of a share of ABCD Inc. at noon on day t of the current year.

None of these involves an expression; the last produces an output that we can’t even know until it happens! But each provides a way to determine an output.

## Functions are a generalization of equations

For some important distinctions, consider this 2001 question from Maureen:

Are All Functions Equations?

I know that any equation that is written y = f(x) is considered a function, since when it is graphed it passes the vertical line test.

I also know that I can draw a horizontal wiggly curvy line that is also a function since it also passes the vertical line test. However, this second function cannot be defined by a single equation. I suppose it could be considered a multi-piece function, and around specific turning points it could be defined by an equation.

I also know that a table of (x,y) values can define a function as long as every x has only 1 y associated with it. However, if I pick quite random values for my x's and y's, once again I cannot define this table with an equation. Also, since my x's would not be continuous - assume all x's are integers - would I still have a function since the vertical line test might in fact not touch a point at all?

I have been searching for the definitive answer to this question for many years.

We commonly see functions defined by equations; but not always! What is a function, really?

After referring to a question we’ll be looking at next week, I answered:

First, we have to define clearly what we mean by "function" and "equation." A function is not an equation; rather, it is a relation. It need not be written as an equation at all, but can be any relation between two variables such that for every value of the independent variable within the domain of the function, there is one value for the dependent variable. An equation is merely one way to express a relation.

A relation is any association between values in two sets (perhaps the same set), which might be expressed by an equation like $$x=y^2$$ or $$x^4=x^2y-y^3$$, or by a description like “x is a sibling of y“. None of these represent functions; but relations like $$y=x^2$$ and “y is the father of x” do.

It sounds as if you are thinking of an equation as having to be expressed in a certain way - perhaps always having a polynomial or rational expression on each side. But if you think carefully, you will recognize that many special functions have been defined just because there was no other way to express them except in functional notation. For example, we have the trig functions sin(x) and so on; in your view, am I writing an equation if I say

y = sin(x) ?

I imagine so. This can't be expressed in terms of rational functions, but by allowing trig functions to be included in equations, we have written an equation. Now consider the absolute value:

y = |x|

This could just as well be written as a function:

y = abs(x)

But apart from these notations, we would have to define this equation piecewise:

y = x  for x >= 0
-x for x < 0

In other words, these examples are functions because they determine a single output; but they can only be written as equations by giving them a name! The function $$\sin(x)$$, for example, is defined as “the ratio of opposite side to hypotenuse in a right triangle with angle $$x$$,” not by an equation.

Does that make this any less an equation? By defining the absolute value function, we have stitched together two linear functions into a single expression so that it looks like a single equation. But if there is any other function you have in mind that can't be written as a single equation USING ESTABLISHED NOTATIONS AND FUNCTIONS, why can't we just define a new function notation for it and write it as an equation?

So I would say, on one hand, that there certainly are functions that can't be expressed as an equation of a FAMILIAR FORM, but there is nothing essentially different about such a function; it's just a question of what we consider familiar. Perhaps if you can define exactly what you mean by "equation," I could give a more specific answer.

In fact, there are many unfamiliar functions that have been named in order to solve equations that otherwise couldn’t be “solved”; an example is the Lambert W function, which was invented in order to solve equations like $$x=ye^y$$.

Now, if you start with a table listing a finite set of x-y pairs, then it is not hard to define a function - in fact, a polynomial function - that fits it. If some x values are missing from what appears to be the natural domain, we can just exclude those values when we define the domain. For any function to be defined, we must state (or imply) its domain, so this is no real restriction. A function on a discrete domain is perfectly legitimate. If you express it in terms of an equation, of course, the domain has to be expressed separately if it is not the natural domain, so in such a case the function can't be fully expressed by ONLY an equation.

For example, the table I showed above can be found to represent this function:

$$y=\frac{2x^{3}-15x^{2}+25x+18}{6},\;x\in\{1,2,3,4,5\}$$

Here is a graph of that equation, showing the dots from our table:

Perhaps ultimately the answer to your question is to recognize that the function concept is a generalization of the equation concept, allowing us to talk about "curvy lines" without being able to write a specific equation. Not all functions can be expressed in any familiar way as an equation, but all functions can be used to make equations.

I've probably missed some aspects of your question, so write back if you aren't fully satisfied.

Maureen replied:

Thanks for your response. You cleared up some of my confusion. I guess one of my sub-questions is, what if I have a table of values that appear to be random but that do in fact define a function - for instance the domain is all the social security numbers in the U.S., and the range is the weight of the person having that social security number?

If I knew what all the numbers were and they were defined in a very, very long table, could I make life easier for myself by determining an equation (polynomial, rational expression, trig, etc.) such that I could use this equation to determine the weight of the person having a particular social security number f(social security number) = weight rather than having to look up the weight in a table?

Interesting question! I responded:

In general, you could theoretically make a polynomial that matches the table, but it wouldn't help at all (unless it's not as random as it looks). For any n points, you can find a polynomial of degree no more than n-1 that passes through those points - so the expression you would get would probably be at least the same size as the table itself. A computer, in particular, would handle the table much better than the polynomial. And, of course, you would also have to find a way to check whether a given number was in fact a valid SSN, and I can't think of any nice way to do that without the table.

The rest of the discussion was about how to find a polynomial given a table, which we’ll deal with some other time.

## A function is like an expression, but …

A 2004 question offers a similar perspective:

How Are Functions and Expressions Related?

What is the relationship between a function and an expression?  I don't see any relationship, they are two completely different things.

Hi, Kristy.

Actually, I would say that they are almost exactly the same thing!  But that may not be obvious.

An expression is essentially the directions for a calculation, telling you to take this variable and that variable and do certain multiplications, additions, and so on.  Right?  Here's an example:

3x - 4

Here is another:

2x - y
-------
3x + 2y

So an expression is one way to state a “rule” for turning one or more variables into a new value.

A function is a "machine" that takes one or more variables and does certain things to them to get a number out, which is the value of the function.  Here is an example with one variable:

f(x) = 3x - 4

Here is one with two variables:

2x - y
f(x,y) = -------
3x + 2y

Look familiar?  I can use any expression as the definition of a function, since the expression tells what to do with the variable(s) to get a value.

On the other hand, not every function can be written as an expression using common operations.

All these ideas are closely related:

The terminology all flows together sometimes.  If you were given the equation

2x + 3y = 5

and I wanted you to "solve for y", I might instead tell you to "write an expression for y in terms of x" or to "write y as a function of x".  These all mean the same thing, but focus on different aspects of what you are doing.  "Solving" focuses on the equation as a problem, and the particular variable we want to find; "in terms of" focuses on which variable(s) are to be used in the calculation, rather than which is to be found; and "as a function" focuses on both.  The latter is probably preferred by mathematicians for that reason, as well as for brevity.  And brevity (the ability to talk about a big concept in a single word) is the main reason for defining "functions":

Why Do We Have Functions?
http://mathforum.org/library/drmath/view/62559.html

We’ll see this next week.

## A function is a mere relationship

I’ll close with a 2014 question about an important distinction:

Functions: The Very Idea

In many calculus books, functions are defined thus:

A function is a rule which assigns, to each of
certain real numbers, some other real numbers.

For example, f(x) = x^2 is a function which assigns to each number x its square, x^2.

Is x^2 here a function? More clearly, is a function a rule or a set of instructions (such as "x^2") for calculating the output of that function?

In a book I read that if we say that a function is a rule, and if by a rule we mean the actual instructions for determining the output f(x), then f(x) = x^2 and f(x) = x^2 + 3x + 3 - 3(x + 1) are different rules, however trivially. But we want them to define the same squaring function; therefore, this definition fails in this respect. It seems to me that here x^2 and x^2 + 3x + 3 - 3(x + 1) are the rules of the functions.

What confuses me is that if a function is the algebraic formula that defines it, then is a function not the dependent variable? For example, given f(x) = x^2 = y, here the formula is equal to the output.

Is a function a specific expression? Is it a rule, or an output, or something deeper?

Hi, Samama.

A function is an abstract concept, which can be represented in many different ways. It is the mere relationship -- not an expression or formula, not a table, not a graph, not even a "rule," really, if by that you mean some specific written or spoken instructions -- but the underlying idea that all of those can express.


That is, there can be many different ways to say the same thing, and a function is not any one of those ways to say it, but the underlying relationship that they all describe.

Mathematicians needed some time to come up with a way to express this, which they did by expanding the concept to that of a relation, which we mentioned above:

Formally, a function is defined as a relation in which any element of the domain is associated with only one element of the range (or codomain); and a relation is defined as any set of ordered pairs of elements from the two sets. That's really all it is.

This is part of the modern approach of defining all of mathematics in terms of sets. A relation is any association of members of one set to members of another set; we make that association “real” in the form of a set of pairs.

A formula can give you a way to associate values of x with values of y; so can a written rule, or whatever you like.

Two functions are the same if they have the same domain, and associate each element of the domain with the same element of the range. So if a function is expressed in terms of two formulas that look different, that is no problem as long as they are equivalent formulas that always give the same value.

Samama’s two expressions always have the same value, so even though they are written differently, they represent the same function.

Similarly, a function is not its dependent variable; it is the "rule" (in the most abstract sense) that determines the values of that variable. The variables are not even part of the function; you decide what variables to use when you apply the function. In this way, the functions represented below are actually the same:

f(x) = x^2                   f(t) = t^2
or           AND             or
y = x^2                      s = t^2

They are equivalent because both make the same relationship, even though they have been associated with different variables.

We can change all the symbols in an expression (or remove them entirely), and the function remains!

### 1 thought on “What is a Function, Really?”

This site uses Akismet to reduce spam. Learn how your comment data is processed.