Maths
What is a function in maths?
Quick answer
A function is a rule that gives exactly one output for each input. In f(x) = 2x + 3, the input 4 gives the output 2 × 4 + 3 = 11.
In one sentence
A function is a rule that turns each input into exactly one output, like a machine that always gives the same answer for the same number.
Explained
Think of a function machine. You drop a number in, the machine follows its rule, and one number comes out. If the rule is "double it, then add 3", putting in 4 gives 11 and putting in 10 gives 23. Put 4 in again tomorrow and you get 11 again. That reliability is what makes it a function.
box
robot
pencil
Mathematicians write the rule with function notation: f(x) = 2x + 3. Read it as "f of x equals 2x plus 3". The letter f is the name of the function, x is the input, and f(x) is the output. So f(4) = 2 × 4 + 3 = 11. It does not mean f times x. Functions can have other names too, like g(x) or h(t).
The key rule: every input has exactly one output. Two different inputs may share an output (f(x) = x² gives 9 for both 3 and −3), but one input can never give two outputs. A vending machine is a good picture: each button gives one snack. If pressing B4 sometimes gave crisps and sometimes chocolate, it would be broken, and so would the "function".
You can show a function in four ways:
- Rule (formula): f(x) = 2x + 3
- Table of values: inputs in one row, outputs in another
- Set of pairs: (0, 3), (1, 5), (2, 7)
- Graph: plot each pair as a point using coordinates, with the input on the x-axis and the output on the y-axis
On a graph, use the vertical line test: if any vertical line crosses the graph more than once, it is not a function. A circle fails the test; a straight line that is not vertical passes.
Two more words come up a lot. The domain is the set of inputs you are allowed to use. The range is the set of outputs you actually get. For f(x) = 1 ÷ x the domain is every number except 0 (you cannot divide by 0). For f(x) = x² the range is y ≥ 0, because a square is never negative.
The first family you meet is linear functions, f(x) = mx + c, whose graphs are straight lines. The number m is the slope and c is where the line crosses the y-axis. Later come quadratic (x²), cubic (x³), exponential (2ˣ) and trigonometric (sin x) functions. Number sequences are functions too: the nth-term rule turns the position n into a term.
Examples
| Function | Input | Working | Output |
|---|---|---|---|
| f(x) = 2x + 3 | x = 4 | 2 × 4 + 3 | 11 |
| f(x) = 2x + 3 | x = −2 | 2 × (−2) + 3 | −1 |
| g(x) = x² − 1 | x = 3 | 9 − 1 | 8 |
| g(x) = x² − 1 | x = −3 | 9 − 1 | 8 |
| h(t) = 100 − 5t | t = 6 | 100 − 30 | 70 |
Worked example: a gym charges a $20 joining fee plus $15 a month. The cost after m months is C(m) = 15m + 20. After 6 months, C(6) = 15 × 6 + 20 = $110. To find when the total reaches $200, solve 15m + 20 = 200: 15m = 180, so m = 12 months.
Common mistakes
- Reading f(x) as f × x. Fix: f(x) means "the output of f when the input is x". Swap x for the number and work out the rule.
- Forgetting brackets with negative inputs. For g(x) = x², g(−3) = (−3)² = 9, not −9. Always write the bracket.
- Thinking two inputs with the same output break the rule. Fix: many-to-one is fine. Only one-to-many (one input, two outputs) stops it being a function.
- Mixing up domain and range. Fix: domain = what goes in (x), range = what comes out (y).
Step by step
Step by step
- Read the ruleFind what the function does to x, for example "times 3, then subtract 1" in f(x) = 3x − 1.
- SubstituteReplace every x with the input, in brackets: f(−2) = 3(−2) − 1.
- Work it outFollow the order of operations: 3(−2) − 1 = −6 − 1 = −7.
- Write the answer as a pairF(−2) = −7, so the point (−2, −7) is on the graph.
- Going backwardsIf you know the output, set the rule equal to it and solve: 3x − 1 = 11 gives x = 4.
To check whether a relation is a function, look at the inputs: if any input appears twice with different outputs, it is not a function.
Practice questions
Work with functions
Try each one, then check your answer.
- f(x) = 3x + 2. Find f(4).
Show answer
3 × 4 + 2 = 14 - f(x) = 3x + 2. Find f(−1).
Show answer
3 × (−1) + 2 = −1 - g(x) = x² − 5. Find g(3).
Show answer
9 − 5 = 4 - g(x) = x² − 5. Find g(−3).
Show answer
(−3)² − 5 = 9 − 5 = 4 - h(x) = 10 − 2x. Find h(0) and h(5).
Show answer
h(0) = 10, h(5) = 10 − 10 = 0 - f(x) = 4x − 1. Find x when f(x) = 19.
Show answer
4x − 1 = 19, 4x = 20, x = 5 - Is {(1, 2), (2, 4), (3, 6), (4, 8)} a function?
Show answer
Each input has one output, so yes. - Is {(1, 2), (1, 5), (2, 3)} a function?
Show answer
The input 1 has two outputs, so no. - A function machine multiplies by 5 and then subtracts 3. Write it as f(x).
Show answer
f(x) = 5x − 3 - Complete the table for f(x) = 2x − 1 when x = −1, 0, 1, 2.
Show answer
−3, −1, 1, 3 - What are the slope and the y-intercept of f(x) = −2x + 7?
Show answer
Slope −2, y-intercept 7 (the point (0, 7)) - Find the linear function with f(0) = 3 and f(2) = 11.
Show answer
Slope = (11 − 3) ÷ 2 = 4, and f(0) = 3, so f(x) = 4x + 3 - Which input is not allowed in f(x) = 1 ÷ (x − 2)?
Show answer
x − 2 cannot be 0, so x = 2 is not in the domain. - What is the range of f(x) = x²?
Show answer
A square is never negative: y ≥ 0 - f(x) = 2x + 1 and g(x) = x². Find f(g(3)).
Show answer
g(3) = 9, then f(9) = 2 × 9 + 1 = 19 - Find the inverse of f(x) = 3x − 6.
Show answer
y = 3x − 6, so x = (y + 6) ÷ 3: f⁻¹(x) = (x + 6) ÷ 3. Check: f(4) = 6 and f⁻¹(6) = 4.
Word problems
Functions in real life
Try each one, then check your answer.
- A taxi charges $3 plus $2 per mile: C(m) = 2m + 3. How much is an 8-mile ride?
Show answer
C(8) = 2 × 8 + 3 = $19 - The same taxi ride cost $25. How many miles was it?
Show answer
2m + 3 = 25, 2m = 22, m = 11 miles - The rule F = 1.8C + 32 changes degrees Celsius into Fahrenheit. What is 25 °C in °F?
Show answer
1.8 × 25 + 32 = 45 + 32 = 77 °F - A 30 cm candle burns 2 cm every hour: h(t) = 30 − 2t. How tall is it after 4 hours, and when does it burn out?
Show answer
h(4) = 30 − 8 = 22 cm; 30 − 2t = 0 gives t = 15 hours - A class trip costs $120 for the bus plus $8 per student: C(n) = 8n + 120. If 30 students go and share the cost equally, how much does each pay?
Show answer
C(30) = 240 + 120 = 360, and 360 ÷ 30 = $12 each - Is "student → date of birth" a function? Is "date of birth → student"?
Show answer
Yes: each student has one date of birth. No the other way: two students can share a birthday.
Questions people ask
What is a function in maths, in simple words?
It is a rule that takes an input and gives back exactly one output. "Add 5" is a function: 2 becomes 7, 10 becomes 15, and the same input always gives the same output.
What does f(x) mean?
f(x) is the output of the function f when the input is x. If f(x) = x + 5, then f(2) = 7. The brackets show the input; they do not mean multiply.
How do you know if something is a function?
In a table or list of pairs, check that no input appears with two different outputs. On a graph, use the vertical line test: no vertical line may cross the graph more than once.
What are domain and range?
The domain is all the inputs a function can take; the range is all the outputs it produces. For f(x) = √x (using real numbers), the domain is x ≥ 0 and the range is y ≥ 0.
What is the difference between a function and an equation?
An equation says two things are equal, like 2x + 3 = 11, and often has one answer (x = 4). A function is a rule linking every input to an output, like f(x) = 2x + 3. Writing y = 2x + 3 is an equation that describes a function.
What are the main types of functions?
Linear (f(x) = 2x + 1, a straight line), quadratic (f(x) = x², a U-shaped parabola), cubic (x³), exponential (2ˣ, which grows faster and faster) and trigonometric (sin x, cos x, which repeat in waves).
What is an inverse function?
It undoes the original function. If f(x) = 3x − 6 takes 4 to 6, the inverse f⁻¹(x) = (x + 6) ÷ 3 takes 6 back to 4.
Quick quiz
Functions (maths)
Check what you know with 5 quick questions.
Question 1 of 5
If f(x) = 2x − 3, what is f(5)?
Practise it
Try it
Practise functions with unlimited questions
Algebra worksheets
Practise it step by step in a full course: Grade 9 Maths
For grown-ups
Related topics
Slope (gradient)
Slope (called gradient in the UK) measures how steep a line is. It is the rise divided by the run, m = (y₂ − y₁) ÷ (x₂ − x₁), and it can be positive, negative, zero or undefined.
Coordinates
Coordinates are a pair of numbers that give an exact position on a grid, like (3, 5). The first number is how far across (x) and the second is how far up (y).
Sequences
A sequence is a list of numbers or shapes that follows a rule, like 3, 7, 11, 15 (add 4 each time). Each item is called a term.
Algebra
Algebra is maths that uses letters, like x or n, to stand for numbers we don't know yet or numbers that can change. For example, if n + 3 = 10, then n = 7.
Completing the square
Completing the square rewrites x² + bx + c as (x + b/2)² − (b/2)² + c. It solves quadratics, finds the vertex (turning point) of a parabola and proves the quadratic formula.
Composite functions
A composite function applies one function and then another. f(g(x)), also written (f ∘ g)(x) or fg(x), means do g first, then put the answer into f.