Composition of Functions
Why this matters
Imagine you're shopping in Dallas for a new pair of headphones that cost $100. You have two coupons: a "20% off" coupon from the manufacturer and a "10% off" store-wide coupon. You can use both! Does the order you present them at the register matter?
If you apply the 20% off first, then the 10% off, is that the same as applying the 10% off first, then the 20%? This is a real-world composition of functions problem. Each coupon is a function that changes the price. We're plugging the result of one coupon into the function of the next. Today, we'll master this idea of "chaining" functions together.
Concept overview
flowchart LR
subgraph Composition f(g(x))
direction LR
A[Input x = 1] --> B{g(x) = x + 2};
B --> C[Output g(1) = 3];
C --> D{f(x) = x^2};
D --> E[Final Output f(3) = 9];
end
Core explanation
At its heart, function composition is about a sequence of operations. Think of it like an assembly line for numbers. An input value goes into the first machine, gets processed, and the result of that becomes the input for the second machine.
Notation and The "Function Machine"
Let's say we have two functions, f(x) and g(x). The composition of f with g is written as (f ∘ g)(x) or, more commonly, f(g(x)).
(f ∘ g)(x): That little circle∘means "composed with." It is NOT a multiplication sign.f(g(x)): This notation is more intuitive. It shows that the functiong(x)is sitting inside the functionf(x).
In the expression f(g(x)):
g(x)is the inner function. It's the first step in our assembly line.f(x)is the outer function. It's the second step, which acts on the result ofg(x).
The Golden Rule of Composition: Always work from the inside out.
Evaluating Composite Functions (LO 2.7.A)
Let's use our "function machine" example.
- Let the inner function be
g(x) = x + 2. - Let the outer function be
f(x) = x^2.
What is f(g(1))?
- 1Start insideFirst, find the value of the inner function,
g(1).g(1) = 1 + 2 = 3So, our first machine takes in1and spits out3. - 2Use the output as the new inputNow, take that output,
3, and plug it into the outer function,f(x).f(3) = 3^2 = 9Our second machine takes in3and spits out9.
So, f(g(1)) = 9.
We can do this using any representation of a function—equations, tables, or graphs. For a table, you'd find the output of g(1) in its table, then look for that value as an input in f's table.
Does Order Matter?
Let's flip it. What is g(f(1))?
- 1Start insideEvaluate the inner function,
f(1).f(1) = 1^2 = 1 - 2Use the output as the new inputPlug that result into
g(x).g(1) = 1 + 2 = 3
So, g(f(1)) = 3.
The only major exception is the identity function, f(x) = x. This function just returns its input, unchanged. If you compose any function g(x) with f(x) = x, you just get g(x) back. It's like adding 0 or multiplying by 1; it doesn't change the original.
Constructing a New Composite Function (LO 2.7.B)
Sometimes, we need to create a single formula for the entire two-step process. To build the equation for f(g(x)), we substitute the entire expression for the inner function into every instance of the variable in the outer function.
Let's use our same functions: f(x) = x^2 and g(x) = x + 2.
To find the formula for h(x) = f(g(x)):
- Start with the outer function:
f(x) = x^2. - Identify its input variable:
x. - Replace that
xwith the entire inner function,g(x) = x + 2.
So, f(g(x)) = f(x + 2) = (x + 2)^2.
This new function, h(x) = (x + 2)^2, represents the entire assembly line in one step. If we plug x=1 into it, we get h(1) = (1 + 2)^2 = 3^2 = 9, the same answer we got before.
Decomposing Functions (LO 2.7.C)
Decomposition is the reverse process: breaking a complex function down into two or more simpler, "nested" functions. This is a crucial skill for calculus.
Given a function like h(x) = √(4x - 1), how can we write it as h(x) = f(g(x))?
Look for an "inner" operation that's being acted upon by an "outer" operation.
- The expression
4x - 1is inside the square root. This is a good candidate for our inner function. Letg(x) = 4x - 1. - The "outer" operation is taking the square root of something. So, our outer function can be
f(x) = √x.
Let's check: f(g(x)) = f(4x - 1) = √(4x - 1). It works!
There can be multiple ways to decompose a function, but we usually look for the most obvious "inner" piece.
This idea also helps us understand transformations. A horizontal shift like F(x) = (x - 3)^2 is really a composition. If f(x) = x^2 and g(x) = x - 3, then F(x) = f(g(x)). This reframes something you already know in the language of composition.
Worked examples
Evaluating and Constructing from Equations
Problem: Given f(x) = 3x + 5 and g(x) = x^2 - 4.
a) Find f(g(3)).
b) Find g(f(3)).
c) Construct an analytic representation of f(g(x)).
Solution:
Part a) Find f(g(3))
Remember, we work from the inside out.
- Evaluate the inner function
g(3):g(3) = (3)^2 - 4g(3) = 9 - 4 = 5 - Use that output as the input for
f(x): Now we findf(5).f(5) = 3(5) + 5f(5) = 15 + 5 = 20So,f(g(3)) = 20.
Part b) Find g(f(3))
The order is now reversed.
- Evaluate the inner function
f(3):f(3) = 3(3) + 5f(3) = 9 + 5 = 14 - Use that output as the input for
g(x): Now we findg(14).g(14) = (14)^2 - 4g(14) = 196 - 4 = 192So,g(f(3)) = 192. As expected,f(g(3))is not the same asg(f(3)).
Part c) Construct f(g(x))
We need a single formula.
- Start with the outer function
f(x) = 3x + 5. - Identify the input variable
x. - Replace that
xwith the entire expression forg(x), which isx^2 - 4. Use parentheses!f(g(x)) = 3( g(x) ) + 5f(g(x)) = 3(x^2 - 4) + 5 - Simplify the expression:
f(g(x)) = 3x^2 - 12 + 5f(g(x)) = 3x^2 - 7Our new composite function isf(g(x)) = 3x^2 - 7. Self-check: Let's test this withx=3.f(g(3)) = 3(3)^2 - 7 = 3(9) - 7 = 27 - 7 = 20. This matches our answer from Part a!
Decomposing a Function
Problem: Decompose the function h(x) = |2x + 7|^3 into two functions f(x) and g(x) such that h(x) = f(g(x)).
Solution:
Our goal is to find an inner function g(x) and an outer function f(x).
- 1Look for the "innermost" calculationWhat's buried deepest inside the parentheses, absolute values, or radicals? Here, the expression
2x + 7is inside the absolute value bars. This is a great candidate for our inner function. Letg(x) = 2x + 7. - 2Figure out what the outer function is doingOnce we have the result of
g(x), what happens to it? It's put into absolute value bars, and then the result is cubed. So, the outer function takes an input, finds its absolute value, and cubes it. Let's represent the input withx. The function would be|x|^3. So, letf(x) = |x|^3. - 3Check your workLet's compose the
f(x)andg(x)we just found and see if we geth(x)back.f(g(x)) = f(2x + 7)Now, we plug2x + 7into thexoff(x):f(2x + 7) = |(2x + 7)|^3This is exactly our original functionh(x). So our decomposition is correct.
A common wrong turn here is to make the functions too simple or too complex. For example, choosing g(x) = x is not helpful. Another possibility could be g(x) = |2x + 7| and f(x) = x^3. This also works! Often, there's more than one correct answer for decomposition, but you should aim for the most logical split of operations.
Try it yourself
Ready to try one on your own? You've got this.
Problem 1: Let p(t) be the number of people in a store t hours after it opens at 9 AM, given by p(t) = 10t^2 - 5t. Let C(p) be the total dollars in sales when p people are in the store, given by C(p) = 15p.
a) Find and interpret C(p(2)).
b) Construct a function S(t) that gives the total sales t hours after opening.
Hints:
- For part (a), work inside-out. What does
p(2)represent in the real world? - For part (b), you're looking for
C(p(t)). Substitute the entire expression forp(t)into the variablepin the functionC(p).
Problem 2: Decompose the function k(x) = 1 / (x^2 + 3) into two simpler functions f(x) and g(x).
Practice — 8 questions
In simple terms, composition of functions is about plugging the output of one function directly into the input of another, like a two-step assembly line.
- 2.7.A: Evaluate the composition of two or more functions for given values.
- 2.7.B: Construct a representation of the composition of two or more functions.
- 2.7.C: Rewrite a given function as a composition of two or more functions.
- 2.7.A.1
- If f and g are functions, the composite function f ∘ g maps a set of input values to a set of output values such that the output values of g are used as input values of f. For this reason, the domain of the composite function is restricted to those input values of g for which the corresponding output value is in the domain of f . ( f ∘ g)(x) can also be represented as f(g(x)).
- 2.7.A.2
- Values for the composite function f ∘ g can be calculated or estimated from the graphical, numerical, analytical, or verbal representations of f and g by using output values from g as input values for f.
- 2.7.A.3
- The composition of functions is not commutative; that is, f ∘ g and g ∘ f are typically different functions; therefore, f(g(x)) and g(f(x)) are typically different values.
- 2.7.A.4
- If the function f (x) = x is composed with any function g, the resulting composite function is the same as g; that is, g(f(x)) = f(g(x)) = g(x). The function f(x) = x is called the identity function. When composing two functions, the identify function acts in the same way as 0, the additive identity, when adding two numbers and 1, the multiplicative identity, when multiplying two numbers.
- 2.7.B.1
- Function composition is useful for relating two quantities that are not directly related by an existing formula.
- 2.7.B.2
- When analytic representations of the functions f and g are available, an analytic representation of f(g(x)) can be constructed by substituting g(x) for every instance of x in f.
- 2.7.B.3
- A numerical or graphical representation of f ∘ g can often be constructed by calculating or estimating values for (x, f (g(x))).
- 2.7.C.1
- Functions given analytically can often be decomposed into less complicated functions. When properly decomposed, the variable in one function should replace each instance of the function with which it was composed.
- 2.7.C.2
- An additive transformation of a function, f, that results in vertical and horizontal translations can be understood as the composition of g(x) = x + k with f.
- 2.7.C.3
- A multiplicative transformation of a function, f, that results in vertical and horizontal dilations can be understood as the composition of g(x) = kx with f.
flowchart LR
subgraph Composition f(g(x))
direction LR
A[Input x = 1] --> B{g(x) = x + 2};
B --> C[Output g(1) = 3];
C --> D{f(x) = x^2};
D --> E[Final Output f(3) = 9];
end
Read what Saavi narrates
Hey everyone, it's Saavi. Let's talk about one of my favorite topics, because it feels like a puzzle: composition of functions.
Imagine you're shopping for some new headphones. They're a hundred dollars. But you have a twenty percent off coupon, and the store is also having a ten percent off sale. You can use both! But... does the order you use them in matter? Is twenty percent off then ten percent off the same as ten then twenty? That's a composition problem. You're chaining functions together, and we're about to see how that works.
Basically, function composition is creating a new function by using the output of one function as the input for another. It’s like a two-step assembly line.
Let's walk through an example together. Suppose we have two functions. Let's call them f of x equals three x plus five, and g of x equals x squared minus four. And the problem asks us to find f of g of 3.
It looks complicated, but don't get intimidated. The rule is simple: always work from the inside out. The "inside" part here is g of 3. So, let's solve that first. We plug 3 into the g function. g of 3 is 3 squared minus 4, which is 9 minus 4, which gives us 5.
Okay, step one is done. The output was 5. Now, that output becomes the input for our outer function, f. So we take that 5 and plug it into f of x. f of 5 is 3 times 5, plus 5. That's 15 plus 5, which is 20. So, f of g of 3 is 20. See? It's just a two-step process.
A really common mistake I see every year is students confusing composition with multiplication. They see f of g of x and they think it means f of x times g of x. It's an easy mistake to make, but they are totally different. Composition is nesting one function inside another, not multiplying them side-by-side. Always read it as "f OF g of x" to remind yourself.
You're building a new kind of intuition here, seeing how mathematical processes can be linked together. It's a powerful idea that you'll use a lot in the future. You're doing great, keep up the amazing work.
Composition is a process of substitution (nesting), not multiplication. `f(g(3))` means "plug 3 into g, then plug that result into f." `f(3) · g(3)` means "plug 3 into f, plug 3 into g, then multiply the two results." They are completely different operations.
Always read `f(g(x))` as "f of g of x." The "of" signals that one function is inside the other. Use parentheses carefully during substitution to avoid accidentally multiplying.
The notation `f(g(x))` explicitly shows `g(x)` is *inside* `f`. You must evaluate the innermost part of an expression first, just like in the order of operations (PEMDAS).
Always work from the inside out. For `f(g(c))`, your first step is *always* to calculate `g(c)`.
If `f(x) = x^2 - x`, the function `f`'s rule is "take an input, square it, and then subtract the original input." This rule must be applied to the *entire* new input, `g(x)`.
When building `f(g(x))`, do a global "find and replace" for the variable in the outer function. Every single `x` in `f(x)`'s formula must be replaced with the *entire* expression for `g(x)`, wrapped in parentheses. For `f(x) = x^2 - x` and `g(x) = 3x+1`, it becomes `f(g(x)) = (3x+1)^2 - (3x+1)`.
The output of the inner function `g(x)` must be a valid input for the outer function `f(x)`. If `g(2) = -4` and `f(x) = √x`, then `f(g(2))` is `f(-4)`, which is `√-4`. This is undefined in the real number system.
When evaluating `f(g(x))`, first find the output of `g(x)`. Then, pause and check: is this output value in the domain of `f(x)`? If not, the composite function is undefined at that `x`.
While technically `h(x) = h(g(x))` if `g(x) = x`, this doesn't simplify the problem or show any understanding of the function's structure. It's like being asked to give two numbers that multiply to 15 and saying "15 and 1."
When decomposing `h(x)`, look for a meaningful "inner" chunk of algebra being acted on by an "outer" operation (like a square root, a power, or absolute value).