Complicated functions are usually built from simple ones. A company's profit is revenue minus cost; the area of a spreading oil spill depends on its radius, which depends on time. This lesson covers the two ways to build new functions from old ones, arithmetic combinations and composition, and the part students most often skip: working out the domain of the result.
Sums, differences, products and quotients
Given two functions f and g, you can combine their outputs input by input:
To compute (f+g)(x) at some input, you need bothf(x) and g(x) to exist. So the domain of f+g, f−g and fg is the set of inputs in both domains, the intersection. A quotient has one extra condition: the denominator can't be zero.
Domains of combined functions
f+g, f−g, fg: all x in the domain of fand in the domain of g.
gf: the same, andg(x)=0.
Find the domain from the original functions, before simplifying. Simplifying can hide a restriction.
Worked example: A quotient and its domain
Let f(x)=x+3 and g(x)=x−1. Find (fg)(6) and the domain of gf.
(fg)(6)=f(6)g(6)=9⋅5=15.
The domain of f is x≥−3. The domain of g is all real numbers. For the quotient, also exclude g(x)=0, which happens at x=1. The domain of gf is
[−3,1)∪(1,∞)
Composition
Composition feeds the output of one function into another.
Definition
Composition
The composition of f with g is
(f∘g)(x)=f(g(x))
Read it as "f of g of x." The function written on the right, g, acts first; its output becomes the input of f.
Think of an assembly line: x enters machine g, the product g(x) comes out and goes straight into machine f. To find a formula for f(g(x)), substitute the entire expression g(x) for every x in the rule for f.
Worked example: Composing in both orders
Let f(x)=x2+1 and g(x)=2x−3. Find f(g(x)), g(f(x)) and f(g(2)).
The two results are different: composition is not commutative.
For a single value, work from the inside out: g(2)=1, then f(1)=2. So f(g(2))=2. (Check with the formula: 4(4)−24+10=2.)
Common mistake
f(g(x)) is not the product f(x)g(x). The small circle in f∘g means composition, not multiplication. For the functions above, f(x)g(x)=(x2+1)(2x−3), which is a cubic, while f(g(x)) is a quadratic.
The domain of a composition
For f(g(x)) to exist, two things must happen in order:
x must be in the domain of g, so that g(x) exists.
g(x) must be in the domain of f, so that f can accept it.
The simplified formula alone can mislead you. For example, if g(x)=x and f(x)=x2, then f(g(x))=(x)2=x, which looks defined everywhere. But g can't accept negative inputs, so the domain of f∘g is only x≥0.
Worked example: Domains of compositions
Let f(x)=x−21 and g(x)=x. Find the domains of f∘g and g∘f.
f(g(x))=x−21. First, g needs x≥0. Then f can't accept the input 2, so we need x=2, which means x=4. Domain: [0,4)∪(4,∞).
g(f(x))=x−21. First, f needs x=2. Then g needs its input to be nonnegative: x−21≥0. A fraction with numerator 1 is never 0, and it is positive exactly when x−2>0. Domain: (2,∞).
f(g(x)) exists only for x ≥ 0 and breaks at x = 4; g(f(x)) exists only for x > 2.Open in grapher →
Compositions from tables and graphs
You don't need formulas to compose. Given a table or a graph, evaluate from the inside out, one step at a time.
Worked example: Composing with a table
Use the table to find f(g(1)), g(f(3)) and (f∘f)(2).
x
0
1
2
3
4
f(x)
2
4
3
0
1
g(x)
3
0
4
1
2
g(1)=0, then f(0)=2. So f(g(1))=2.
f(3)=0, then g(0)=3. So g(f(3))=3.
f(2)=3, then f(3)=0. So (f∘f)(2)=0.
Decomposing a function
Going backward is just as useful, especially in calculus: given a complicated function h, find an inner function g and an outer function f with h(x)=f(g(x)). Look for the "inside" expression that is being plugged into something.