Function Machines
On this page
How to find the output of a function machine, how to work backwards with inverse operations to find the input, how to fill in an empty box, and how to show that there is an input that gives the same number out.
What a function machine does
A function machine, also called a number machine, takes a number in, does one or more operations to it in order, and gives a number out. The number that goes in is the input. The number that comes out is the output.
This machine multiplies by 4, then subtracts 5. An input of 6 becomes 6 \times 4 = 24, then 24 - 5 = 19. So the output is 19.
In the exam you are usually shown a number machine and asked to work out the output for a given input, for 1 mark, and then the input for a given output, for 2 marks. Some questions give a machine with an empty box to complete, or ask you to show that one input gives the same number as the output. They come up on the non-calculator and the calculator papers.
Worked example 1: Finding the output
This number machine subtracts 4, then multiplies by 6. Work out the output when the input is 9.
- Start with the input, 9, and go through the first box: 9 - 4 = 5
-
Your turn. Now go through the second box. Work out 5 \times 6
5 \times 6 = 30
- Finish each box before you start the next. Writing 9 - 4 \times 6 and using the order of operations would multiply first, which is not what the machine does.
- Answer: 30
One box at a time
Go through the boxes one at a time, from left to right. Write the number you have after each box above the arrow, so you don't lose track.
Don't turn the whole machine into one calculation. For a machine that adds 7 then divides by 2, an input of 9 gives 9 + 7 = 16, then 16 \div 2 = 8. Working out 9 + 7 \div 2 instead gives 12.5, which is wrong.
The order of the boxes matters. Multiply by 2 then add 3 turns 5 into 13. Add 3 then multiply by 2 turns 5 into 16
Negative numbers and decimals go through a machine in the same way. A machine that multiplies by 4 then adds 10 turns -3 into -12, then -12 + 10 = -2
Working backwards to find the input
When you know the output and want the input, run the machine backwards. Start at the output, go through the boxes from right to left, and do the inverse of each operation: the operation that undoes it.
- Adding and subtracting undo each other: the inverse of +3 is -3
- Multiplying and dividing undo each other: the inverse of \times 2 is \div 2
The last box is the first one you undo. Then check your answer by putting it through the machine forwards: you should get the output you were given.
Worked example 2: Finding the input
This number machine adds 8, then multiplies by 3. The output is 42. Work out the input.
- Start at the output, 42. The last box is \times 3, so undo it first with \div 3
-
Your turn. Undo the \times 3 box. What number goes into it?
42 \div 3 = 14
- Next undo +8 with -8: 14 - 8 = 6
- Check forwards: 6 + 8 = 14, then 14 \times 3 = 42
- Answer: 6
Worked example 3: Working back from a negative output
This number machine adds 5, then divides by 3. The output is -4. Work out the input.
- Undo the last box first. The inverse of \div 3 is \times 3: -4 \times 3 = -12
-
Your turn. Now undo +5 with -5. Work out -12 - 5
-12 - 5 = -17. Taking 5 away from -12 goes further below zero.
- Check forwards: -17 + 5 = -12, then -12 \div 3 = -4
- Answer: -17
Completing a machine with an empty box
Sometimes one box is empty, and you are told an input and its output. Go forwards from the input through any box you know, and backwards from the output through any box you know. Then you have the number going into the empty box and the number coming out of it.
Find an operation that turns one into the other. If 7 goes in and 19 comes out, the box could be +12, because 7 + 12 = 19
Write the operation with its sign, such as +12 or \times 3, not just the number. Sometimes more than one operation works, and any one that gives the right output is correct.
Worked example 4: Filling in an empty box
In this number machine the first box adds 3 and the second box is empty. When the input is 5, the output is 32. Complete the number machine.
- Go forwards through the box you know: 5 + 3 = 8. So the empty box turns 8 into 32
-
Your turn. What number do you multiply 8 by to give 32?
32 \div 8 = 4, so the empty box could be \times 4
- Adding works too: 32 - 8 = 24, so +24 also turns 8 into 32
- Check: 5 + 3 = 8, then 8 \times 4 = 32
- Answer: the empty box is \times 4 (or +24)
Worked example 5: A missing number in the first box
In this number machine the first box subtracts a number, but the number is missing. The second box divides by 6. When the input is 50, the output is 7. Work out the missing number.
- You can't go forwards through the first box, so start at the output, 7, and undo the second box. The inverse of \div 6 is \times 6
-
Your turn. Work out 7 \times 6
7 \times 6 = 42, so 42 comes out of the first box
- The first box turns 50 into 42. Then 50 - 42 = 8, so the first box subtracts 8
- Check: 50 - 8 = 42, then 42 \div 6 = 7
- Answer: 8
When the output equals the input
The hardest part of a number machine question asks you to show that there is a number for which the output is the same as the input. In these questions the machine usually multiplies, then subtracts.
You can try inputs. For multiply by 4 then subtract 9, an input of 1 gives -5, too small. An input of 5 gives 11, too big. An input of 3 gives 12 - 9 = 3, the same as the input.
Or call the input n and write the output as an expression. Going through the boxes, n becomes 4n, then 4n - 9
The output equals the input, so solve 4n - 9 = n. Take n from both sides: 3n - 9 = 0, so 3n = 9 and n = 3
Either way, finish by showing it: write the number going through every box and the output it gives, so the examiner sees that they match. Don't change the machine to make them match.
Worked example 6: An output equal to its input
This number machine multiplies by 6, then subtracts 20. Show that there is a number for which the output is the same as the input.
- Call the input n. The first box multiplies by 6, so n becomes 6n
-
Your turn. The second box subtracts 20. Write an expression, in terms of n, for the output.
The output is 6n - 20
- The output equals the input, so 6n - 20 = n. Take n from both sides: 5n - 20 = 0, so 5n = 20 and n = 4
- Show it: 4 \times 6 = 24, then 24 - 20 = 4, the same as the input.
- Answer: an input of 4 gives an output of 4
Common mistakes
- Treating the output as an input. When the question gives you the output, start at the output end and work backwards.
- Undoing the boxes in the wrong order. Undo the last box first, then work back to the first.
- Doing the same operation instead of the inverse. Going backwards, add becomes subtract and multiply becomes divide.
- Using the order of operations across the boxes. Finish each box before the next: add 7 then divide by 2 turns 9 into 8, not 12.5
- Slips with negative numbers. Take care going below zero: -12 - 5 is -17, not -7
- Changing the machine to make the input and output match. Keep the boxes as they are, and change only the number you put in.
More on this topic: Function Machines worksheet with full solutions