Domain of a composition
A composition runs a number through one function and then another. Which starting numbers make it all the way through?
Where you are 5 in Combining and composing functions
Why this exists
A composition f(g(x)) is a two-step calculation: work out g(x), then feed the answer to f. In composing functions algebraically the two steps were merged into one formula. Every function, though, comes with its inputs as well as its rule, and the merged formula does not say which inputs belong to the composition. Worse, it can say the wrong thing: \displaystyle (\sqrt{x})^2 simplifies to x, which accepts x = -4, although \displaystyle \sqrt{-4} is not a real number and the chain never got started.
The domain of a combination such as f + g or \displaystyle \frac{f}{g} was found by looking at both functions at the same input. A composition is different, because the second function never sees the input at all. It sees the output of the first one. So a second question appears: not “is this number allowed into f?” but “does g turn this number into something allowed into f?” This lesson collects the inputs that pass both tests.
Definition
The domain of the composition f \circ g is the set of inputs x for which the whole chain works: x is an input that g accepts, and the output g(x) is an input that f accepts.
In set notation, writing \operatorname{dom} g for the domain of g:
When a function is given only by a formula, its domain is understood to be every real number at which the formula gives a real number: no division by zero, and no even root of a negative number. When a function describes a situation, the situation can shrink its domain further (a time before the start, a negative length, half a person).
Intuition
Think of the composition as a road with two gates. The first gate is the domain of g: an input that g cannot handle is turned away at once. The inputs that pass are changed by g into outputs, and those outputs arrive at the second gate, the domain of f. An output that f cannot handle is turned away there, and the input it came from is lost with it.
Take \displaystyle g(x) = \sqrt{x + 1} and f(x) = \dfrac{1}{x - 3}. The first gate needs x + 1 \ge 0, so x \ge -1. Those inputs become the outputs \displaystyle \sqrt{x + 1}, which are the numbers 0 and above. The second gate refuses exactly one number, 3, because \displaystyle f(3) = \frac{1}{0}. So the question at the second gate is which input g sends to 3. Solving \displaystyle \sqrt{x + 1} = 3 gives x + 1 = 9, so x = 8.
The composition therefore accepts every x \ge -1 except x = 8:
Notice what the second gate does not ask. It does not ask whether x itself is in the domain of f. The number 3 is not in the domain of f, yet it is a perfectly good input to the composition: g(3) = 2 and f(2) = 1. What f receives is g(3), never 3.
The graph shows both gates as gaps. There is no graph to the left of x = -1, and at x = 8 the bottom of the fraction \displaystyle \sqrt{x + 1} - 3 is zero, so the graph shoots off along the vertical line x = 8 without ever touching it.
Results
The domain of a composition. For functions f and g,
In particular:
- The domain of f \circ g always sits inside the domain of g.
- It need not sit inside the domain of f: an input refused by f can still be accepted by the composition, because f only ever receives outputs of g.
- If f accepts every real number, the domain of f \circ g is just the domain of g. If g accepts every real number, it is the set of x with g(x) \in \operatorname{dom} f.
- The domain can be empty, when no output of g lies in the domain of f.
Simplifying keeps the values, not the domain. If f(g(x)) simplifies to a formula h(x), then f(g(x)) = h(x) at every x in \operatorname{dom}(f \circ g), but the formula h(x) may also give values at inputs outside that domain. The domain is read from f and g before simplifying, never from the simplified formula alone.
Why it is true
To evaluate f(g(a)) at a number a there are two calculations, done in order. The first is g(a), and it gives a real number exactly when a \in \operatorname{dom} g. If it fails, there is nothing to hand to f, and f(g(a)) has no value. If it succeeds, the second calculation is f applied to the number g(a), and that gives a real number exactly when g(a) \in \operatorname{dom} f. The composition has a value at a exactly when both calculations succeed, which is the condition in the definition. The input a itself is never handed to f, so whether a is in the domain of f plays no part.
For the simplified formula: each simplifying step (canceling a factor, squaring a square root, clearing a fraction inside a fraction) is an equation that holds wherever both sides have values. So the simplified h(x) agrees with f(g(x)) on \operatorname{dom}(f \circ g). But a step such as \displaystyle (\sqrt{u})^2 = u or \displaystyle \frac{u}{u} = 1 removes the very expression that made some input fail, and after it the formula no longer remembers that the input was refused.
Worked examples
The two gates, with numbers
Let f(x) = \dfrac{1}{x - 3} and \displaystyle g(x) = \sqrt{x + 1}. Write f(g(x)), find the domain of f \circ g, and evaluate the composition at x = 0, x = 24 and x = -5 where it has a value.
SolutionSubstituting g(x) for the input of f gives
First gate: g needs x + 1 \ge 0, so \operatorname{dom} g = [-1, \infty). Second gate: f refuses only the input 3, so remove every x with g(x) = 3. From \displaystyle \sqrt{x + 1} = 3, squaring gives x + 1 = 9, so x = 8. Squaring can bring in a false solution, so check: \displaystyle \sqrt{9} = 3, true. The domain is [-1, 8) \cup (8, \infty).
Values, inside first: g(0) = 1 and \displaystyle f(1) = \frac{1}{-2} = -\frac{1}{2}; the formula gives \displaystyle \frac{1}{1 - 3} = -\frac{1}{2} as well. g(24) = 5 and \displaystyle f(5) = \frac{1}{2}. At x = -5 there is no value: \displaystyle g(-5) = \sqrt{-4} is not a real number, so the chain stops at the first gate.
The other order, and a sign chart
With the same f(x) = \dfrac{1}{x - 3} and \displaystyle g(x) = \sqrt{x + 1}, find the domain of g \circ f.
SolutionNow f is inside: \displaystyle g(f(x)) = \sqrt{\dfrac{1}{x - 3} + 1}.
First gate: f needs x \ne 3. Second gate: g accepts an input u only when u + 1 \ge 0, and here u = f(x), so the condition is
Writing the left side over the common denominator x - 3 gives \displaystyle \frac{1 + (x - 3)}{x - 3} = \frac{x - 2}{x - 3}, so the condition is \displaystyle \frac{x - 2}{x - 3} \ge 0. A fraction changes sign only where its top or bottom is zero, here at x = 2 and x = 3, so test one number in each piece of the line:
| x | x - 2 | x - 3 | \displaystyle \frac{x - 2}{x - 3} |
|---|---|---|---|
| x < 2 | negative | negative | positive |
| 2 < x < 3 | positive | negative | negative |
| x > 3 | positive | positive | positive |
At x = 2 the fraction is 0, which is allowed, since \displaystyle \sqrt{0} = 0. At x = 3 it has no value, and 3 was refused at the first gate anyway. So
Check an input that is refused: \displaystyle f(2.5) = \frac{1}{-0.5} = -2, and \displaystyle g(-2) = \sqrt{-1} is not a real number. And one that is accepted: f(2) = -1 and \displaystyle g(-1) = \sqrt{0} = 0.
The two orders have quite different domains, because each order puts a different function at each gate.
A function composed with itself
With f(x) = \dfrac{1}{x - 3}, find the domain of f \circ f. Then simplify f(f(x)) and say which excluded input the simplified formula forgets.
SolutionFirst gate: x \ne 3. Second gate: f(x) must not equal 3. From \displaystyle \frac{1}{x - 3} = 3, multiplying both sides by x - 3 gives 1 = 3(x - 3), so \displaystyle x - 3 = \frac{1}{3} and \displaystyle x = \frac{10}{3}. The domain is every real number except 3 and \displaystyle \frac{10}{3}.
To simplify, multiply the top and bottom of the fraction inside a fraction by x - 3, which is allowed because x \ne 3 on the domain:
The simplified formula still refuses \displaystyle x = \frac{10}{3}, where its bottom is zero. But at x = 3 it gives \displaystyle \frac{0}{1} = 0, while the composition has no value there, since f(3) does not exist. So \displaystyle f(f(x)) = \frac{x - 3}{10 - 3x} only for x \ne 3, and that condition has to be written beside the formula. Check at x = 4: f(4) = 1 and \displaystyle f(1) = -\frac{1}{2}, while \displaystyle \frac{4 - 3}{10 - 12} = -\frac{1}{2}.
An input refused by the outer function
Let \displaystyle f(x) = \sqrt{x - 6} and g(x) = x^2 + 2. Find the domain of f \circ g, and show that it contains a number that is not in the domain of f.
Solutiong accepts every real number, so the first gate lets everything through. f accepts an input u only when u - 6 \ge 0, and here u = x^2 + 2, so the condition is x^2 + 2 \ge 6, that is x^2 \ge 4. A square is at least 4 exactly when the number is at least 2 away from zero, so
The formula is \displaystyle f(g(x)) = \sqrt{x^2 - 4}, which agrees.
The domain of f is [6, \infty), and -3 is not in it: \displaystyle f(-3) = \sqrt{-9} is not real. Yet -3 is in the domain of f \circ g, since g(-3) = 11 and \displaystyle f(11) = \sqrt{5}. The squaring in g turns a negative input into a large positive output before f ever sees it. At the edge, g(2) = 6 and f(6) = 0, so 2 is included.
Domains from tables
Two functions are given only by tables, and each is defined at the inputs listed and nowhere else.
| x | -2 | -1 | 0 | 1 | 2 | 3 |
|---|---|---|---|---|---|---|
| g(x) | 5 | 3 | 1 | 0 | 4 | 7 |
| x | 0 | 1 | 2 | 4 | 5 |
|---|---|---|---|---|---|
| f(x) | 2 | -1 | 6 | 3 | 0 |
Find the domain of f \circ g and its values, then the domain of g \circ f.
SolutionFor f \circ g, go along the g table and keep each x whose output is in the top row of the f table, \{0, 1, 2, 4, 5\}. g(-2) = 5, kept. g(-1) = 3, refused, since f(3) is not in the table. g(0) = 1, kept. g(1) = 0, kept. g(2) = 4, kept. g(3) = 7, refused. So \operatorname{dom}(f \circ g) = \{-2, 0, 1, 2\}, with values f(g(-2)) = f(5) = 0, f(g(0)) = f(1) = -1, f(g(1)) = f(0) = 2 and f(g(2)) = f(4) = 3.
For g \circ f, go along the f table and keep each x whose output is an input of g, that is in \{-2, -1, 0, 1, 2, 3\}. f(0) = 2, kept. f(1) = -1, kept. f(2) = 6, refused. f(4) = 3, kept. f(5) = 0, kept. So \operatorname{dom}(g \circ f) = \{0, 1, 4, 5\}, with values g(2) = 4, g(-1) = 3, g(3) = 7 and g(0) = 1.
A shrinking patch of frost
When the sun reaches a window, a round patch of frost on it shrinks. Its radius t minutes later is r(t) = 12 - 0.5t centimeters, and a circle of radius r centimeters has area A(r) = \pi r^2 square centimeters. Find A(r(t)), its domain in this setting, and the area after 8 minutes.
Solutionr turns a time into a radius and A takes a radius, so r is inside:
As a bare formula this has a value at every real t. The setting supplies the gates. The model starts when the sun arrives, so t \ge 0. A radius cannot be negative, so the area function only accepts r \ge 0, and the second gate needs 12 - 0.5t \ge 0, that is t \le 24. At t = 24 the patch has shrunk to a point and gone. So the domain is 0 \le t \le 24, the interval [0, 24]. Outside it the formula still produces numbers, such as \pi(12 - 15)^2 = 9\pi at t = 30, but they come from a radius of -3 centimeters and describe nothing.
After 8 minutes, r(8) = 8 and A(8) = 64\pi \approx 201.1 square centimeters.
Choosing a constant so that every input works
Let \displaystyle f(x) = \sqrt{x} and g(x) = x^2 - 8x + c, where c is a constant. (a) For which values of c is the domain of f \circ g every real number? (b) Find the domain when c = 7.
Solution(a) g accepts every real number, so the only gate is the second: x^2 - 8x + c \ge 0. Completing the square,
and (x - 4)^2 is never negative and equals 0 at x = 4. So the smallest output of g is c - 16, at x = 4. Every input passes exactly when that smallest output is at least 0, that is when c \ge 16.
(b) With c = 7 the condition is (x - 4)^2 - 9 \ge 0, so (x - 4)^2 \ge 9. That holds when x - 4 \ge 3 or x - 4 \le -3, so the domain is (-\infty, 1] \cup [7, \infty). Check: g(1) = 1 - 8 + 7 = 0 and f(0) = 0, while g(4) = -9 and \displaystyle \sqrt{-9} is not real.
Boundaries
Read the domain before simplifying. A simplified formula can accept inputs the composition refuses, as x = 3 in Example 3 and x = -4 in \displaystyle (\sqrt{x})^2 show. The domain comes from \operatorname{dom} g and \operatorname{dom} f; the simplified formula is then valid on that domain and no further.
The outer function judges outputs, not inputs. Whether x is in the domain of f says nothing about whether it is in the domain of f \circ g (Example 4). Only g(x) is ever handed to f.
Each order has its own domain. f \circ g and g \circ f put different functions at the two gates, and their domains usually differ (Examples 1 and 2).
The domain can be empty. If no output of g is an input of f, the composition has no inputs at all. With \displaystyle f(x) = \sqrt{x - 7} and g(x) = 5 - x^2, every output of g is at most 5, so f refuses all of them.
A setting adds its own gates. For a function describing a situation, the formula’s domain is only an upper limit. Times before the start, negative lengths and fractional counts are refused too, at whichever stage they appear (Example 6).
Real numbers only. Throughout, a value has to be a real number, so an even root of a negative number counts as no value. With complex numbers allowed, the square root gates would open.
Where this goes next
Domains decide when two functions undo each other. Two functions are inverses when f(g(x)) = x for every x in the domain of g and g(f(x)) = x for every x in the domain of f, so checking a pair means checking the domains too: \displaystyle (\sqrt{x})^2 = x holds only for x \ge 0, which is why the inverse of y = x^2 needs its domain cut down first. Finding an inverse algebraically keeps track of exactly this.
The same two-gate reasoning gives the domains of more involved formulas. A function such as \displaystyle \frac{1}{\sqrt{x - 2}} is a chain of three simple functions, and its domain is found gate by gate (Exercise 10). In calculus, f \circ g is continuous at a when g is continuous at a and f is continuous at g(a), the same two gates asked about continuity, and the chain rule gives the rate of change of f(g(x)) at the inputs where both steps work.
Exercises
Domains from formulas
For each pair, find the stated composition and its domain.
- f(x) = \dfrac{2}{x - 5} and g(x) = x^2 - 4: find f \circ g.
- The same f and g as in Exercise 1: find g \circ f.
- \displaystyle f(x) = \sqrt{x + 2} and g(x) = 3x - 7: find f \circ g.
- The same f and g as in Exercise 3: find g \circ f.
- f(x) = \dfrac{1}{x} and \displaystyle g(x) = \sqrt{9 - x}: find f \circ g.
- \displaystyle f(x) = \sqrt{x} and g(x) = \dfrac{1}{x - 6}: find f \circ g.
- \displaystyle f(x) = \sqrt{x - 1} and g(x) = x^2 - 8: find f \circ g.
- \displaystyle f(x) = \sqrt{16 - x} and g(x) = x^2: find f \circ g.
- f(x) = \dfrac{1}{x - 1} and g(x) = \dfrac{4}{x + 3}: find f \circ g, simplify it to a single fraction, and give its domain.
- f(x) = \dfrac{1}{x}, \displaystyle g(x) = \sqrt{x} and h(x) = x - 2: find f(g(h(x))) and its domain.
When simplifying hides an exclusion
- f(x) = x^2 and \displaystyle g(x) = \sqrt{2x - 3}. Simplify f(g(x)), give the domain of f \circ g, and say whether x = 0 belongs to it.
- f(x) = \dfrac{6}{x} and g(x) = \dfrac{1}{x + 2}. Simplify f(g(x)) and give the domain of f \circ g. Explain why the second gate removes nothing.
Domains from tables
Each function is defined at the listed inputs only.
| x | -1 | 0 | 1 | 2 | 3 |
|---|---|---|---|---|---|
| g(x) | 2 | 6 | -3 | 0 | 4 |
| x | 0 | 2 | 4 | 5 |
|---|---|---|---|---|
| f(x) | 1 | -2 | 7 | 3 |
- Find the domain of f \circ g.
- Find f(g(x)) at each input in that domain.
- Find the domain of g \circ f and the value of g(f(x)) at each input in it.
In context
- A candle 20 centimeters tall burns so that its height after t hours is h(t) = 20 - 2.5t centimeters, and a candle of height h centimeters holds V(h) = 12h cubic centimeters of wax. Find V(h(t)), its domain in this setting, and the volume after 6 hours.
- A boat trip costs 600 dollars, shared equally by the people who pay. In a group of k people, two are guides who ride free, so n(k) = k - 2 people pay, and each pays C(n) = \dfrac{600}{n} dollars. Find C(n(k)), say which values of k make sense, and find the share in a group of 8.
Reasoning
- Let \displaystyle f(x) = \sqrt{x} and g(x) = x^2 + 4x + c. Find every value of c for which the domain of f \circ g is every real number, and explain why.
- Let \displaystyle f(x) = \sqrt{x - 7} and g(x) = 5 - x^2. Explain why f \circ g has no inputs at all, and whether g \circ f has any.
- Explain why the domain of f \circ g always lies inside the domain of g, but need not lie inside the domain of f. Give an example of your own for the second part.
- Bertrand composes f(x) = \dfrac{1}{x} with itself, simplifies to f(f(x)) = x, and says the domain of f \circ f is every real number. Explain what is wrong, and give the correct domain.
Answers
- \displaystyle f(g(x)) = \frac{2}{x^2 - 9}, domain every real number except -3 and 3. g accepts all x; the second gate refuses g(x) = 5, and x^2 - 4 = 5 gives x^2 = 9.
- \displaystyle g(f(x)) = \frac{4}{(x - 5)^2} - 4, domain every real number except 5. The first gate needs x \ne 5, and g accepts every output.
- \displaystyle f(g(x)) = \sqrt{3x - 5}, domain \displaystyle \left[\frac{5}{3}, \infty\right). The second gate needs 3x - 7 + 2 \ge 0, so 3x \ge 5.
- \displaystyle g(f(x)) = 3\sqrt{x + 2} - 7, domain [-2, \infty). The first gate needs x + 2 \ge 0, and g accepts every output.
- \displaystyle f(g(x)) = \frac{1}{\sqrt{9 - x}}, domain (-\infty, 9). The first gate needs x \le 9; the second refuses g(x) = 0, which happens only at x = 9.
- \displaystyle f(g(x)) = \sqrt{\frac{1}{x - 6}}, domain (6, \infty). The first gate needs x \ne 6; the second needs \displaystyle \frac{1}{x - 6} \ge 0, and a fraction with top 1 is positive exactly when its bottom is, so x > 6.
- \displaystyle f(g(x)) = \sqrt{x^2 - 9}, domain (-\infty, -3] \cup [3, \infty). The second gate needs x^2 - 8 \ge 1, so x^2 \ge 9.
- \displaystyle f(g(x)) = \sqrt{16 - x^2}, domain [-4, 4]. The second gate needs x^2 \le 16.
- \displaystyle f(g(x)) = \frac{x + 3}{1 - x}, domain every real number except -3 and 1. The first gate refuses x = -3; the second refuses \displaystyle \frac{4}{x + 3} = 1, so x + 3 = 4 and x = 1. Simplifying, \displaystyle \frac{1}{\frac{4}{x + 3} - 1} times \displaystyle \frac{x + 3}{x + 3} is \displaystyle \frac{x + 3}{4 - (x + 3)} = \frac{x + 3}{1 - x}, which forgets that -3 was refused.
- \displaystyle f(g(h(x))) = \frac{1}{\sqrt{x - 2}}, domain (2, \infty). h accepts every x; g needs x - 2 \ge 0; f refuses \displaystyle \sqrt{x - 2} = 0, which happens at x = 2.
- f(g(x)) = 2x - 3, but the domain of f \circ g is \displaystyle \left[\frac{3}{2}, \infty\right), so x = 0 does not belong: \displaystyle g(0) = \sqrt{-3} is not real, even though 2(0) - 3 = -3 looks fine.
- f(g(x)) = 6x + 12, domain every real number except -2. \displaystyle \frac{6}{1/(x + 2)} = 6(x + 2). The first gate refuses x = -2. The second refuses g(x) = 0, but a fraction with top 1 is never 0, so it removes nothing.
- \{-1, 2, 3\}. The inputs of f are 0, 2, 4, 5; g(-1) = 2, g(2) = 0 and g(3) = 4 are among them, while g(0) = 6 and g(1) = -3 are not.
- f(g(-1)) = f(2) = -2, f(g(2)) = f(0) = 1 and f(g(3)) = f(4) = 7.
- \{0, 5\}, with g(f(0)) = g(1) = -3 and g(f(5)) = g(3) = 4. The inputs of g are -1, 0, 1, 2, 3; f(0) = 1 and f(5) = 3 are among them, while f(2) = -2 and f(4) = 7 are not.
- V(h(t)) = 240 - 30t, domain [0, 8], and 60 cubic centimeters after 6 hours. 12(20 - 2.5t) = 240 - 30t. Time starts at t = 0, and the height must not be negative, 20 - 2.5t \ge 0, so t \le 8. At t = 6: 240 - 180 = 60.
- \displaystyle C(n(k)) = \frac{600}{k - 2}, which makes sense for k = 3, 4, 5 and so on (up to what the boat holds): k counts people, and at least one person must pay, since k = 2 would divide by zero. A group of 8 has 6 payers, each paying \displaystyle \frac{600}{6} = 100 dollars.
- c \ge 4. Completing the square, x^2 + 4x + c = (x + 2)^2 + (c - 4), whose smallest value is c - 4, at x = -2. Every output of g is at least 0 exactly when c - 4 \ge 0.
- Every output of g is 5 - x^2 \le 5, because x^2 \ge 0, while f accepts only inputs of at least 7. No output of g passes the second gate, so f \circ g has an empty domain. The other order does have inputs: f accepts x \ge 7 and g accepts every real number, so g \circ f has domain [7, \infty), with g(f(x)) = 5 - (x - 7) = 12 - x there.
- To evaluate f(g(x)), g(x) must be worked out first, so an input outside the domain of g never gets started; that puts every input of f \circ g inside the domain of g. But f is applied to g(x), not to x, so x need not be an input of f. Example: \displaystyle f(x) = \sqrt{x} and g(x) = -x. Then -4 is not in the domain of f, but g(-4) = 4 and f(4) = 2, so -4 is in the domain of f \circ g, which is (-\infty, 0].
- The simplified formula x accepts 0, but the composition does not: \displaystyle f(0) = \frac{1}{0} has no value, so the chain stops at the first gate. The second gate removes nothing more, since \displaystyle f(x) = \frac{1}{x} is never 0. The domain is every real number except 0, and f(f(x)) = x holds on that domain only.