The Central Idea

Suppose

\[ f(x)=x+2 \]

and

\[ g(x)=x^2. \]

Start with the input

\[ x=3. \]

First apply \(f\):

\[ f(3)=5. \]

Then use that output as the input to \(g\):

\[ g(5)=25. \]

So

\[ g(f(3))=25. \]

The two functions have been composed.

Composition Notation

The composition of \(g\) with \(f\) is written

\[ \boxed{(g\circ f)(x)=g(f(x))}. \]

This is read:

“\(g\) composed with \(f\) at \(x\).”

The function nearest the input is applied first.

Read Composition from Right to Left

In

\[ g(f(x)), \]

the function \(f\) acts first.

Its output then becomes the input to \(g\).

So the flow is

\[ x \longrightarrow f(x) \longrightarrow g(f(x)). \]

The Circle Symbol Is Not Multiplication

The symbol

\[ \circ \]

means composition.

It does not mean ordinary multiplication.

Thus,

\[ g\circ f \]

means “apply \(f\), then \(g\),” not “multiply \(g\) and \(f\).”

Numerical Composition

Let

\[ f(x)=2x+1 \]

and

\[ g(x)=x^2. \]

Find

\[ (g\circ f)(3). \]

First:

\[ f(3)=2(3)+1=7. \]

Then:

\[ g(7)=49. \]

Therefore,

\[ \boxed{(g\circ f)(3)=49}. \]

Symbolic Composition

Using

\[ f(x)=2x+1 \]

and

\[ g(x)=x^2, \]

find

\[ (g\circ f)(x). \]

Substitute \(f(x)\) into \(g\):

\[ g(f(x))=[f(x)]^2. \]

So

\[ g(f(x))=(2x+1)^2. \]

Therefore,

\[ \boxed{(g\circ f)(x)=(2x+1)^2}. \]

Simplify After Substitution

If desired, expand:

\[ (2x+1)^2 = 4x^2+4x+1. \]

Thus,

\[ (g\circ f)(x) = 4x^2+4x+1. \]

Both forms describe the same composed function.

Reverse the Order

Now find

\[ (f\circ g)(x). \]

This means

\[ f(g(x)). \]

Since

\[ g(x)=x^2, \]

substitute \(x^2\) into \(f\):

\[ f(g(x)) = 2x^2+1. \]

Therefore,

\[ \boxed{(f\circ g)(x)=2x^2+1}. \]

Order Usually Matters

We found

\[ (g\circ f)(x) = (2x+1)^2 \]

but

\[ (f\circ g)(x) = 2x^2+1. \]

These are not the same function.

So, in general,

\[ \boxed{g\circ f\ne f\circ g}. \]

Composition Is Usually Not Commutative

Ordinary addition satisfies

\[ a+b=b+a. \]

Function composition generally does not have this commutative property.

The order of operations changes the result.

A Real-Life Analogy

Imagine two actions:

  1. put on socks;
  2. put on shoes.

The order matters.

“Socks then shoes” is not equivalent to “shoes then socks.”

Composition records ordered sequences of operations in the same way.

Composition as a Pipeline

A useful model is a pipeline:

\[ \text{input} \longrightarrow f \longrightarrow \text{intermediate output} \longrightarrow g \longrightarrow \text{final output}. \]

Each stage processes the result of the previous stage.

Composition Builds New Functions

If

\[ f:A\to B \]

and

\[ g:B\to C, \]

then the composition

\[ g\circ f \]

maps directly from \(A\) to \(C\):

\[ g\circ f:A\to C. \]

The intermediate set \(B\) becomes an internal stage of the combined process.

Domain Compatibility

Composition works only when the output from the first function is a valid input to the second.

For

\[ g(f(x)) \]

we need:

  1. \(x\) must belong to the domain of \(f\);
  2. \(f(x)\) must belong to the domain of \(g\).

Composition Domain

The domain of

\[ g\circ f \]

is

