Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 37 · Function Analysis

Functions, Domain and Range

Understand what makes a relation a function, use the vertical line test, and find the domain and range of common functions with runnable Python.

A function is the central object of pre-calculus and calculus. Before you can analyze one, you need to say precisely what it is, which inputs it accepts (its domain) and which outputs it can produce (its range). This lesson builds those ideas and gives you a checklist for finding domains quickly.

What is a function?

A relation is any set of pairs (input, output). A function is a relation in which each input has exactly one output. The set of allowed inputs is the domain; the set of outputs that actually occur is the range.

Compare two small relations:

  • {(1, 4), (2, 5), (3, 4)} is a function. Two inputs share the output 4, which is fine.
  • {(1, 4), (1, 5), (2, 6)} is not a function: the input 1 has two outputs.

Different inputs may share an output. One input may never have two outputs.

The vertical line test

On a graph, a relation is a function exactly when no vertical line crosses it more than once. A parabola y = x² passes. A sideways parabola x = y² fails, because the line x = 4 hits it at y = 2 and y = -2. A circle fails for the same reason.

flowchart LR
A["Draw a vertical line"] --> B{"Crosses graph<br/>more than once?"}
B -->|"Yes, anywhere"| C["Not a function"]
B -->|"Never"| D["A function"]

The vertical line test, as a decision.

Function notation

y = f(x) names the function f. The expression f(x) is read "f of x". You can substitute anything: f(a + 1), f(2x), even another function.

If f(x) = x² + 1, then f(a + 1) = (a + 1)² + 1 = a² + 2a + 2. Note that f(a + 1) is not f(a) + f(1).

A useful derived quantity is the difference quotient (f(x + h) - f(x)) / h, which is the starting point of calculus. For f(x) = x² it simplifies to 2x + h.

Python Difference quotient with SymPy

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.

Finding the domain

Start from "all real numbers" and remove inputs that cause trouble. There are two common troublemakers in this course:

  1. Division by zero. Exclude any x that makes a denominator 0.
  2. Even roots of negatives. An expression √(...) needs the inside to be ≥ 0.

(Later you will add: a logarithm needs a positive argument.)

Function Restriction Domain
f(x) = 3x - 1 none (-∞, ∞)
f(x) = 1 / (x - 4) x ≠ 4 (-∞, 4) ∪ (4, ∞)
f(x) = √(x + 2) x + 2 ≥ 0 [-2, ∞)
f(x) = √(x - 1) / (x - 5) x ≥ 1 and x ≠ 5 [1, 5) ∪ (5, ∞)

The last row combines both conditions. Note that 5 is in [1, ∞) so it must be punched out.

Python Test a domain by trying inputs

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.

Testing inputs can suggest a domain, but only algebra proves it. A computer cannot try every real number.

Finding the range

The range is harder because it depends on the whole shape of the graph. Useful strategies:

  • From the graph. Read the lowest and highest y values reached.
  • From the structure. x² is never negative, so x² + 3 ≥ 3 and the range is [3, ∞).
  • By solving for x. Treat y as given and ask which y allow a solution. For y = 1/(x - 4), solving gives x = 4 + 1/y, which exists for every y ≠ 0, so the range is (-∞, 0) ∪ (0, ∞).

Here is a plot with numerical estimates of domain and range for a function.

Python Estimate a range by sampling

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.

A sampled maximum only describes the window you looked at. This function keeps growing without bound, so its true range has no upper limit.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which relation is a function?

    Each input appears once. Sharing an output is allowed, but an input with two outputs is not.
  2. 2. What is the domain of f(x) = √(x - 3)?

    We need x - 3 ≥ 0, so x ≥ 3, and 3 is included because √0 = 0 is defined.
  3. 3. What is the range of f(x) = x² + 3?

    x² is at least 0, so x² + 3 is at least 3 and takes every value above.
  4. 4. What is the domain of f(x) = 1/(x - 4)?

    The denominator is zero only at x = 4.

Summary

  • A function gives exactly one output per input; the vertical line test checks this on a graph.
  • Domain: inputs allowed; range: outputs produced.
  • Exclude zero denominators and negative numbers under even roots when finding a domain.
  • Find a range from the graph, the structure of the expression, or by solving for x.

Next: Graph Features and Symmetry