# What is the composite function?

Finds the composite functions (f ∘ g)(x) = f(g(x)) and (g ∘ f)(x) = g(f(x)), simplified, and their values at x = a.

- Page: https://www.acalculator.org/math/composite-function-calculator
- JSON spec: https://www.acalculator.org/math/composite-function-calculator.json
- Version: 51a8f3525727

## Default answer

Example with the default inputs (f(x) 2x + 1, g(x) 3 - x): For f(x) = 2x + 1 and g(x) = 3 - x, f(g(x)) = -2x + 7.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| f | f(x) | The function f, in x. |
| g | g(x) | The function g, in x. |
| a | At x = a (optional) | A number at which to evaluate both composites. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| fg | f(g(x)) = | f with g(x) in place of x. |
| gf | g(f(x)) = | g with f(x) in place of x. |
| fga | f(g(a)) | The value of f(g(x)) at x = a. |
| gfa | g(f(a)) | The value of g(f(x)) at x = a. |

## Method

f(g(x)) is f with every x replaced by g(x); the result is expanded or simplified only when the shorter form is the same function on the same domain.

## Assumptions

- The variable is x; angles in radians.
- The domain of f(g(x)) is the x where g(x) is in the domain of f.

## Worked examples

1. f = 2x + 1, g = 3 - x gives fg = -2x + 7, gf = -2x + 2. Source: OpenStax, College Algebra 2e, section 3.4 Composition of Functions (https://openstax.org/books/college-algebra-2e/pages/3-4-composition-of-functions), Example 2: f(g(x)) = 7 − 2x and g(f(x)) = −2x + 2.
2. f = x^2 - x, g = 3x + 2, a = 1 gives fga = 20, fg = 9x^2 + 9x + 2. Source: OpenStax, College Algebra 2e, section 3.4 Composition of Functions (https://openstax.org/books/college-algebra-2e/pages/3-4-composition-of-functions), Example 7: f(h(1)) = 20.
3. f = sqrt(x), g = 5 - x^2 gives fg = sqrt(5 - x^2). Source: OpenStax, College Algebra 2e, section 3.4 Composition of Functions (https://openstax.org/books/college-algebra-2e/pages/3-4-composition-of-functions), Example 10: g(h(x)) = √(5 − x²).

## FAQ

### What is a composite function?

The function you get by applying one function to the output of another. (f ∘ g)(x) = f(g(x)): first g acts on x, then f acts on g(x). For f(x) = 2x + 1 and g(x) = 3 − x, f(g(x)) = 2(3 − x) + 1 = 7 − 2x.

### Is f(g(x)) the same as g(f(x))?

Usually not. With the functions above, g(f(x)) = 3 − (2x + 1) = −2x + 2, which differs from f(g(x)) = 7 − 2x. Composition is not commutative. When f(g(x)) = g(f(x)) = x for all x, f and g are inverse functions.

### How do I evaluate a composite function at a number?

Work from the inside out: find g(a), then put that value into f. For f(t) = t² − t and h(x) = 3x + 2, h(1) = 5 and f(5) = 25 − 5 = 20, so f(h(1)) = 20. Type a to get both values.

### What is the domain of f(g(x))?

The x in the domain of g for which g(x) is in the domain of f. For f(x) = √x and g(x) = 5 − x², f(g(x)) = √(5 − x²) needs 5 − x² ≥ 0, so −√5 ≤ x ≤ √5.

### Why does the page not simplify (√x)² to x?

The two differ for x < 0, where √x is not a real number. The page keeps a simpler form only when it is real at exactly the same test points as the composite as written. One point can still drop out: 1/(1/x) is shown as x, though x = 0 is not in its domain.

### How do I decompose a function into a composite?

Look for an inside part. √(5 − x²) is g(h(x)) with h(x) = 5 − x² and g(x) = √x. Type those two here to check that the composite gives back the function.

## Sources

- OpenStax, College Algebra 2e, section 3.4 Composition of Functions (retrieved 2026-10-03): https://openstax.org/books/college-algebra-2e/pages/3-4-composition-of-functions
