Type to search, in English or Thai

  1. Home
  2. English lessons
  3. Precalculus
  4. Functions

// Chapter 27.2 · Precalculus · Functions

Functions in Precalculus: Relations, Domain, Range, Function Notation, Operations and Composition

A function is a rule that takes one input and always returns one output, like a vending machine that gives the same drink every time you press the same button. If one day the same button produced two different drinks, the machine would stop being a function. This page lays the foundation that every later page uses: reading f(x)f(x), deciding which inputs are allowed (the domain) and which outputs occur (the range), combining functions, and chaining them with composition. It ends with the average rate of change, the doorway to derivatives.

By Ajarn ModUpdated
In 30 seconds
  • Function: one x gives one y · the graph passes the vertical line test
  • Domain: exclude zero denominators, negative values under even roots and non-positive log arguments
  • Range: solve for x in terms of y, or use the vertex and the graph
  • (f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x)): g acts first · in general f∘g≠g∘ff \circ g \ne g \circ f
  • Average rate of change = secant slope f(b)−f(a)b−a\dfrac{f(b) - f(a)}{b - a}

What a function is: one input, one output

A relation is a set of ordered pairs (x,y)(x, y) such as {(1, 2), (2, 4), (3, 6)}. It is a function when no x is paired with two different y-values. On a graph that is the vertical line test: if a vertical line hits the graph twice, some x has two outputs. The circle x2+y2=25x^2 + y^2 = 25 is therefore not a function of x, while its upper half y=25−x2y = \sqrt{25 - x^2} is. The notation f(x)f(x), read “f of x”, means the output of the rule f at the input x; it is not f times x.

F1 Function

f:A→B,(x,y1)∈f and (x,y2)∈f ⇒ y1=y2f: A \to B,\qquad (x, y_1) \in f \ \text{and}\ (x, y_2) \in f \ \Rightarrow\ y_1 = y_2

A is the domain · the set of outputs {f(x):x∈A}\{f(x) : x \in A\} is the range

F2 Function notation

f(x)=x2−3x ⇒ f(a+1)=(a+1)2−3(a+1)=a2−a−2f(x) = x^2 - 3x \ \Rightarrow\ f(a + 1) = (a + 1)^2 - 3(a + 1) = a^2 - a - 2

Substitute the whole input into every x, inside brackets

Finding the domain

Unless a problem gives the domain, take it to be every real number for which the formula produces a real number. At this level only three things can go wrong, so check each one and intersect the conditions. Interval notation keeps the answer readable.

F3 Domain rules

p(x)q(x): q(x)≠0,u(x): u(x)≥0,log⁡u(x): u(x)>0\frac{p(x)}{q(x)}:\ q(x) \ne 0,\qquad \sqrt{u(x)}:\ u(x) \ge 0,\qquad \log u(x):\ u(x) > 0

With several conditions, take the intersection · a root in a denominator needs u>0u > 0

Example F-1 · A root and a denominator

Find the domain of f(x)=x+2x−3f(x) = \dfrac{\sqrt{x + 2}}{x - 3}

  1. Square root: x+2≥0⇒x≥−2x + 2 \ge 0 \Rightarrow x \ge -2

  2. Denominator: x−3≠0⇒x≠3x - 3 \ne 0 \Rightarrow x \ne 3

  3. Together: every x≥−2x \ge -2 except 3

Df=[−2, 3)∪(3, ∞)D_f = [-2,\ 3) \cup (3,\ \infty)

Example F-2 · Domain of a logarithm

Find the domain of g(x)=log⁡(4−x2)g(x) = \log\left(4 - x^2\right)

  1. The argument must be positive: 4−x2>0⇒x2<44 - x^2 > 0 \Rightarrow x^2 < 4

  2. (2−x)(2+x)>0(2 - x)(2 + x) > 0 holds for −2<x<2-2 < x < 2 (see A11)

Dg=(−2, 2)D_g = (-2,\ 2)