\[ \boxed{ \{x\in\operatorname{dom}(f): f(x)\in\operatorname{dom}(g)\} }. \]

So the composition domain may be smaller than the domain of the inner function.

Domain Example

Let

\[ f(x)=x-4 \]

and

\[ g(x)=\sqrt{x}. \]

Then

\[ (g\circ f)(x)=\sqrt{x-4}. \]

For real outputs,

\[ x-4\ge0. \]

So the domain is

\[ \boxed{[4,\infty)}. \]

Reverse Composition Can Have a Different Domain

Using

\[ f(x)=x-4 \]

and

\[ g(x)=\sqrt{x}, \]

we have

\[ (f\circ g)(x) = \sqrt{x}-4. \]

Now the only restriction is

\[ x\ge0. \]

So the domain is

\[ \boxed{[0,\infty)}. \]

Changing the order changed both the formula and the domain.

Rational Composition Example

Let

\[ f(x)=x+1 \]

and

\[ g(x)=\frac{1}{x}. \]

Then

\[ (g\circ f)(x) = \frac{1}{x+1}. \]

The domain excludes

\[ x=-1. \]

Inner Output Restrictions

Suppose

\[ f(x)=x^2-1 \]

and

\[ g(x)=\ln x. \]

Then

\[ (g\circ f)(x) = \ln(x^2-1). \]

The logarithm requires

\[ x^2-1>0. \]

Thus,

\[ x<-1 \]

or

\[ x>1. \]

The composition domain is

\[ \boxed{(-\infty,-1)\cup(1,\infty)}. \]

Composition with Algebraic Inputs

Composition is just function evaluation where the input happens to be another function output.

If

\[ g(u)=u^2+3, \]

then

\[ g(f(x)) \]

means replace every \(u\) in the rule for \(g\) with \(f(x)\):

\[ g(f(x)) = [f(x)]^2+3. \]

Use Parentheses Carefully

Suppose

\[ f(x)=x-2 \]

and

\[ g(x)=3x^2+1. \]

Then

\[ g(f(x)) = 3(x-2)^2+1. \]

It is not

\[ 3x-2^2+1. \]

The entire inner output replaces the outer input variable.

Composition from a Table

Suppose:

\(x\) \(f(x)\) \(g(x)\)
1 3 5
2 1 4
3 2 7

Find

\[ g(f(1)). \]

First,

\[ f(1)=3. \]

Then use \(3\) as the input to \(g\):

\[ g(3)=7. \]

Therefore,

\[ \boxed{g(f(1))=7}. \]

A Table Composition Can Be Undefined

Suppose

\[ f(2)=5, \]

but the table for \(g\) contains no input \(5\).

Then

\[ g(f(2)) \]

is not defined from the given function data.

The intermediate output must belong to the domain of the next function.

Composition from a Mapping Diagram

Suppose

\[ f: 1\mapsto a,\quad 2\mapsto b \]

and

\[ g: a\mapsto 10,\quad b\mapsto 20. \]

Then

\[ (g\circ f)(1)=10 \]

and

\[ (g\circ f)(2)=20. \]

Composition follows the arrows through both mappings.

Composition with Piecewise Functions

Suppose

\[ g(x)= \begin{cases} x+1, & x<0,\\ x^2, & x\ge0. \end{cases} \]

To evaluate

\[ g(f(x)), \]

the branch of \(g\) depends on the sign of the inner output \(f(x)\), not directly on \(x\).

Piecewise Composition Example

Let

\[ f(x)=x-3 \]

and

\[ g(u)= \begin{cases} u+1, & u<0,\\ u^2, & u\ge0. \end{cases} \]

Because

\[ f(x)=x-3, \]

the condition

\[ f(x)<0 \]

means

\[ x<3. \]

So

\[ (g\circ f)(x)= \begin{cases} x-2, & x<3,\\ (x-3)^2, & x\ge3. \end{cases} \]

Composition in Real Models

