ALGEBRA 1 • MODEL RELATIONSHIPS WITH FUNCTIONS

Compose Two Functions

Learn how to chain two functions together so the output of one becomes the input of the next.

Historical Context & Motivation

Have you ever played a game where one action triggers another, and that result triggers something else? Mathematicians faced a similar challenge centuries ago. They needed a way to connect two separate processes into a single, streamlined rule. The idea of function composition — feeding the output of one function directly into another — became one of the most powerful tools in all of mathematics.

~300 BCE
Euclid's Geometric Chains
Ancient Greek mathematicians like Euclid described multi-step geometric constructions where each step depended on the result of the previous one — an early form of chaining processes together.
1694
Leibniz Introduces 'Function'
Gottfried Wilhelm Leibniz coined the word functio to describe a rule that takes an input and produces an output, laying the groundwork for modern function notation.
1748
Euler's Formal Notation
Leonhard Euler popularized the f(x) notation we use today. With clear notation, mathematicians could easily write one function inside another, such as f(g(x)).
1837
Dirichlet Refines the Definition
Peter Gustav Dirichlet gave the modern definition of a function as a rule that assigns exactly one output to each input. This made it possible to rigorously study what happens when functions are composed.
Today
Composition Everywhere
From computer programming to weather forecasting, function composition is used whenever one process feeds into another. The Common Core standard F-BF.1.c asks you to master this skill.

The central question function composition answers is this: if you already know two separate rules, how can you combine them into a single rule that goes from the very first input all the way to the very last output? That is exactly what you will learn in this lesson.

Core Principles & Definitions

Before you compose functions, you need a solid understanding of four key ideas. Each one builds on the last, so take them in order.

1

A Function Is a Rule

A function takes an input, applies a rule, and gives exactly one output. Think of it like a machine: something goes in, and something comes out.
2

Input & Output

The input (also called the argument) is the value you feed in. The output is the result the function returns after applying its rule.
3

Composition Means Chaining

To compose two functions means the output of the first function becomes the input of the second function. We write this as (f ∘ g)(x) = f(g(x)).
4

Order Matters

f(g(x)) and g(f(x)) are usually not the same. Applying g first and then f gives a different result than applying f first and then g. Always read from the inside out.
KEY TAKEAWAY
Think of function composition like a relay race. The first runner (the inner function) finishes and hands the baton (the output) to the second runner (the outer function). The second runner doesn't start from scratch — they start exactly where the first runner left off. If you switch which runner goes first, the race plays out completely differently!

Visual Explanation — The Function Machine Chain

The diagram below shows how two function "machines" chain together. An input enters the first machine g, which produces an output. That output then slides into the second machine f, which produces the final result. This entire chain is the composed function f(g(x)).

The input x enters machine g (violet), producing g(x). That result is passed to machine f (cyan), which produces the final answer f(g(x)). The green "Baton Pass" box shows where the output of g becomes the input of f.

Notice the direction of the flow: left to right. However, when you write the notation f(g(x)), you read from the inside out. The inner function g is evaluated first, and its result becomes the input for the outer function f. This inside-out reading is the single most important habit to develop when working with composition.

Mathematical Framework

Now let's write the formal definitions and notation so you can work with composition confidently in equations and word problems.

COMPOSITION NOTATION
(f ∘ g)(x) = f(g(x))
The small circle ∘ is the composition operator. Read it as "f composed with g" or "f of g." It means: first apply g to x, then apply f to the result.
REVERSE ORDER
(g ∘ f)(x) = g(f(x))
This means: first apply f to x, then apply g to the result. In general, f(g(x)) ≠ g(f(x)), so order matters.
WEATHER BALLOON EXAMPLE
T(h(t)) = temperature at the balloon's location at time t
Here h(t) gives the height of the balloon at time t, and T(y) gives the temperature at height y. By composing them, T(h(t)) gives the temperature where the balloon actually is at time t — connecting time directly to temperature.
⚠️ Domain Check
For f(g(x)) to make sense, the output of g must be a valid input for f. If g gives you a number that f can't handle (for example, a negative number under a square root), then the composition is not defined at that input. Always check that the range of g fits inside the domain of f.

Detailed Breakdown — Numeric, Algebraic, and Real-World Composition

Function composition shows up in three forms: with specific numbers, with algebraic expressions, and in real-world situations. The diagram below illustrates a numeric example step by step, and the table that follows compares all three forms.

Top row: computing f(g(3)) = f(7) = 49. Bottom row: computing g(f(3)) = g(9) = 19. The red dashed box emphasizes that 49 ≠ 19, proving that the order of composition matters.
Three ways to encounter function composition
FormWhat You DoExample
NumericPlug a specific number into the inner function, get a number, then plug that number into the outer function.f(g(3)): first find g(3) = 7, then f(7) = 49.
AlgebraicReplace the variable in the outer function's formula with the entire expression for the inner function.f(g(x)): replace x in f(x) = x² with (2x + 1) to get (2x + 1)².
Real-WorldIdentify two processes where one's output naturally feeds into the other. Write the composition to model the combined process.h(t) = height at time t, T(y) = temp at height y. Then T(h(t)) = temp at the balloon's location.

Worked Example

Let's walk through a complete problem from start to finish. We will find both f(g(x)) and g(f(x)), simplify each, and verify our answers with a specific number.

