The Central Idea

Consider the function

\[ f(x)=x^2. \]

If we write

\[ f:\mathbb{R}\to\mathbb{R}, \]

then:

The codomain and range are not always the same.

The Domain

The domain of a function is the set of inputs for which the function is defined.

If

\[ f:A\to B, \]

then \(A\) is the domain.

Every element of the domain must receive exactly one output.

The Codomain

The codomain is the set in which the function's outputs are declared to lie.

In

\[ f:A\to B, \]

the set \(B\) is the codomain.

The codomain is part of the function's definition.

The Range

The range is the set of output values that the function actually attains.

Symbolically,

\[ \operatorname{range}(f) = \{f(x):x\in\operatorname{dom}(f)\}. \]

The range is always contained in the codomain:

\[ \operatorname{range}(f)\subseteq\operatorname{codomain}(f). \]

Domain, Codomain, and Range at a Glance

Concept Meaning
Domain Allowed inputs
Codomain Declared set of possible outputs
Range Outputs actually produced

Example: Squaring Function

Let

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=x^2. \]

Domain:

\[ \mathbb{R}. \]

Codomain:

\[ \mathbb{R}. \]

Range:

\[ [0,\infty). \]

Negative real numbers belong to the codomain, but the function never produces them.

The Range Can Equal the Codomain

Consider

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=2x+1. \]

Every real number can be produced by some real input.

So the range is

\[ \mathbb{R}. \]

Here the range equals the codomain.

Same Formula, Different Codomain

Consider

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=x^2 \]

and

\[ g:\mathbb{R}\to[0,\infty), \qquad g(x)=x^2. \]

They use the same formula and same domain, but their codomains differ.

So they are not identical as formally defined functions.

Why Codomain Matters

The codomain affects function properties.

For example,

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=x^2 \]

does not reach every element of its codomain.

But

\[ g:\mathbb{R}\to[0,\infty), \qquad g(x)=x^2 \]

does reach every element of its codomain.

This distinction becomes important when studying surjective and inverse functions.

Domain Restrictions from Division

Consider

\[ f(x)=\frac{1}{x-3}. \]

The denominator cannot equal zero:

\[ x-3\ne0. \]

Therefore,

\[ x\ne3. \]

The real domain is

\[ \boxed{\mathbb{R}\setminus\{3\}}. \]

Interval Form of a Restricted Domain

The same domain can be written

\[ (-\infty,3)\cup(3,\infty). \]

Set difference and interval notation are two representations of the same set.

Domain Restrictions from Even Roots

Consider

\[ f(x)=\sqrt{x-5}. \]

For real outputs, the radicand must satisfy

\[ x-5\ge0. \]

So

\[ x\ge5. \]

The domain is

\[ \boxed{[5,\infty)}. \]

Odd Roots Behave Differently

Consider

\[ f(x)=\sqrt[3]{x-5}. \]

Cube roots are defined for every real input.

So the domain is

\[ \boxed{\mathbb{R}}. \]

Domain Restrictions from Logarithms

Consider

\[ f(x)=\ln(x+2). \]

A real logarithm requires a positive argument:

\[ x+2>0. \]

Thus,

\[ x>-2. \]

The domain is

\[ \boxed{(-2,\infty)}. \]

Multiple Restrictions

Consider

\[ f(x)=\frac{\sqrt{x-1}}{x-4}. \]

The square root requires

\[ x-1\ge0, \]

so

\[ x\ge1. \]

The denominator requires

\[ x\ne4. \]

Therefore, the domain is

\[ \boxed{[1,4)\cup(4,\infty)}. \]

Domain Restrictions Must Be Combined

When several conditions appear, the domain is the intersection of all allowed-input conditions.

Every restriction must be satisfied simultaneously.

This is another use of set intersection in algebra.

Natural Domain of a Formula

If no domain is explicitly stated, we often use the natural domain: the largest set of inputs for which the formula makes sense in the number system being used.

For a real-valued rational function, this means excluding denominator zeros.

For real square roots, it means requiring nonnegative radicands.

Explicit Domains Override the Natural Domain

Consider

\[ f(x)=x^2 \]

with explicit domain

\[ [-2,3]. \]

Although the formula makes sense for all real numbers, the function is defined here only on

\[ [-2,3]. \]

The stated domain is part of the function.

Contextual Domains

A formula may permit inputs that do not make sense in an application.

Suppose

\[ C(n)=12n \]

gives the cost of \(n\) tickets.

If only whole tickets may be purchased, a practical domain is

\[ \boxed{\mathbb{Z}_{\ge0}}. \]

Continuous Versus Discrete Domains

A distance function such as

\[ d(t)=60t \]

may use a continuous domain such as

\[ t\ge0. \]