Suppose temperature in Celsius depends on time:

\[ C(t). \]

Suppose Fahrenheit temperature is calculated from Celsius by

\[ F(C)=\frac95C+32. \]

Then Fahrenheit as a function of time is

\[ F(C(t)). \]

One model feeds directly into another.

Unit Conversion as Composition

A measurement may pass through several conversion functions.

For example:

\[ \text{miles} \longrightarrow \text{feet} \longrightarrow \text{inches}. \]

The combined conversion is the composition of the individual conversions.

Tax and Discount as Composition

Suppose

\[ D(p)=0.80p \]

applies a 20% discount, and

\[ T(p)=1.08p \]

applies 8% tax.

Tax after discount is

\[ (T\circ D)(p). \]

Then

\[ (T\circ D)(p) = 1.08(0.80p) = 0.864p. \]

Order in Applied Composition

In some multiplicative models, two operations may happen to commute numerically.

But this should be checked, not assumed.

For example, an additive fee and a percentage tax generally produce different totals depending on the order.

Order Example with a Fixed Fee

Let

\[ F(p)=p+10 \]

add a \$10 fee, and

\[ T(p)=1.10p \]

apply 10% tax.

Tax after the fee:

\[ (T\circ F)(p) = 1.10(p+10) = 1.10p+11. \]

Fee after tax:

\[ (F\circ T)(p) = 1.10p+10. \]

The results differ.

Identity Function

The identity function on a set \(A\) is

\[ I_A(x)=x. \]

It returns every input unchanged.

Identity and Composition

Composing with the identity leaves a function unchanged:

\[ f\circ I=f \]

and

\[ I\circ f=f, \]

when the domains and codomains are compatible.

Why Identity Acts Like “Do Nothing”

If

\[ I(x)=x, \]

then

\[ f(I(x)) = f(x). \]

Likewise,

\[ I(f(x)) = f(x). \]

The identity function preserves the current value in a composition chain.

Composition Is Associative

Although composition is generally not commutative, it is associative.

For compatible functions,

\[ h\circ(g\circ f) = (h\circ g)\circ f. \]

Both mean:

apply \(f\), then \(g\), then \(h\).

Associativity Means Grouping Does Not Change the Pipeline

Consider

\[ h(g(f(x))). \]

We may group the inner two functions first or the outer two functions first.

The order of application remains

\[ f\to g\to h. \]

Three-Function Composition

Let

\[ f(x)=x+1, \] \[ g(x)=2x, \]

and

\[ h(x)=x^2. \]

Then

\[ (h\circ g\circ f)(x) = h(g(f(x))). \]

First:

\[ f(x)=x+1. \]

Then:

\[ g(f(x))=2(x+1). \]

Finally:

\[ h(g(f(x))) = [2(x+1)]^2. \]

Thus,

\[ \boxed{(h\circ g\circ f)(x)=4(x+1)^2}. \]

Repeated Composition

A function may be composed with itself.

For example,

\[ f\circ f \]

means

\[ f(f(x)). \]

Self-Composition Example

Let

\[ f(x)=2x+1. \]

Then

\[ f(f(x)) = 2(2x+1)+1. \]

So

\[ \boxed{f(f(x))=4x+3}. \]

Iterates of a Function

Repeated composition is often written

\[ f^2=f\circ f, \] \[ f^3=f\circ f\circ f, \]

and more generally

\[ f^n. \]

Here \(f^2\) means repeated composition, not squaring the output.

Do Not Confuse \(f^2(x)\) with \([f(x)]^2\)

Depending on context,

\[ f^2(x) \]

may mean

\[ f(f(x)). \]

But

\[ [f(x)]^2 \]

means square the numerical output.

These are different operations.

Iteration and Fixed Points

Repeated composition creates sequences such as

\[ x_{n+1}=f(x_n). \]

A fixed point

\[ f(L)=L \]

remains unchanged under further composition.