Given f(x) = 3x − 5 and g(x) = x + 4, find (f ∘ g)(x) and (g ∘ f)(x).
1
Step 1 — Identify the Inner and Outer Functions for f(g(x))In (f ∘ g)(x) = f(g(x)), the inner function is g and the outer function is f. We will first write out g(x), then substitute it into f.
2
Step 2 — Write g(x)The inner function is g(x) = x + 4. This entire expression will replace every x inside the formula for f.
g(x) = x + 4
3
Step 3 — Substitute g(x) into ff(x) = 3x − 5. Replace the x in f with the expression (x + 4): f(g(x)) = 3(x + 4) − 5.
f(g(x)) = 3(x + 4) − 5
4
Step 4 — SimplifyDistribute the 3: 3 × x + 3 × 4 = 3x + 12. Then subtract 5: 3x + 12 − 5 = 3x + 7.
f(g(x)) = 3x + 7
5
Step 5 — Now find g(f(x))This time f is the inner function. Substitute f(x) = 3x − 5 into g: g(f(x)) = (3x − 5) + 4 = 3x − 1.
g(f(x)) = 3x − 1
6
Step 6 — Verify with x = 2Check f(g(2)): g(2) = 2 + 4 = 6, then f(6) = 3(6) − 5 = 13. Our formula gives 3(2) + 7 = 13. ✓ Check g(f(2)): f(2) = 3(2) − 5 = 1, then g(1) = 1 + 4 = 5. Our formula gives 3(2) − 1 = 5. ✓ Notice that 13 ≠ 5, confirming that order matters.
Both formulas verified!

Common Mistakes & How to Avoid Them

Even after you understand the concept, a few tricky spots can trip you up. The table below lists the most common errors students make with function composition, along with the correct approach.

Common composition mistakes and corrections
Common MistakeWhy It's WrongCorrect Approach
Multiplying the two functions: f(x) × g(x)Composition is substitution, not multiplication. f(g(x)) means plugging g(x) into f, not multiplying their outputs.Replace every x in f's formula with the entire expression for g(x).
Applying the outer function firstIn f(g(x)), g is evaluated first. The inside always goes before the outside.Read inside-out: start with g(x), then apply f to that result.
Assuming f(g(x)) = g(f(x))Composition is generally not commutative. Switching the order usually produces a different function.Always respect the order stated in the problem. Test with a number to confirm.
Forgetting to substitute into every xIf f(x) = x² + 2x, you must replace both x's with g(x), not just one.Everywhere you see x in the outer function, replace it with the full inner expression, using parentheses.
💡 REMEMBER
Think of composition like following driving directions. "Turn right, then turn left" is a completely different route from "Turn left, then turn right." In the same way, f(g(x)) and g(f(x)) are different paths to different answers. Always follow the directions in the exact order given!

Connection to Advanced Topics

Function composition is not just an isolated skill — it is a stepping stone to many advanced ideas you will encounter in later courses. The table below shows how composition connects to topics in Algebra 2, Pre-Calculus, and beyond.

How function composition connects to future coursework
Concept in This LessonAdvanced ExtensionWhere You'll See It
f(g(x)) — composing two functionsInverse functions: if f and g are inverses, then f(g(x)) = x and g(f(x)) = x.Algebra 2, Pre-Calculus
Substituting one expression into anotherThe Chain Rule in calculus: d/dx [f(g(x))] = f′(g(x)) × g′(x).AP Calculus AB/BC
Chaining real-world processesMathematical modeling: combining multiple transformations to describe complex systems.Statistics, Engineering, Computer Science
Checking if order mattersCommutativity in abstract algebra: studying which operations can be swapped and which cannot.College Algebra, Abstract Algebra

Mastering composition now gives you a head start. When you study inverse functions, you'll use composition to prove that two functions are inverses by showing that their compositions both equal x. And when you reach calculus, the Chain Rule is essentially a formula for taking the derivative of a composed function — so the better you understand composition, the smoother that transition will be.

Practice Problems

Try these five problems on your own. They increase in difficulty from a simple concept check to a critical-thinking challenge. Complete solutions are provided below each problem.

PROBLEM 1CONCEPTUAL
In your own words, explain what f(g(x)) means. Which function do you evaluate first — f or g? Why does the order matter?
PROBLEM 2BASIC CALCULATION
Let f(x) = x + 6 and g(x) = 2x. Find f(g(5)) and g(f(5)).
PROBLEM 3INTERMEDIATE
Given f(x) = x² − 1 and g(x) = x + 3, find the simplified expression for (f ∘ g)(x). Then evaluate (f ∘ g)(−2).
PROBLEM 4APPLIED
A store offers a 20% discount on any item, and you also have a $10-off coupon. Let d(p) = 0.80p represent the 20% discount and c(p) = p − 10 represent the $10 coupon. Find d(c(p)) and c(d(p)). Which order saves you more money on a $60 item?
PROBLEM 5CRITICAL THINKING
Find a pair of functions f and g (different from the identity function f(x) = x) such that f(g(x)) = g(f(x)) for all values of x. Prove that your answer works by computing both compositions.

Lesson Summary

Function composition connects two functions into a single process by feeding the output of the inner function directly into the input of the outer function. The notation (f ∘ g)(x) = f(g(x)) tells you to evaluate g first, then apply f. Always read from the inside out, and remember that order matters — f(g(x)) and g(f(x)) usually give different results.

You can compose functions numerically by plugging in specific values, algebraically by substituting one formula into another, or in real-world contexts like the weather-balloon example where T(h(t)) links time to temperature through height. This skill is the foundation for inverse functions and the Chain Rule in calculus, so investing time now will pay off throughout your math journey.

Varsity Tutors • Algebra 1 • Compose Two Functions