A counting function may use a discrete domain such as

\[ n\in\{0,1,2,3,\ldots\}. \]

The type of input set matters.

Finite Domains

A function may have only finitely many inputs.

For example,

\[ f:\{1,2,3\}\to\mathbb{R} \]

defined by

\[ f(1)=4,\qquad f(2)=7,\qquad f(3)=9 \]

has domain

\[ \{1,2,3\}. \]

Domain from a Table

Input Output
\(-2\) 4
0 1
5 9

The domain is

\[ \boxed{\{-2,0,5\}}. \]

The range is

\[ \boxed{\{1,4,9\}}. \]

Repeated Outputs Do Not Repeat in the Range

Suppose a table gives outputs

\[ 4,4,9,9,9. \]

The range is a set, so repeated values are listed only once:

\[ \boxed{\{4,9\}}. \]

Domain and Range from Ordered Pairs

Consider

\[ \{(1,5),(2,7),(4,5),(8,10)\}. \]

The domain is the set of first coordinates:

\[ \boxed{\{1,2,4,8\}}. \]

The range is the set of second coordinates:

\[ \boxed{\{5,7,10\}}. \]

Domain from a Graph

On a graph, the domain consists of the horizontal input values for which points exist.

One useful mental question is:

How far does the graph extend from left to right?

Range from a Graph

On a graph, the range consists of the vertical output values that occur.

A useful question is:

How far does the graph extend from bottom to top?

Open and Closed Endpoints

If a graph includes an endpoint, interval notation uses a bracket when the endpoint is finite.

If the endpoint is excluded, use a parenthesis.

For example:

\[ [2,7) \]

includes \(2\) but excludes \(7\).

Infinity Always Uses Parentheses

Infinity is not a finite endpoint that can be included.

Therefore,

\[ [3,\infty) \]

is valid, while

\[ [3,\infty] \]

is not.

Range of a Linear Function

For

\[ f(x)=2x+3 \]

with domain \(\mathbb{R}\), every real output is attained.

So

\[ \operatorname{range}(f)=\mathbb{R}. \]

Range of a Quadratic

For

\[ f(x)=x^2+4, \]

we know

\[ x^2\ge0. \]

Therefore,

\[ f(x)\ge4. \]

The range is

\[ \boxed{[4,\infty)}. \]

Range of a Reciprocal Function

Consider

\[ f(x)=\frac{1}{x}. \]

The output can never equal zero.

So the range is

\[ \boxed{\mathbb{R}\setminus\{0\}}. \]

Range of a Square Root

For

\[ f(x)=\sqrt{x}, \]

the principal square root is always nonnegative.

Thus,

\[ \boxed{\operatorname{range}(f)=[0,\infty)}. \]

Range Can Depend on the Domain

Consider

\[ f(x)=x^2. \]

If the domain is

\[ \mathbb{R}, \]

the range is

\[ [0,\infty). \]

If the domain is

\[ [2,5], \]

the range becomes

\[ [4,25]. \]

Changing the domain can change the range.

Restricted Domain Can Change Function Properties

For

\[ f(x)=x^2 \]

on all real numbers, different inputs such as \(2\) and \(-2\) share an output.

But on the restricted domain

\[ [0,\infty), \]

the function is one-to-one.

Domain restriction can fundamentally change behavior.

Codomain Is Not Read from a Graph Alone

A graph shows actual outputs, so it can reveal the range.

But the codomain is part of the function's declaration.

Two functions may have identical graphs and different codomains.

Therefore, the codomain generally cannot be recovered from the graph alone.

Mapping Diagram View

Suppose

\[ f:\{1,2,3\}\to\{a,b,c,d\} \]

with

\[ 1\mapsto a,\qquad 2\mapsto c,\qquad 3\mapsto c. \]

Then:

Domain:

\[ \{1,2,3\}. \]

Codomain:

\[ \{a,b,c,d\}. \]

Range:

\[ \{a,c\}. \]

Unused Codomain Elements Are Allowed

In the previous example,

\[ b \]

and

\[ d \]

belong to the codomain but are not reached.

A function does not have to use every codomain element unless a stronger property is required.

Domain and Range Need Not Be Numbers

Suppose

\[ L(w)=\text{number of letters in word }w. \]

The domain could be a set of words.

The range could be positive integers.

Domain and range are sets of objects, not necessarily intervals of real numbers.

Example with Sets as Inputs

Let

\[ N(S)=|S| \]

for finite sets \(S\).

The domain consists of finite sets.

The range is

\[ \{0,1,2,3,\ldots\}. \]

The function maps sets to nonnegative integers.

Multivariable Domains

Consider

\[ A(l,w)=lw. \]

If \(l\) and \(w\) are arbitrary real inputs, the domain could be

