Lessons › coding and computer science · taught by Leo
Functions explained: inputs, outputs, and graphs
Learn what a function is, how to read input-output pairs, and how to use the vertical line test on graphs.
Learn this with Leo, freeA voiced lesson with a live whiteboard, quizzes and a tutor you can call, at tutelage.appA function is a rule
Think of a function like a machine. You put one thing in, and it gives one thing out.
The important rule is this: each input gets exactly one output.
Big idea: input and output
A function connects inputs to outputs by a rule.
The input is the x-value. The output is the y-value.
If the same input tried to give two different outputs, it would not be a function.
Predict the function rule
If a rule takes an input and always gives one output, is it a function?
- Yes, if each input has one output
- No, only if outputs repeat
- No, only if the input is y
Show answer
Yes, if each input has one output: Yes. That is the definition of a function.
Read a table as pairs
A function can be shown in a table. Each row is one input-output pair.
Here, x equals one gives y equals three. x equals two gives y equals five.
Worked example: is it a function?
Let’s test a set of pairs. I am checking whether any input is matched to two outputs.
First pair: one goes to four. That is fine.
Second pair: two goes to six. Still fine.
Third pair: three goes to four. Repeated outputs are allowed, so this is still a function.
Quick check: what fails?
Which situation breaks the function rule?
- One input has two different outputs
- Two different inputs share one output
- Every input has one output
Show answer
One input has two different outputs: Correct. One input cannot point to two different outputs.
Why vertical line test works
A graph is a function if any vertical line hits it at most once.
On a graph, x is the input. A vertical line fixes one x-value.
If that line hits the graph twice, one x would have two y-values, so it is not a function.
Graph test for functions
This curve passes the vertical line test. Each x has only one y.
The flat horizontal line is also a function, because every x still matches one y.
Watch out: repeated y is okay
A lot of students mix this up. Repeated outputs are okay.
The real no-go is two outputs from the same input.
Your turn: is it a function?
A relation has pairs (1, 2), (2, 2), (3, 5). Is it a function?
- Yes, because each input is used once
- No, because the output 2 repeats
- No, because 2 appears twice
Show answer
Yes, because each input is used once: Yes. Each input has exactly one output, so it is a function.
Recap: function checklist
Here is your checklist. Start with the input side.
Then check that each input has exactly one output.
Remember: outputs can repeat, and graphs must pass the vertical line test.