Functions and slope
What f(x) means and how to work out f(3), and how to find the slope of a line through two points.
A taxi charges $3 to get in and $2 for every kilometer. A ride of 5 km costs 2 · 5 + 3 = 13 dollars, and a ride of 10 km costs 2 · 10 + 3 = 23. The distance goes in, and the price comes out. A rule like this is called a function. Functions are everywhere: in phone bills, in recipes, in how fast a plant grows. This page shows how to read the short way of writing them, f(x), and how to measure how steep a straight line is, which is called its slope.
What f(x) means
Think of a function as a machine. You put a number in, the machine follows its rule, and one number comes out. We usually call the machine f and the number that goes in x. So f(x) = 2x + 3 means: "the machine f takes a number, multiplies it by 2, and adds 3."
Then f(5) means "what comes out when 5 goes in". You find it by putting 5 in place of every x in the rule: f(5) = 2(5) + 3 = 13. The number in the brackets is the input. The answer is the output.
Working out a value
- Write down the rule.
- Wherever you see x, write the input number inside a bracket.
- Work out powers first, then multiplying, then adding and subtracting.
Example 1
f(x) = 2x² − 1. What is f(4)?
- Put 4 in place of x: f(4) = 2(4)² − 1.
- Power first: 4² = 16.
- Then multiply: 2(16) = 32.
- Then subtract: 32 − 1 = 31.
Answer: f(4) = 31
Be extra careful when the input is a negative number. Always put it inside a bracket, so the minus sign is squared as well.
Example 2
g(x) = x² + 4x. What is g(−2)?
- Put −2 in place of each x: g(−2) = (−2)² + 4(−2).
- (−2)² = (−2)(−2) = 4, because a negative times a negative is positive.
- 4(−2) = −8.
- So g(−2) = 4 − 8 = −4.
Answer: g(−2) = −4
Example 3
f(x) = 10 − x². What is f(4)?
- Put 4 in place of x: f(4) = 10 − 4².
- Power first: 4² = 16.
- 10 − 16 = −6.
Answer: f(4) = −6
Working backwards: which input gives this output?
Sometimes you know what comes out and must find what went in. For example: "f(x) = 3x − 7. For which x is f(x) = 8?" Here 8 is the output. Write the rule equal to 8 and solve the equation.
Example 4
f(x) = 2x + 5. For which x is f(x) = 17?
- Write the rule equal to the output: 2x + 5 = 17.
- Take 5 away from both sides: 2x = 12.
- Divide both sides by 2: x = 6.
- Check: f(6) = 2(6) + 5 = 12 + 5 = 17. Correct.
Answer: x = 6
Points and the slope of a line
A point on a graph is written as two numbers in brackets, like (3, 8). The first number is x: how far across from the start. The second is y: how far up. So (3, 8) is 3 across and 8 up.
The slope of a line tells you how steep it is. It says how much the line goes up for every 1 step across. A road sign that shows 10% says the same thing: the road rises about 10 meters for every 100 meters forward. To find the slope of a line through two points, divide the change in height by the change across.
Remember
slope = (y_2 − y_1)/(x_2 − x_1)
The change in y divided by the change in x. Subtract in the same order on the top and on the bottom.
Example 5
What is the slope of the line through (2, 3) and (5, 12)?
- Change in y: 12 − 3 = 9.
- Change in x: 5 − 2 = 3.
- Slope = 9/3 = 3.
- The line goes up 3 for every 1 step to the right.
Answer: 3
Example 6
What is the slope of the line through (−2, 7) and (1, −2)?
- Change in y: −2 − 7 = −9.
- Change in x: 1 − (−2) = 1 + 2 = 3. On the number line, going from −2 to 1 is 3 steps to the right.
- Slope = (−9)/3 = −3.
- The slope is negative, so the line goes down as you move to the right.
Answer: −3
Example 7
What is the slope of the line through (0, 1) and (6, 4)?
- Change in y: 4 − 1 = 3.
- Change in x: 6 − 0 = 6.
- Slope = 3/6 = 1/2.
Answer: 1/2
A slope does not have to be a whole number. A slope of 1/2 means the line rises 1 for every 2 steps across. It is a gentle line.
| Slope | What the line does, left to right |
|---|---|
| positive, like 3 | goes up |
| negative, like −2 | goes down |
| 0 | stays flat |
| between 0 and 1, like 1/2 | goes up gently |
Try it yourself
1.f(x) = 3x² + 2. What is f(2)?
Show the answer
14
2² = 4, then 3(4) = 12, and 12 + 2 = 14.
2.g(x) = x² − 4x. What is g(−1)?
Show the answer
5
(−1)² = 1 and −4(−1) = 4, so g(−1) = 1 + 4 = 5.
3.f(x) = 5x + 3. For which x is f(x) = 28?
Show the answer
x = 5
Solve 5x + 3 = 28: 5x = 25, so x = 5.
4.What is the slope of the line through (2, 3) and (4, 11)?
Show the answer
4
(11 − 3)/(4 − 2) = 8/2 = 4.
5.What is the slope of the line through (−1, 6) and (3, −2)?
Show the answer
−2
(−2 − 6)/(3 − (−1)) = (−8)/4 = −2. The line goes down.
6.What is the slope of the line through (1, 1) and (7, 3)?
Show the answer
1/3
(3 − 1)/(7 − 1) = 2/6 = 1/3.
Ready to test yourself?
Play Algebra: 20 seconds per question, and it gets harder as you go.