\[ \mathbb{R}^2. \]

If they represent side lengths, a contextual domain might be

\[ \{(l,w)\in\mathbb{R}^2:l>0,\ w>0\}. \]

Domain as a Region

For multivariable functions, the domain may be a region rather than an interval.

For example,

\[ f(x,y)=\sqrt{9-x^2-y^2} \]

requires

\[ 9-x^2-y^2\ge0. \]

So

\[ x^2+y^2\le9. \]

The domain is the closed disk of radius \(3\) in the plane.

Domain Restrictions Can Describe Geometry

The inequality

\[ x^2+y^2\le9 \]

is not merely a technical restriction.

It describes a geometric object: all points inside and on a circle of radius \(3\).

Domains can therefore encode geometry as well as arithmetic conditions.

Piecewise Domains

A piecewise function may use different formulas on different parts of the domain.

For example,

\[ f(x)= \begin{cases} x+1, & x<0,\\ x^2, & x\ge0. \end{cases} \]

The domain is

\[ \mathbb{R}. \]

The conditions partition the input set.

Gaps in a Domain

A domain need not be one continuous interval.

For

\[ f(x)=\frac{1}{(x-1)(x+2)}, \]

we require

\[ x\ne1,\qquad x\ne-2. \]

The domain is

\[ (-\infty,-2)\cup(-2,1)\cup(1,\infty). \]

Set-Builder Notation for Domains

The previous domain can also be written

\[ \{x\in\mathbb{R}:x\ne-2,\ x\ne1\}. \]

Set-builder notation is especially useful when the allowed inputs are easier to describe by a condition than by intervals.

Range in Set-Builder Notation

For

\[ f(x)=x^2, \]

the range can be written

\[ \{y\in\mathbb{R}:y\ge0\}. \]

Or in interval notation:

\[ [0,\infty). \]

Using a Different Variable for Range

Range is a set of outputs, so the output variable is often written \(y\):

\[ \{y\in\mathbb{R}:y\ge0\}. \]

But the letter is not essential.

The set matters more than the symbol used to name its elements.

Domain and Inverse Functions

When a function is inverted, the roles of inputs and outputs reverse.

For a true inverse function:

This is one reason domain and range must be understood precisely before studying inverses.

Codomain and Surjectivity Preview

A function is called surjective onto its codomain if every codomain element is reached.

That means

\[ \operatorname{range}(f) = \operatorname{codomain}(f). \]

So surjectivity cannot be discussed without knowing the codomain.

Range Is Determined by Domain and Rule

Once the domain and function rule are fixed, the range is determined.

The codomain, however, may be chosen as part of the function's declaration as long as it contains all actual outputs.

A Codomain Must Contain the Range

Suppose

\[ f(x)=x^2 \]

with real domain.

It would be invalid to declare

\[ f:\mathbb{R}\to(-\infty,0) \]

because the actual outputs are nonnegative and do not belong to that codomain.

A codomain must be broad enough to contain every function output.

Natural Range Versus Declared Codomain

The phrase natural range may informally mean the outputs produced by the natural domain.

But formally, range and codomain should remain distinct:

\[ \text{range}=\text{actual outputs}, \] \[ \text{codomain}=\text{declared target set}. \]

Worked Example: Rational Domain

Find the real domain of

\[ f(x)=\frac{x+4}{x^2-9}. \]

Factor the denominator:

\[ x^2-9=(x-3)(x+3). \]

Exclude

\[ x=3,\qquad x=-3. \]

Domain:

\[ \boxed{\mathbb{R}\setminus\{-3,3\}}. \]

Worked Example: Radical Domain

Find the real domain of

\[ f(x)=\sqrt{2x-6}. \]

Require

\[ 2x-6\ge0. \]

Then

\[ x\ge3. \]

Domain:

\[ \boxed{[3,\infty)}. \]

Worked Example: Logarithmic Domain

Find the real domain of

\[ f(x)=\log(x^2-4). \]

Require

\[ x^2-4>0. \]

Factor:

\[ (x-2)(x+2)>0. \]

This holds when

\[ x<-2 \]

or

\[ x>2. \]

So the domain is

\[ \boxed{(-\infty,-2)\cup(2,\infty)}. \]

Worked Example: Quadratic Range

Find the range of

\[ f(x)=(x-2)^2-5. \]

Since

\[ (x-2)^2\ge0, \]

we have

\[ f(x)\ge-5. \]

Therefore,

\[ \boxed{[-5,\infty)}. \]

Worked Example: Restricted Quadratic Range

Let

\[ f(x)=x^2 \]

with domain

\[ [-3,1]. \]

The smallest value is

\[ 0 \]

at \(x=0\).

The largest value is

