Function machines
Function machines are a fun way to understand how inputs are turned into outputs using mathematical rules — just like a vending machine gives you something different depending on the button you press! They're used in computer programming, science formulas, and everyday problem solving to model how one thing affects another. Jump to the questions
Practise now
Solve the function machine below. Some ask you to find the output and others the input. Integers only. Good luck!
Topic guide
What this worksheet practises
This worksheet provides practice on using function machines. A function machine is a visual way of representing a sequence of mathematical operations. It is the crucial first step towards understanding formal algebra, substitution, and solving equations.
Key method
You can use a function machine in two directions: forwards or backwards.
- Forwards (Finding the Output): Start with the given input number. Apply the first operation in the first box. Take that new result and apply the second operation in the next box. The final result is your output.
- Backwards (Finding the Input): Start with the given output number. Move backwards through the machine from right to left. Crucially, you must perform the inverse (opposite) operation of whatever is written in the box.
Worked example
A machine has two steps: "multiply by 4" then "subtract 5".
1) Find the output if the input is 7.
2) Find the input if the output is 27.
Step 1 (Forwards): Start with 7.
Multiply by 4: 7 × 4 = 28.
Subtract 5: 28 − 5 = 23. (The output is 23).
Step 2 (Backwards): Start with the output, 27. Move right to left.
The last step was "subtract 5". The opposite is "add 5".
27 + 5 = 32.
Step 3: Move to the first box. It was "multiply by 4". The opposite is "divide by 4".
32 ÷ 4 = 8. (The original input was 8).
Common mistakes to avoid
When working backwards, the most common mistake is reversing the order of the boxes but forgetting to change the mathematical signs (e.g. subtracting 5 and then multiplying by 4). When you move backwards through a machine, everything reverses: the order reverses, and every single operation must become its opposite.
Things to remember
Function machines ignore BIDMAS/BODMAS rules. You must calculate them strictly in the order the boxes appear from left to right. This is why they are often used to introduce brackets in algebra (e.g. an input of 'x' into the machine above results in the expression 4x − 5, whereas an input of 'x' into a "add 5" then "multiply by 4" machine results in 4(x + 5)).