---
title: "Composite Functions"
description: "Apply one function to the output of another, writing fg(x) as f(g(x)), and keep the order of the two rules straight."
canonical: https://lightmysky.com/learn/mathematics/composite-functions-mt_jqGJHXgYNw
source: https://lightmysky.com/learn/mathematics/composite-functions-mt_jqGJHXgYNw.md
retrieved: 2026-09-02
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Composite Functions

Apply one function to the output of another, writing fg(x) as f(g(x)), and keep the order of the two rules straight.

Subject: Mathematics · Area: Algebra · Ages 15 to 16
Page: https://lightmysky.com/learn/mathematics/composite-functions-mt_jqGJHXgYNw

## Ready when they can

- Work out fg(2) by finding g(2) first and then applying f
- Write and simplify an expression for fg(x)
- Show with one example that fg(x) and gf(x) usually differ

## Lesson: Composite Functions

Last stop you fed a number into one rule and read off the output. This time there are two rules, and you chain them: the output of one becomes the input of the next. That is a composite function. The notation fg(x) means apply g first, then f, which you can read as f of g of x. The order is baked into the name, and keeping it straight is the whole trick of this topic.

*(drawing: Two machines in a row: the output of g feeds straight into f.)*

The letters are read inside-out. In fg(x), g is the inner rule and f is the outer one, so you always start with g. Work from the inside out: feed the input into g, take that result, and feed it into f. It is tempting to read fg as f first, because f is written first, but the second letter is the one that acts first. Keep the inside-out habit and the order never trips you.

Here is the surprise that trips people up: fg(x) and gf(x) are usually not the same. Swapping the order swaps which rule sits on the inside, and a different inside usually gives a different answer. Sometimes they match, but you cannot assume it. When a question asks you to show they differ, one input that gives two different outputs is all you need.

**Example.** Find fg(2) and gf(2) for f(x) = 3x - 2 and g(x) = x + 4. For fg(2), start with g: g(2) is 2 + 4, which is 6. Now feed 6 into f: f(6) is 3(6) - 2, which is 18 - 2 = 16. So fg(2) is 16. For gf(2), start with f: f(2) is 3(2) - 2, which is 4. Feed 4 into g: g(4) is 4 + 4 = 8. So gf(2) is 8. Same input, two different outputs, because the order changed.

**Example.** Now write the expression. For f(x) = 2x + 3 and g(x) = x - 2, find fg(x). The inside is g, so fg(x) = f(g(x)) = f(x - 2). Feed x - 2 into f: 2(x - 2) + 3 = 2x - 4 + 3 = 2x - 1. So fg(x) is 2x - 1. Check it at x = 2 by the pipeline: g(2) is 0, and f(0) is 3, and 2(2) - 1 is also 3, so they agree. For comparison, gf(x) = g(f(x)) = (2x + 3) - 2 = 2x + 1, which is different.

**Example.** Finally, show with one number that the order matters. Take f(x) = x squared and g(x) = 2x - 1, and test the input 3. For fg(3), start with g: g(3) is 2(3) - 1 = 5. Feed 5 into f: f(5) is 5 squared = 25. For gf(3), start with f: f(3) is 3 squared = 9. Feed 9 into g: g(9) is 2(9) - 1 = 17. So fg(3) is 25 and gf(3) is 17. One input, two different outputs, and that single example is enough to show the composites differ.

**Recap.** Evaluate a composite inside-out: apply the inner rule first, then feed its output into the outer rule, and remember that fg(x) and gf(x) are usually different because the order changes which rule is on the inside.

## Practice

24 questions on this page, each with its working shown.

## Needs first

- [Function Notation and Evaluating Functions](https://lightmysky.com/learn/mathematics/function-notation-and-evaluating-functions-mt_YWKWzHK_6Z)

## Opens up

- [Inverse Functions](https://lightmysky.com/learn/mathematics/inverse-functions-mt_7k7q5ZjMb4)