\[ 9 \]

at \(x=-3\).

So the range is

\[ \boxed{[0,9]}. \]

Worked Example: Mapping Diagram

Suppose

\[ f:\{1,2,3,4\}\to\{a,b,c,d,e\} \]

with outputs

\[ 1\mapsto b,\quad 2\mapsto c,\quad 3\mapsto c,\quad 4\mapsto e. \]

Then:

Domain:

\[ \boxed{\{1,2,3,4\}}. \]

Codomain:

\[ \boxed{\{a,b,c,d,e\}}. \]

Range:

\[ \boxed{\{b,c,e\}}. \]

A Reliable Domain Workflow

  1. Begin with the stated domain if one is given.
  2. Identify denominator restrictions.
  3. Require even-root radicands to be nonnegative.
  4. Require logarithm arguments to be positive.
  5. Combine all conditions using intersection.
  6. Apply contextual restrictions such as positivity or integer counts.
  7. Write the final set clearly in interval, roster, or set-builder notation.

A Reliable Range Workflow

  1. Identify the domain first.
  2. Ask what outputs the rule can actually produce.
  3. Use algebraic inequalities, graph behavior, or transformations as appropriate.
  4. Check endpoint inclusion carefully.
  5. Remember that the range may change if the domain is restricted.
  6. Write the output set clearly.

A Reliable Codomain Check

  1. Read the declared target set in \(f:A\to B\).
  2. Verify that every actual output belongs to \(B\).
  3. Do not assume every element of \(B\) is reached.
  4. Compare range and codomain only when studying properties such as surjectivity.

Common Errors

Using Domain, Codomain, and Range as Synonyms

They describe different parts of the function structure.

Assuming the Codomain Is the Range

The range may be a proper subset of the codomain.

Ignoring an Explicitly Stated Domain

The stated domain overrides the larger natural domain of the formula.

Forgetting Contextual Restrictions

Counts, lengths, times, and other applied variables may have narrower domains than the algebraic formula alone suggests.

Using \(\ge0\) for a Logarithm Argument

Real logarithms require the argument to be strictly positive:

\[ >0. \]

Forgetting Denominator Restrictions After Simplification

Original excluded values remain excluded even if algebraic cancellation removes the visible factor.

Reading Codomain from the Graph

The graph shows the range, not necessarily the declared codomain.

Practice

1. Domain of a Rational Function

Find the real domain of

\[ f(x)=\frac{3}{x-5}. \]
Check Answer \[ x\ne5. \]

Domain:

\[ \boxed{\mathbb{R}\setminus\{5\}}. \]

2. Domain of a Square Root

Find the real domain of

\[ f(x)=\sqrt{x+7}. \]
Check Answer \[ x+7\ge0, \] \[ x\ge-7. \]

Domain:

\[ \boxed{[-7,\infty)}. \]

3. Domain of a Logarithm

Find the real domain of

\[ f(x)=\ln(5-x). \]
Check Answer \[ 5-x>0, \] \[ x<5. \]

Domain:

\[ \boxed{(-\infty,5)}. \]

4. Range of a Quadratic

Find the range of

\[ f(x)=x^2+2. \]
Check Answer \[ x^2\ge0, \]

so

\[ f(x)\ge2. \]

Range:

\[ \boxed{[2,\infty)}. \]

5. Domain and Range from Ordered Pairs

For

\[ \{(-1,2),(0,5),(3,2),(7,9)\}, \]

find the domain and range.

Check Answer

Domain:

\[ \boxed{\{-1,0,3,7\}}. \]

Range:

\[ \boxed{\{2,5,9\}}. \]

6. Codomain Versus Range

Let

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=x^2. \]

What are the codomain and range?

Check Answer

Codomain:

\[ \boxed{\mathbb{R}}. \]

Range:

\[ \boxed{[0,\infty)}. \]

7. Contextual Domain

The function

\[ T(n)=15n \]

gives the total cost of \(n\) identical items. If only whole nonnegative numbers of items may be purchased, what is the domain?

Check Answer \[ \boxed{\mathbb{Z}_{\ge0}}. \]

8. Multivariable Domain

Find the real domain of

\[ f(x,y)=\sqrt{16-x^2-y^2}. \]
Check Answer \[ 16-x^2-y^2\ge0, \]

so

\[ \boxed{x^2+y^2\le16}. \]

The domain is the closed disk of radius \(4\).

Key Ideas

Where This Leads

Domain, codomain, and range form the set-theoretic skeleton of functions.

These ideas become essential when studying graphs, inverse functions, one-to-one and onto mappings, transformations, composition, rational and radical functions, piecewise functions, multivariable functions, and later calculus where domain boundaries and attainable outputs often control the behavior of a model.