Skip to content
Tutorials Center
My learning

Topics

Lesson 5 of 38 · Functions and Transformations

Functions and Function Notation

Understand what a function is, read and use f(x) notation, apply the vertical line test, and move between tables, graphs, equations and words.

A function is a rule that assigns to every allowed input exactly one output. The phrase "exactly one" is the whole definition. A vending machine is a good picture: press one button (the input) and you get one specific item (the output). Press the same button again and you expect the same item.

Functions let you describe how one quantity depends on another: distance on time, price on quantity, temperature on altitude. Once a relationship is a function, you can ask powerful questions about it: where is it largest, when does it equal zero, how does it change?

Relations and functions

A relation is any set of input-output pairs. It is a function only if no input is paired with two different outputs.

Relation (as pairs) Function? Why
(1, 2), (2, 4), (3, 6) Yes each input appears once
(1, 5), (2, 5), (3, 5) Yes different inputs may share an output
(1, 2), (1, 3), (2, 4) No input 1 has two outputs

Notice the asymmetry: two inputs sharing an output is fine; one input with two outputs is not.

Function notation

We name a function with a letter and write f(x), read "f of x". The symbol f(x) is not f times x. It means "the output of f when the input is x".

If f(x) = 3x² - 2x + 1, then to evaluate f(2) replace every x with 2: f(2) = 3(2)² - 2(2) + 1 = 12 - 4 + 1 = 9. Brackets help: write f(-1) = 3(-1)² - 2(-1) + 1 = 3 + 2 + 1 = 6. Forgetting brackets around a negative input is a very common error.

You can also put expressions inside. For the same f, f(a + 1) = 3(a + 1)² - 2(a + 1) + 1. Expand if you need to: 3a² + 6a + 3 - 2a - 2 + 1 = 3a² + 4a + 2.

Python Evaluate functions

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Four ways to show a function

The same function can be shown as an equation, a table, a graph or words. Moving between them is a key skill.

  • Words: "Take a number, double it, add one."
  • Equation: f(x) = 2x + 1.
  • Table: inputs 0, 1, 2, 3 give outputs 1, 3, 5, 7.
  • Graph: a straight line through (0, 1) with slope 2.

The vertical line test

On a graph, a vertical line at any x shows the outputs for that input. If a vertical line ever crosses the graph twice, one input has two outputs and the graph is not a function. A parabola opening upward, y = x², passes the test. A sideways parabola, x = y², fails it: at x = 4 both y = 2 and y = -2 appear.

flowchart LR
    X["Input x"] --> F["Rule f"]
    F --> Y["Output f(x)"]

A function as a machine: one input in, one output out.

Independent and dependent variables

The input is the independent variable because you choose it freely. The output is the dependent variable because its value depends on your choice. In d = 60t (distance in kilometers for a car at 60 km/h after t hours), t is independent and d is dependent. We could write d(t) = 60t.

Solving for the input

Evaluation goes from input to output. Sometimes you need to go the other way: for f(x) = 2x + 1, which x gives f(x) = 9? Solve the equation 2x + 1 = 9, giving x = 4. For some functions there may be several such inputs, or none. For g(x) = x², the equation g(x) = 9 has two solutions, x = 3 and x = -3, while g(x) = -1 has none among the real numbers.

Python Is a set of pairs a function?

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. If f(x) = x² - 3x, what is f(-2)?

    f(-2) = (-2)² - 3(-2) = 4 + 6 = 10.
  2. 2. Which set of pairs is NOT a function?

    The input 2 is paired with both 7 and 8.
  3. 3. What does the vertical line test check?

    A vertical line crossing the graph twice means one x has two outputs.
  4. 4. In d(t) = 60t, which variable is dependent?

    d depends on the chosen value of t.

Summary

  • A function gives exactly one output for each input.
  • f(x) means "the output of f at input x", not a product.
  • Replace every x by the given input, using brackets for negatives and expressions.
  • Functions can be given as words, equations, tables or graphs.
  • A graph is a function if no vertical line meets it twice.

Next: Domain and Range