L2-02 · Functions map inputs to outputs
A function is a rule that gives exactly one output for each input. When we use a function as a model of the real world, its output is a prediction, not a measurement. The gap between them is called the residual: observed minus predicted.
What you will learn¶
I can decide whether a table or a mapping diagram shows a function.
I can use function notation, like h(3), to find a predicted value.
I can find a residual as observed minus predicted, with its sign and unit.
Story: Leo’s bean plant¶
Leo plants a bean seedling for a science project. These are made-up numbers, but they are like real ones. At the start it is 5 cm tall, and it seems to grow about 2 cm a week. Leo writes a rule: h(t) = 2t + 5. Here t is the time in weeks and h is the height in cm. You read h(t) as “h of t”, the height at time t.
Maya tests the rule like a machine. Put in t = 3, and out comes 2 times 3 plus 5, which is 11. So h(3) = 11: the model says the plant should be 11 cm tall after 3 weeks. Each input gives exactly one output. That is what makes the rule a function.
Not every rule is a function. Maya makes a made-up list of birth months for three friends: Maya and Kai were born in March, and Leo in July. Person to birth month is a function, because each person has one birth month. Two people sharing March is fine. But birth month to person is not a function, since March points to two people.
Every Sunday Leo measures the real plant with a ruler. After 3 weeks it is 11.5 cm, not 11. After 4 weeks it is 12 cm, while the model said 13. The model’s output is a prediction. The ruler gives a measurement. They are not the same thing.
To compare them, Leo uses residual = observed - predicted. At week 3, 11.5 - 11 = 0.5 cm, so the plant was a bit above the line. At week 4, 12 - 13 = -1 cm, so it was below. Small residuals that go both ways mean the line is a fair summary for these weeks. They do not mean the plant follows the rule exactly.
A function machine, a function and a non-function, then a model line with measured heights and their residuals.
What the animation shows. First, the input t = 3 weeks goes into a machine with the rule h(t) = 2t + 5. Out comes 11 cm, written h(3) = 11. Next, arrows go from Maya, Kai and Leo to their made-up birth months. Each person has one arrow, so it is a function, even though Maya and Kai share March. When the arrows are turned around, March has two arrows, so it is not a function. Last, the rule is drawn as a line, and Leo’s six made-up measured heights appear as dots. The height axis starts at 4 cm, not 0, so the gaps are easier to see. Short segments show each gap, using residual = observed - predicted. Week 3 shows 11.5 - 11 = 0.5 and week 4 shows 12 - 13 = -1.
Hands-on: Function machines and a coin tower¶
About 20 minutes.
You need:
10 index cards
20 coins of the same kind
A ruler with millimeters
Graph paper
A pencil and a calculator
Steps:
On 5 cards, write a rule, such as “double it, then add 1”. On the back, write three inputs and their outputs. If you have a partner, swap cards and guess each other’s rules from the outputs.
On the other 5 cards, draw small mapping diagrams. Make some that are functions and at least one where an input has two arrows. Sort them into two piles.
Now the coins. Stack 10 coins and measure the height in millimeters. Divide by 10 to get the thickness of one coin.
Write a model: h(n) = thickness times n, where n is the number of coins and h is the height in millimeters.
Use your model to predict the height of 5, 15 and 20 coins. Write the predictions in a table before you measure.
Build each stack and measure it. Add a column for the measured height.
Work out each residual as observed minus predicted, with its sign and unit.
Plot the model as a line and the measurements as dots. Look at whether the residuals are mostly small and go both ways.
Practice together¶
Leo’s model for his plant (made-up numbers) is h(t) = 2t + 5. Predict the height at week 6. If he measures 16.5 cm, what is the residual?
Check your answer
The prediction is h(6) = 2 times 6 plus 5, which is 17 cm. The residual is observed minus predicted: 16.5 - 17 = -0.5 cm. It is negative, so the real plant was a little shorter than the model said.
Try it yourself¶
1. A made-up candle model says L(t) = 20 - 3t, where t is hours of burning and L is length in cm. Predict the length after 4 hours. The real candle is 9 cm long then. Find the residual.
Check your answer
The prediction is L(4) = 20 - 12, which is 8 cm. The residual is 9 - 8 = 1 cm. It is positive, so the candle burned a bit more slowly than the model said.
2. A table lists inputs and outputs: 1 gives 4, 2 gives 4, 3 gives 6, and 1 gives 5. Is this a function? What if the last pair were removed?
Check your answer
It is not a function, because the input 1 has two outputs, 4 and 5. Without the last pair it is a function. Inputs 1 and 2 sharing the output 4 is allowed.
Talk about it¶
Why should Leo keep his predictions and his measurements in separate columns?
If every residual were positive, what would that tell you about the model?
Can a model be useful even if it is never exactly right? Give an example from your life.
Check yourself¶
1. A model predicts 13 cm and the ruler shows 12 cm. What is the residual?
A. 1 cm
B. 25 cm
C. -1 cm
Show the answer
C. -1 cm
Residual = observed - predicted, so 12 - 13 = -1 cm. The minus sign says the real value was below the prediction.
2. Two students in a class were both born in May. Which of these is NOT a function?
A. Each student maps to their birth month.
B. May maps to the first student, and May also maps to the second.
C. Each number x maps to 2x + 5.
Show the answer
B. May maps to the first student, and May also maps to the second.
In the last rule, the input May has two outputs, the two students, so it is not a function. Two students sharing May is fine in the first rule.
3. Remember Lesson 1. In the rule y = 5x + 4 for a price in dollars, what does the 4 stand for? (Review of L2-01)
A. The cost of each item
B. The number of items
C. A fixed fee, paid once
Show the answer
C. A fixed fee, paid once
The constant 4 is added once, whatever x is, so it is a fixed fee. The coefficient 5 is the cost of each item.
Words to know¶
- function
- A rule that gives exactly one output for each input. Two inputs may share an output, but one input may not have two outputs.
- residual
- Observed value minus predicted value. A positive residual means the real value was above the prediction.
For grown-ups: about this lesson
Why it matters. Common Core 8.F.1 asks learners to understand that a function assigns to each input exactly one output NGA Center and CCSSO, 2010. OpenStax defines a function the same way and introduces function notation f(x) Jay Abramson, 2021. The mapping diagrams make the definition concrete: two inputs may share an output, but one input may not have two. The lesson then treats the function as a model: its output is a prediction, and the residual (observed minus predicted) measures how far a measurement falls from it. This sign convention, observed minus predicted, is the one OpenStax uses for regression residuals Illowsky & Dean, 2023, and it prepares the scatter-plot and line-fitting work in the next lesson.
Watch for these mix-ups.
A function must be one-to-one. (Two inputs may share an output; only one input with two outputs breaks the rule.)
The model’s output is what really happened. (It is a prediction; the measurement is what was observed.)
Residual is predicted minus observed. (In this course, as in the OpenStax statistics text Illowsky & Dean, 2023, it is observed minus predicted, so a positive residual means the real value was higher.)
Small residuals prove the rule is the true cause of growth. (They show the line summarizes these weeks well; they say nothing about other weeks or about why the plant grows.)
To make it easier. Skip the mapping cards. Use only the coin tower: find the thickness from 10 coins, then predict and measure 5 and 15 coins, and compute two residuals.
To make it harder. Measure the coin tower for 1 to 20 coins and fit your own line. Compare the slope with your single-stack estimate of the thickness, and explain why measuring 10 coins and dividing gives a better thickness estimate than measuring 1.
Limits. The plant heights and birth months are made up. Real plants do not grow in a straight line for long, so a linear rule is only a short-term summary.
On the computer. Grown-ups can see where this idea leads later in Lab: Variational circuits and gradients, written for older learners.
Sources for this guide. NGA Center and CCSSO, 2010Jay Abramson, 2021Illowsky & Dean, 2023
Next: L2-03 · Read plots without inventing causes
- NGA Center and CCSSO. (2010). Common Core State Standards for Mathematics. Common Core State Standards Initiative. https://learning.ccsso.org/wp-content/uploads/2022/11/Math_Standards1.pdf
- Jay Abramson. (2021). 3.1 Functions and Function Notation. OpenStax, College Algebra 2e. https://openstax.org/books/college-algebra-2e/pages/3-1-functions-and-function-notation
- Illowsky, B., & Dean, S. (2023). Introductory Statistics 2e. https://openstax.org/books/introductory-statistics-2e/pages/1-introduction