This connects composition directly to iterative processes and dynamical systems.

Composition and Inverse Functions

If \(f\) is bijective, then its inverse \(f^{-1}\) reverses its action.

The defining relationships are

\[ f^{-1}\circ f=I \]

and

\[ f\circ f^{-1}=I. \]

Inverse Composition Example

Let

\[ f(x)=2x+3. \]

Its inverse is

\[ f^{-1}(x)=\frac{x-3}{2}. \]

Then

\[ f^{-1}(f(x)) = \frac{(2x+3)-3}{2} = x. \]

The functions undo one another.

Composition Can Simplify to the Identity

When two functions are inverses, their composition removes the effect of the first function.

Symbolically:

\[ x \longrightarrow f(x) \longrightarrow f^{-1}(f(x)) = x. \]

Composition of Injective Functions

If

\[ f:A\to B \]

and

\[ g:B\to C \]

are injective, then

\[ g\circ f \]

is injective.

No output collisions are introduced by chaining two collision-free functions.

Composition of Surjective Functions

If both functions are surjective, their composition is surjective.

Every final target in \(C\) can be reached through some value in \(B\), and that intermediate value can be reached from \(A\).

Composition of Bijections

The composition of two bijective functions is bijective.

It therefore has an inverse.

Inverse of a Composition Preview

If \(f\) and \(g\) are invertible, then

\[ (g\circ f)^{-1} = f^{-1}\circ g^{-1}. \]

The inverse reverses both the operations and their order.

Why the Inverse Order Reverses

If a process applies

\[ f \]

first and then

\[ g, \]

undoing the process requires undoing \(g\) first and then undoing \(f\).

This is the same logic used when reversing a sequence of algebraic operations.

Composition and Units

Function composition should also make sense dimensionally.

If one function outputs meters and the next expects seconds, the composition may be meaningless unless there is another stated relationship connecting those quantities.

Compatible mathematical domains include compatible units and object types.

Type Matching

Think of each function as having an input type and output type.

For example:

\[ f:\text{hours}\to\text{miles} \]

and

\[ g:\text{miles}\to\text{dollars}. \]

Then

\[ g\circ f \]

is meaningful:

\[ \text{hours}\to\text{dollars}. \]

But the reverse composition may not be meaningful.

Worked Example: Numerical Composition

Let

\[ f(x)=3x-1 \]

and

\[ g(x)=x+4. \]

Find

\[ (g\circ f)(2). \]

First:

\[ f(2)=5. \]

Then:

\[ g(5)=9. \]

Therefore,

\[ \boxed{(g\circ f)(2)=9}. \]

Worked Example: Symbolic Composition

Let

\[ f(x)=x^2+1 \]

and

\[ g(x)=2x-5. \]

Then

\[ (g\circ f)(x) = 2(x^2+1)-5. \]

Simplify:

\[ \boxed{(g\circ f)(x)=2x^2-3}. \]

Worked Example: Reverse Order

Using

\[ f(x)=x^2+1 \]

and

\[ g(x)=2x-5, \]

find

\[ (f\circ g)(x). \]

Substitute \(2x-5\) into \(f\):

\[ f(g(x)) = (2x-5)^2+1. \]

Therefore,

\[ \boxed{(f\circ g)(x)=(2x-5)^2+1}. \]

Worked Example: Domain Restriction

Let

\[ f(x)=x+2 \]

and

\[ g(x)=\frac{1}{x-5}. \]

Then

\[ (g\circ f)(x) = \frac{1}{(x+2)-5} = \frac{1}{x-3}. \]

The composition is undefined when

\[ x=3. \]

So the domain is

\[ \boxed{\mathbb{R}\setminus\{3\}}. \]

Worked Example: Radical Composition

Let

\[ f(x)=2x-6 \]

and

\[ g(x)=\sqrt{x}. \]

Then

\[ (g\circ f)(x) = \sqrt{2x-6}. \]

Require