Finding the range

The range is harder than the domain because the question runs backwards: which y-values are actually produced by some x? Three methods cover most cases: (1) solve y=f(x)y = f(x) for x and see which y allow a solution, (2) use the vertex for quadratics, (3) start from a known graph, for instance x≥0\sqrt{x} \ge 0 or bx>0b^x > 0, and apply the shifts and stretches.

F4 Finding the range

y=f(x) ⇒ x=g(y) ⇒ Rf={ y:g(y) is defined and lies in Df }y = f(x) \ \Rightarrow\ x = g(y) \ \Rightarrow\ R_f = \{\,y : g(y) \text{ is defined and lies in } D_f\,\}

Quadratic a(x−h)2+ka(x - h)^2 + k: a>0a > 0 gives [k,∞)[k, \infty) · a<0a < 0 gives (−∞,k](-\infty, k]

Example F-3 · Two ranges

Find the range of (a) f(x)=x2−4x+7f(x) = x^2 - 4x + 7 (b) h(x)=2xx+1h(x) = \dfrac{2x}{x + 1}

  1. (a) Complete the square: (x−2)2+3(x - 2)^2 + 3; the smallest value is 3, at x = 2

  2. (b) Let y=2xx+1y = \dfrac{2x}{x + 1}: y(x+1)=2x⇒x(y−2)=−y⇒x=y2−yy(x + 1) = 2x \Rightarrow x(y - 2) = -y \Rightarrow x = \dfrac{y}{2 - y}

  3. x exists for every y except y=2y = 2, and no y produces x = −1, so nothing else is removed

(a) [3, ∞)[3,\ \infty) · (b) R∖{2}\mathbb{R} \setminus \{2\}, matching the horizontal asymptote y=2y = 2 on the rational functions page

Piecewise functions

A piecewise function uses different formulas on different intervals of x. Real examples are everywhere: tiered electricity prices, postage by weight, income tax bands. When evaluating, decide which interval x is in first, and watch the < and ≤ signs at each boundary. The absolute value ∣x∣|x| and the floor function ⌊x⌋\lfloor x \rfloor are piecewise functions too.

F5 Piecewise & floor

