- Using formulae — substituting values · coming soon
- The nth term of an arithmetic sequence · coming soon
- Sketching quadratic graphs
- Composite functions
- Inverse functions
- Domain and range · coming soon
Two machines, and one of them cannot be trusted
Here are two machines. Each one takes in a number and sends a number out.
Machine A squares whatever you put in. Put in 3, and out comes 9. Put in −3, and out comes 9 again.
Machine B is the reverse. You put in a number, and it gives you back a number whose square is your number. Put in 9. What comes out?
Both 3 and −3 have a square of 9. So machine B has two correct answers and no rule for choosing between them. On Monday it might say 3. On Tuesday it might say −3. You cannot predict it, so you cannot build anything on it.
Machine A has the opposite property. It gives the same answer to 3 and to −3, and that is not a problem at all. Every time you put in 3, you get 9. You always know what will come out.
This is the whole difference between a rule that mathematics can use and a rule that it cannot. Machine A is a function. Machine B is not. By the end of this lecture you will see exactly why. You will also be able to spot the difference in a formula, a table, a diagram or a graph.
One input, exactly one output
A function is a rule that takes each allowed input and gives exactly one output. The two words "exactly one" carry the whole definition. They forbid two things.
- No input may have two outputs. That is what went wrong with machine B.
- No allowed input may have no output. If the rule has nothing to say about an input, that input is simply not allowed. We come back to this below.
Now notice what the definition does not forbid. Two different inputs may share the same output. Machine A sends 3 and −3 to the same place, 9, and it is still a function. Many students believe that a function must give a different output for every input. It does not. The rule is about each input looking forward: one input, one output. It says nothing about outputs looking back.
A mapping diagram shows this clearly. The inputs sit in one oval and the outputs in another. An arrow joins each input to its output.
So the test on a mapping diagram is simple. Look at the inputs, not the outputs. Count the arrows leaving each input. If every input has exactly one, the rule is a function. Arrows arriving together at one output do no harm.
Your calculator has a √ key. Press √ and then 9, and it shows 3, never −3. Is the √ key a function? And how can that be, when machine B was not?
Show the answer
Yes, the √ key is a function. Mathematicians made a decision: the symbol means the positive square root only, so . That decision removes the choice that broke machine B. Now every allowed input has exactly one output. This is why you write when you solve : the ± puts back the second answer that the √ symbol, on purpose, leaves out.
A function is a rule that assigns to each allowed input exactly one output.
Different inputs may give the same output. One input may never give two outputs.
A function can be given in many forms: a formula, a table, a mapping diagram, a graph, or a rule in words. The form does not matter. The test is always the same. Sort the cards below, and look at the reason on each one.
Put each card in a box. For every card, ask one question: can one input ever have two outputs?
Nine rules, each tested by asking whether one input can ever have two outputs.
| Rule | Function? | Reason |
|---|---|---|
| x → x² | Yes | Each number has one square. 3 and −3 share the output 9, which is allowed. |
| x → a number whose square is x | No | The input 9 has two outputs, 3 and −3. |
| y = 2x + 1 | Yes | Each x gives one value of 2x + 1. |
| x² + y² = 25 | No | x = 3 gives y = 4 and y = −4. |
| Each student → their date of birth | Yes | Each person has one date of birth. Two students may share one. |
| Each date → a student born on that date | No | One date can belong to several students. |
| x: 1, 2, 3, 4 → y: 5, 5, 5, 5 | Yes | Every input has one output. All the outputs are equal, which is allowed. |
| x: 1, 2, 2, 3 → y: 4, 6, 7, 8 | No | The input 2 has two outputs, 6 and 7. |
| Each whole number → its last digit | Yes | A whole number has one last digit. 17 and 237 share the output 7. |
Every "not a function" card has an input with a choice of outputs. Every "function" card, even the one where all the outputs are 5, gives each input one fixed answer.
Giving a function a name: f(x)
Once we have a reliable machine, it is useful to give it a name. The most common name is . We then write
and read it as "f of x equals 2x plus 1". Each part has one job.
- is the name of the function, the name of the machine.
- inside the brackets is the input.
- as a whole is the output: what comes out when goes in.
- is the rule: double the input, then add 1.
To use the function, put a number in place of . Then means "the output when the input is 3":
In the same way, . So is a complete sentence. It says: "the machine turns 3 into 7".
This is the hard part of the notation, so spend time here. The brackets in do not mean multiplication. In , the brackets do mean "times", because 3 is a number. But is not a number. It is the name of a rule. So is not "f times 3". It is "f applied to 3". The same brackets do two different jobs, and the letter in front tells you which job it is.
The letter is only a name. Other functions are often called and . In science, the name often reminds you what the function measures: a height that depends on time might be .
Anything can go into the machine
The input does not have to be a number. It can be a letter or a whole expression. The rule stays the same: replace every with the input, in brackets. With :
The brackets around the input are the safest habit in this whole topic. They matter most when the input is negative, as the first worked example shows.
Allowed inputs and possible outputs
Two more words come with every function.
- The domain is the set of all allowed inputs.
- The range is the set of all outputs that can actually come out.
For , you can put in any number at all, so the domain is all real numbers. Every number can also come out, so the range is all real numbers too.
Squaring is different. Any number can go in, but a square is never negative. So the range of is all numbers greater than or equal to 0, written .
Sometimes the domain is limited too. You cannot divide by zero, so the rule "one over x" has no output for the input 0. That input is left out of the domain. A whole lecture later in this topic is about choosing and finding domains and ranges. For now, hold on to the two words and what each one describes.
Seeing a function on a graph
You have been drawing functions for some time already. When you plotted , you took each input , worked out its one output , and plotted the point . So the graph of a function is the picture of all its input–output pairs, and we often write .
On a graph, an input is a position along the -axis. All the points with the same input lie on one vertical line. That gives a test you can use just by looking.
A graph shows a function of if no vertical line meets it more than once.
If even one vertical line meets the graph twice, one input has two outputs, so the graph is not a function.
Do not learn the test as a trick. Learn the reason. A vertical line is the set of points with one fixed input. Meeting the graph twice means that this one input is paired with two outputs. That is machine B again, drawn as a picture.
Be careful with the wording. The test needs every vertical line, not one. For the sideways parabola, the line meets the graph only once, at the origin. That does not rescue it, because the line meets it twice. A line that meets the graph zero times is not a problem either. It only means that input is not in the domain. Slide a vertical line across four graphs and see for yourself.
Choose a graph. Then slide the dashed line from left to right across the whole picture. Watch how many points it meets and what the outputs are. The verdict appears once you have seen enough.
Graph:
The vertical line test on four graphs: the number of points a vertical line meets at several inputs.
| Graph | x = −4 | x = 0 | x = 2 | x = 4 | Function? |
|---|---|---|---|---|---|
| y = ½x + 1 | 1 | 1 | 1 | 1 | Yes |
| y = x² − 3 | 1 | 1 | 1 | 1 | Yes |
| x = y² | 0 | 1 | 2 | 2 | No |
| x² + y² = 9 | 0 | 2 | 2 | 0 | No |
For x = y², the input 2 gives y ≈ 1.41 and y ≈ −1.41. For the circle, the input 0 gives y = 3 and y = −3. One input with two outputs is enough to fail.
What should you have seen? The straight line and the upright parabola never gave more than one point. The sideways parabola and the circle each gave two points for many inputs, so they fail. Notice also that the circle and the sideways parabola have inputs with no points. Those inputs are outside the domain, and that alone would not make them fail.
Worked examples
For , find and .
Replace every with the input, in brackets. .
. The brackets matter here. means . Without brackets, means "the negative of ", which is −4, and it would give the wrong answer −7.
Check: the graph of passes through , and by symmetry also through . Indeed . Two inputs, one shared output, as for machine A.
For , find and . Then find the input that gives the output 13.
. For , the whole of goes in, in brackets: .
The last part asks the question the other way round. We know the output and want the input. So solve : , so and .
Check: . Also, should be the output of the next input. With : , and . They agree.
A taxi charges $2.50 to start, plus $1.20 for each kilometre. The cost for a journey of kilometres is . Find . Then find the distance of a journey that cost $8.50. What is a sensible domain?
, so a 10 km journey costs $14.50.
For the cost $8.50, solve . Then , so . The journey was 5 km.
A distance cannot be negative, so a sensible domain is . The formula would happily accept , but the situation would not. This is why a function is more than its formula. It is a formula together with its allowed inputs.
Check: . ✓ Notice the name and the input : they remind you what the function measures.
Is a function of ? If not, can part of it be?
Try one input. With : , so and or . One input has two outputs, so the circle is not a function. On the graph, the vertical line meets the circle at and .
Now keep only the top half. That is , because the √ symbol gives only the positive root. Each input from −5 to 5 now has exactly one output. So the top half is a function, with domain .
Check: , the top point only. ✓ The same idea as the calculator's √ key: make a choice, and the second output disappears.
Three classic mistakes
is the output of the function when the input is 3. It is not . You cannot "cancel" the or divide by it, because is the name of a rule, not a number.
For , the input −2 must go in as , which is 4. Writing gives −4, because the square is done first and the minus sign after. Always put the input in brackets, whatever it is.
For , the input gives . But . They are different. The first changes the input. The second changes the output. Check with : , while .
Work each one on paper first. Open a hint only when you are stuck.
-
For , find , and .
Hint 1
Replace with each input, in brackets.
Hint 2
. What is ?
Full answer
. . . Check: is a straight line with gradient −3, so each step of 1 to the right lowers the output by 3. From to the output falls by 6, from 5 to −1. ✓
-
For , find . Then find every input that gives the output 0.
Hint 1
.
Hint 2
For the second part, solve by factorising: .
Full answer
. For output 0: , so or . Check: and . ✓ Two inputs give the same output, and is still a function.
-
For , show that . Find two more inputs that share an output. Explain why is still a function.
Hint 1
Work out and . The graph of is a parabola. Where is its line of symmetry?
Hint 2
The roots are and , so the line of symmetry is . Inputs the same distance either side of 2 share an output.
Full answer
and . Other pairs: , or . The function is still a function because each input has exactly one output. Sharing an output is allowed. Only one input with two outputs would break the rule.
-
A car park charges $2 for up to 1 hour, then $1.50 for each extra hour or part of an hour. Is the cost a function of the time parked? Is the time parked a function of the cost? Find the cost for 2.5 hours.
Hint 1
For each time, is there one cost? For each cost, is there one time?
Hint 2
2.5 hours is 1 hour plus 1.5 extra hours. "Part of an hour" counts as a whole hour, so that is 2 extra hours.
Full answer
Cost for 2.5 hours: , so $5.
The cost is a function of time. Any time you are parked gives exactly one charge. Many different times give the same charge: 2.5 hours and 3 hours both cost $5. That is allowed.
The time is not a function of the cost. If you know only that someone paid $5, they could have parked for 2.1 hours, 2.5 hours or 3 hours. One input (the cost) has many possible outputs (times). Check: 3.2 hours costs , not $5, because 3.2 hours needs a third extra hour. ✓
A function is the mathematical word for dependence. Writing says that depends on in one fixed, predictable way. Change , and you know exactly what becomes. You have met this idea in many places already. The th term of a sequence is a function of . The distance a car travels is a function of time. In Economics, the quantity demanded is a function of the price. Each of these is a reliable machine.
The idea took time to arrive. The word "function" goes back to Leibniz in the late 1600s. The notation was first used by Leonhard Euler in 1734. For Euler, a function was a formula. Later mathematicians, in the 1800s, saw that the formula was not the important part. What mattered was the rule "each input has exactly one output", however that rule is given: by a formula, a table, a graph, or words. That is the definition you have used today.
The rest of this topic grows from it. Because each input has one output, you can feed the output of one function into another. And sometimes you can run a function backwards, from output to input, as Worked Example 2 did once.
- A function is a rule that gives each allowed input exactly one output.
- Different inputs may share an output, but one input may never have two outputs.
- In f(x), f is the name of the function, x is the input and f(x) is the output, and the brackets do not mean multiplication.
- To evaluate a function, replace every x with the input in brackets, which protects negative numbers and whole expressions.
- The domain is the set of allowed inputs and the range is the set of possible outputs.
- A graph is a function of x if no vertical line meets it more than once, because a vertical line holds one fixed input.