\[ 2x-6\ge0. \]

Thus,

\[ x\ge3. \]

The domain is

\[ \boxed{[3,\infty)}. \]

A Reliable Composition Workflow

  1. Identify the outer function and inner function.
  2. Read from right to left: the inner function acts first.
  3. Write the outer function rule.
  4. Replace its input variable with the entire inner function.
  5. Use parentheses to preserve structure.
  6. Simplify only after substitution is correct.
  7. Determine the domain of the composition.
  8. Check that inner outputs are valid outer inputs.

A Reliable Numerical Workflow

  1. Evaluate the inner function at the given input.
  2. Take that output and feed it into the outer function.
  3. Do not reverse the order.
  4. Check that the intermediate value belongs to the outer function's domain.

A Reliable Table or Mapping Workflow

  1. Start with the original input.
  2. Use the first table or mapping to find the intermediate output.
  3. Use that intermediate value as the next input.
  4. If the next function has no value there, the composition is undefined.

Common Errors

Applying the Functions in the Wrong Order

In

\[ g\circ f, \]

apply \(f\) first and \(g\) second.

Treating Composition as Multiplication

The symbol \(\circ\) represents chaining, not product.

Substituting Only Part of the Inner Function

The entire inner output replaces the outer input variable.

Ignoring Parentheses

Complex inner expressions must remain grouped during substitution.

Assuming Composition Is Commutative

Usually,

\[ g\circ f\ne f\circ g. \]

Ignoring Domain Compatibility

The inner output must belong to the domain of the outer function.

Confusing \(f(f(x))\) with \([f(x)]^2\)

Repeated composition and numerical squaring are different operations.

Practice

1. Numerical Composition

Let

\[ f(x)=x+3 \]

and

\[ g(x)=2x. \]

Find

\[ (g\circ f)(4). \]
Check Answer \[ f(4)=7. \] \[ g(7)=14. \]

Answer:

\[ \boxed{14}. \]

2. Symbolic Composition

Let

\[ f(x)=x-1 \]

and

\[ g(x)=x^2. \]

Find

\[ (g\circ f)(x). \]
Check Answer \[ g(f(x)) = (x-1)^2. \]

Answer:

\[ \boxed{(x-1)^2}. \]

3. Reverse Composition

Using the same functions, find

\[ (f\circ g)(x). \]
Check Answer \[ f(g(x)) = x^2-1. \]

Answer:

\[ \boxed{x^2-1}. \]

4. Domain of a Radical Composition

Let

\[ f(x)=x-5 \]

and

\[ g(x)=\sqrt{x}. \]

Find the real domain of

\[ g\circ f. \]
Check Answer \[ (g\circ f)(x)=\sqrt{x-5}. \]

Require

\[ x-5\ge0. \]

So the domain is

\[ \boxed{[5,\infty)}. \]

5. Composition from a Table

Suppose

\[ f(1)=3 \]

and

\[ g(3)=8. \]

Find

\[ g(f(1)). \]
Check Answer \[ \boxed{8}. \]

6. Self-Composition

Let

\[ f(x)=x+2. \]

Find

\[ f(f(x)). \]
Check Answer \[ f(f(x)) = f(x+2) = x+4. \]

Answer:

\[ \boxed{x+4}. \]

7. Identity Function

If

\[ I(x)=x, \]

what is

\[ (f\circ I)(x)? \]
Check Answer \[ f(I(x)) = f(x). \]

Answer:

\[ \boxed{f(x)}. \]

8. Inverse Composition

If \(f\) is bijective, what is

\[ f^{-1}(f(x))? \]
Check Answer \[ \boxed{x}. \]

Key Ideas

Where This Leads

Function composition turns separate relationships into reusable mathematical pipelines.

It leads directly into inverse functions, identity functions, transformation chains, iterative methods, dynamical systems, nested models, coordinate transformations, matrix transformations, and higher mathematics where complex operations are built by composing simpler ones.