✖

What is a function

Functions are absolutely fundamental in maths, and you should understand them properly. Maths is woven through with functions, and many of the symbols you have known since primary school are really functions in disguise.

The function analogy

Have you ever seen a coffee machine? What is typical of one? You put some coins in and the machine gives you a coffee. If you feed in more coins, you get a better coffee.

A function is a sort of mathematical coffee machine. You put an input into the function (the coins) and the function returns an output (the coffee). That is the whole basic idea of a function.

A function’s job is to take an input, some number, do something to that number inside, change it and then return the new number as the output.

Basic terms

Every function has a name that identifies it. The most common name for a function is the letter “f”. A function also needs a rule that says how it should work – how the machine should brew the coffee. To begin with, we can picture a function as a table with two columns. The first column holds our input (in the machine, the value of the coins) and the second holds the output of the function (the coffee).

inputoutput12243648510

We can see that the output is always twice the input, but that does not have to be the case. We could also have a table like this:

inputoutput02212274−3142−45884

For now, though, the first, regular table is enough for us. We can say that this table defines a function f. What does the function do? We put an input into the function, the function looks it up in the first column of the table and returns the output on the same row. If we want the output of the function for the number three, we write it like this:

f(3)=6

We found the row where the input is three, and on the same row the output was six. Similarly, f(1) = 2, f(2) = 4, f(4) = 8 and f(5) = 10. Writing functions as tables may look clear enough for a few numbers, but once we work with more numbers it is hopelessly impractical. So we need another way of writing a function down. We can define it with a rule. In our table the output was twice the input. We can write that as a rule like this:

f(x)=2⋅x

This is a simple linear function, but that does not matter yet. What does this expression tell us? The letter f is the name of the function, as we already know. The expression in brackets, the letter x, is the parameter of the function. In the machine analogy, it would stand for “the value of the coins we put in”. The parameter of a function is a variable that stores the value we pass in. If we put two pounds into the machine (the function), then inside the function x = 2. From there on, the machine, or the function, works with this value in its own way.

Next comes the equals sign, and after it is the rule itself, which says what to do with the value x. We can see that the function multiplies the value x it is given by two. That is all.

More examples of functions

On the right-hand side there can be practically any mathematical expression. There can be other functions in it, and there can be conditions that make the definition more precise. We could define a function in words, for example like this: “if the input is an even number, return zero; if the input is an odd number, return one”. That is a function that only ever returns ones and zeros, but it is still a function.

It is important to understand that a function can be defined in almost any way. A function has its rules too, of course, but they are not so important right now – and one of them is mentioned in the very next section. The definition of a function does not have to make sense at first glance and does not have to follow any pattern. A function can quite happily return double the input every time except when the input is seven, in which case it returns nine. That is probably complete nonsense, but it is a function too.

Many of the things we do outside maths can be called functions too. For example, if you work out the length of the word “mammoth”, we can say that you called a function named “word length” and passed it the word “mammoth” as an argument. The function counted the letters in the word and returned the number seven.

Do you need to work out how much compound interest you will pay on a loan or a mortgage? A function can do that too. You simply define a function that calculates the amount of interest after, say, ten years. Do you need to find out how many more kilometres a car can travel on a given number of litres of petrol? Define a function! If the car travels 11 kilometres on average on a litre of petrol, then a function that works out how much further we can go can be defined like this:

distance(x)=11⋅x

If we have only 17 litres of petrol left, we work out the distance by calling the function like this:

distance(17)=11⋅17=187

A function is simply anything that returns a number for a given input. Return the distance as the crow flies from London to a given city, return the length of the longest track on a given album, return the number of hairs on a given person’s head, return the number of legs of a given animal, and so on.

The basic property of a function

An enormously important condition for a function, if we go back to the table, is that no value in the first column, the input, may appear twice. If the table looked like this:

inputoutput12141648510

… then we would not be able to say what the function should return if we put in one:

f(1)=?

A function must be well defined: it cannot happen that the same input could give two different results. That simply is not allowed. We require a function to always return the same output for the same input. Watch out: this requirement does not apply to the second column, the output. The outputs may well be the same, and that does not bother us. This table would be valid:

inputoutput12223242510

Evaluating a function

We now know what each part of a function is called and roughly how to define a function. Next we will explain step by step how a function is evaluated. So we have the function f(x) = 2x. What happens when we put three into the function? Putting three into the function means substituting the number three for the parameter of the function. The argument of the function is three, so we substitute three for every x:

f(3)=2⋅3

We can already see that the function returns six, just as the table did a moment ago. The table was limited to five numbers, though, while our new definition can handle other numbers too:

f(10)=2⋅10=20f(54)=2⋅54=108f(−7)=−14

This process of substituting specific values for the variable x is called evaluating the function, calling the function or applying the function. So if we say that we “call the function f with the argument 5”, we want to work out the value f(5), which in our case is f(5) = 2 · 5 = 10.

Here are two more terms to remember. What we call the function with (what we substitute for x) is called the argument of the function. It may seem a little confusing, but if we have a function f(x) and call it with the value three, f(3), then x is the parameter of the function and 3 is the argument of the function. The argument is the actual value we call the function with. The parameter is the original variable the function was defined with. It is more of a technical detail.

Another term is the value of the function (or output), which is the value the function returns. The previous function returned the number six when called with the number three, so six is the value of the function in this case. In a full sentence we would say “the function f has the value six at the point three”. By “point” we usually mean the argument of the function in this context.

Functions in everyday maths

Everyday maths is full of functions that have a very special way of being written, so it does not even look as if they are functions. For example, the absolute value is nothing other than a function. It takes a number as its input and returns either the same number or the number with the opposite sign.

You surely recognise the symbol for the square root: . This is a function too. It takes an argument as its input and returns the square root. Similarly, the square x2 is a function. It takes a number as its input and returns the square of that number.

It is quite important to realise that most of these magic symbols are really nothing more complicated than some ordinary function. Do not look at the symbol as some strange bent shape; look at it as a function.

An expression that contains a heap of mathematical symbols can be confusing, especially for a beginner who has no idea what half of them mean, when it is simply a handful of composite functions. Let’s take this example to help us:

|x2|!

A layperson who looks at this scratches their head and has little idea what to do with it. Yet the expression contains four fairly simple functions, applied one after another to the variable x. It could be written out using named, nested functions like this:

factorial(root(abs(square(x))))

It is a longer way of writing it, but probably clearer for someone who does not know the symbols. It also makes the order in which the functions are called perfectly clear.

Summary of function notation

A function has a name, which can be pretty much anything. A general function is most often called f. Every function has a certain number of parameters, which we write in brackets after the name. If our function f had two parameters, we would write it like this: f(x, y) or f(a, b). The names of the parameters do not generally matter.

Some commonly used functions have their own symbol; for example, the square root has the symbol . Also, sin or sin(x) is the sine function, |x| is the absolute value function and x! is the factorial function.

If a function has one parameter, we sometimes leave out the brackets, which can make the notation clearer and sometimes does not. So sin(x) and sin x are both valid ways of writing the sine function.

When we talk about the parameter of a function, we mean the letter x in the notation f(x). The argument is then the value we call the function with, the value we substitute for x. These two terms are often used interchangeably. The value of the function is the value we get after calling it. We write it simply as the name of the function, brackets and the argument. If we have the function f(x) = 2x and substitute the argument x = 4 for the parameter x, we say that we called the function with the argument x = 4 and the resulting value f(4) is equal to eight.

Chapters: What is a function, Functions of several arguments, Composition of functions, The graph of a function