f(x)={f1(x),x<cf2(x),x≥c⌊x⌋=max⁡{n∈Z:n≤x}f(x) = \begin{cases} f_1(x), & x < c \\ f_2(x), & x \ge c \end{cases}\qquad \lfloor x \rfloor = \max\{n \in \mathbb Z : n \le x\}

⌊2.7⌋=2\lfloor 2.7 \rfloor = 2 · ⌊−2.7⌋=−3\lfloor -2.7 \rfloor = -3 (not −2)

Example F-4 · Evaluating a piecewise function

f(x)={x2,x<12x−1,1≤x≤35,x>3f(x) = \begin{cases} x^2, & x < 1 \\ 2x - 1, & 1 \le x \le 3 \\ 5, & x > 3 \end{cases} Find f(−2),f(1),f(3),f(4)f(-2), f(1), f(3), f(4) and say whether the pieces join

  1. f(−2)f(-2): −2 < 1, use x2x^2: 4 · f(1)f(1): second line, 2(1)−1=12(1) - 1 = 1

  2. f(3)=2(3)−1=5f(3) = 2(3) - 1 = 5 · f(4)=5f(4) = 5

  3. At x = 1 the left piece approaches 12=1=f(1)1^2 = 1 = f(1) · at x = 3 the right piece is 5 = f(3), so both joins are seamless

4, 1, 5, 54,\ 1,\ 5,\ 5, continuous at both joins

Sum, difference, product and quotient

Two functions combine by adding, subtracting, multiplying or dividing their values at the same x. The catch is the domain: the result is defined only where both f and g are defined, and a quotient must also exclude the points where g is zero, even if the simplified formula hides the denominator.

F6 Operations

(f±g)(x)=f(x)±g(x),(fg)(x)=f(x)g(x),(fg)(x)=f(x)g(x)(f \pm g)(x) = f(x) \pm g(x),\quad (fg)(x) = f(x)g(x),\quad \left(\tfrac{f}{g}\right)(x) = \tfrac{f(x)}{g(x)}

Domain =Df∩Dg= D_f \cap D_g, and for f/gf/g remove {x:g(x)=0}\{x : g(x) = 0\}

Composite functions

Composition connects two machines so that the output of the first becomes the input of the second. (f∘g)(x)(f \circ g)(x), read “f composed with g”, means f(g(x))f(g(x)): do g first, then f, even though f is written first. Its domain has two layers: x must be allowed in g, and g(x) must be allowed in f. Simplifying the final formula can hide the first layer, which is exactly where exam questions set their traps.

F7 Composition

(f∘g)(x)=f(g(x)),Df∘g={ x∈Dg:g(x)∈Df }(f \circ g)(x) = f\big(g(x)\big),\qquad D_{f\circ g} = \{\,x \in D_g : g(x) \in D_f\,\}

In general f∘g≠g∘ff \circ g \ne g \circ f · but always (f∘g)∘h=f∘(g∘h)(f \circ g) \circ h = f \circ (g \circ h)

Example F-5 · f∘g and g∘f

With f(x)=x+2f(x) = \sqrt{x + 2} and g(x)=x2−1g(x) = x^2 - 1, find f∘gf \circ g and g∘fg \circ f with their domains

  1. (f∘g)(x)=f(x2−1)=x2+1(f \circ g)(x) = f(x^2 - 1) = \sqrt{x^2 + 1}; since x2+1>0x^2 + 1 > 0 always, the domain is R\mathbb R

  2. (g∘f)(x)=(x+2)2−1=x+1(g \circ f)(x) = \left(\sqrt{x + 2}\right)^2 - 1 = x + 1

  3. But x must go through f first, so x≥−2x \ge -2, even though x+1x + 1 makes sense for every x

f∘g=x2+1, x∈Rf \circ g = \sqrt{x^2 + 1},\ x \in \mathbb R · g∘f=x+1, x≥−2g \circ f = x + 1,\ x \ge -2

Example F-6 · Decomposing a function

Write H(x)=(3x−1)5H(x) = (3x - 1)^5 as f(g(x))f(g(x))

  1. The step done first is 3x−13x - 1, so g(x)=3x−1g(x) = 3x - 1

  2. The step done last is raising to the fifth power: f(x)=x5f(x) = x^5

g(x)=3x−1, f(x)=x5g(x) = 3x - 1,\ f(x) = x^5 — seeing functions this way is the heart of the chain rule

Average rate of change and the difference quotient

The average rate of change says how much y changes, on average, per unit of x. If f is distance against time, it is the average speed. Graphically it is the slope of the line through two points of the graph, the secant line. The difference quotient is the same expression written with a step h, and it becomes the definition of the derivative when h shrinks to zero.

F8 Average rate of change

ΔyΔx=f(b)−f(a)b−a\frac{\Delta y}{\Delta x} = \frac{f(b) - f(a)}{b - a}

F9 Difference quotient

f(x+h)−f(x)h,h≠0 → h→0  f′(x)\frac{f(x + h) - f(x)}{h},\quad h \ne 0 \ \xrightarrow{\ h \to 0\ }\ f'(x)
Example F-7 · Difference quotient

Find the difference quotient of f(x)=x2−3xf(x) = x^2 - 3x, and the average rate of change of x+2\sqrt{x + 2} from x = −1 to x = 2

  1. f(x+h)=x2+2xh+h2−3x−3hf(x + h) = x^2 + 2xh + h^2 - 3x - 3h; subtracting f(x)f(x) leaves 2xh+h2−3h2xh + h^2 - 3h

  2. Divide by h: 2x+h−32x + h - 3 (as h → 0 this becomes 2x−32x - 3, the derivative)

  3. −1+2=1\sqrt{-1 + 2} = 1, 2+2=2\sqrt{2 + 2} = 2, so 2−12−(−1)=13\dfrac{2 - 1}{2 - (-1)} = \dfrac13

2x+h−32x + h - 3 · 13\tfrac13

Function lab: type f and g

Type functions the usual way, for example 2x^2-3, 1/(x-1), sqrt(4-x^2), |x| or log(x) (base 10), then choose to plot f, g, their sum, product, quotient or a composition. Grey bands mark the x-values where the function is undefined, which checks a domain answer instantly. Move x₁ and x₂ to see the secant line and the average rate of change.

Common trapsReading the domain of g∘fg \circ f from the final formula alone: in Example F-5 the formula x+1x + 1 looks defined everywhere, but x must pass through x+2\sqrt{x + 2} first. Another is writing f(x+h)=f(x)+hf(x + h) = f(x) + h, which is true only for special functions.

Practice (with answers)

1Is {(1, 2), (2, 3), (1, 4)} a function?

x = 1 is paired with both 2 and 4

No

2Domain of f(x)=15−xf(x) = \dfrac{1}{\sqrt{5 - x}}

The root is in a denominator, so it must be strictly positive: 5−x>05 - x > 0

(−∞, 5)(-\infty,\ 5)

3Range of f(x)=3−x−1f(x) = 3 - \sqrt{x - 1}

x−1≥0\sqrt{x - 1} \ge 0, so f(x)≤3f(x) \le 3

(−∞, 3](-\infty,\ 3]

4f(x)=2x+1, g(x)=x2f(x) = 2x + 1,\ g(x) = x^2: find (f∘g)(3)(f \circ g)(3) and (g∘f)(3)(g \circ f)(3)

f(9)=19f(9) = 19 · g(7)=49g(7) = 49

19 and 49

5If f(x)=3x−2f(x) = 3x - 2 and f(g(x))=6x+7f(g(x)) = 6x + 7, find g(x)g(x)

3g(x)−2=6x+7⇒g(x)=2x+33g(x) - 2 = 6x + 7 \Rightarrow g(x) = 2x + 3

g(x)=2x+3g(x) = 2x + 3

6Difference quotient of f(x)=1xf(x) = \dfrac1x

1x+h−1xh=−1x(x+h)\dfrac{\frac{1}{x+h} - \frac1x}{h} = \dfrac{-1}{x(x + h)}

−1x(x+h)-\dfrac{1}{x(x + h)}

Read next

Frequently asked questions

What is the difference between a relation and a function?

A relation is any set of ordered pairs. A function is a relation in which each x is paired with exactly one y. If the same x appears with two different y-values, for example (2, 3) and (2, 5), it is not a function. On a graph, check with the vertical line test: if some vertical line meets the graph more than once, it is not a function.

How do I find the domain of a function?

Look for the three things that break a real-valued formula: a denominator that could be zero, an even root of a negative number, and a logarithm of a number that is not positive. Write a condition for each and intersect them. If none of the three appears, the domain is all real numbers.

Is f∘g the same as g∘f?

Usually not. f∘g means apply g first and feed the result into f. With f(x) = √(x + 2) and g(x) = x² − 1, f∘g = √(x² + 1) but g∘f = x + 1 for x ≥ −2: both the formula and the domain differ. The domain of f∘g is the set of x in the domain of g for which g(x) lies in the domain of f.

How is the average rate of change related to calculus?

The average rate of change (f(b) − f(a))/(b − a) is the slope of the secant line through two points of the graph. As b approaches a, the secant line turns into the tangent line and its slope is the derivative. The difference quotient (f(x + h) − f(x))/h practised here is exactly the definition of the derivative as h → 0.

Ajarn Mod · Teerawut Savangboon
Lecturer in Electrical Engineering, Dhonburi Rajabhat University, Samut Prakan · Profile