# Composition of Two Functions

In Math, we can perform what is called a composition of two functions, where one function is applied or input into another function.
It’s the same approach as when you evaluate a function by inputting a numerical value.

We could have the function    f(x) = \space 3x + 4.

Evaluate with the number  4.

f(4) \space = \space 3(4) + 4 \space = \space 12 + 4 \space = \space 16

This can be done with functions also, and we call such situations a composition of two functions.

The notation is   (f \circ g)(x),  which would represent   f(g(x)).

Examples

(1.1)

g(x) = \space 4x \space {\text{--}} \space 2 \space \space \space , \space \space \space h(x) = \space 2x + 1

Find   (g \circ h)(x).

Solution

Here we look to input the function  h(x)  into the function  g(x)  where there is an  x,  like if it was a number.
This is a function composition.

(g \circ h)(x) \space = \space g(h(x))

g(h(x)) \space = \space 4(2x + 1) \space {\text{--}} \space 2

= \space 8x + 4 \space {\text{--}} \space 2 \space = \space 8x + 2

Our composition of two functions has given us another function as a result.

(1.2)

f(a) = \space \frac{6}{a} \space \space \space , \space \space \space g(a) = \space 3a

Find   f(g(a)).

Solution

(f \circ g)(a) \space = \space f(g(a))

f(g(a)) \space = \space \frac{6}{3a} \space = \space \frac{2}{a}

## Composition of Two Functions,Composition Order

When performing a composition of functions, the order of composition is something that matters, as the results often differ.
In example (1.1), function  g  was performed on function  h.

Resulting in    g(h(x)) = \space 8x + 2

But we can change the order, and perform  h(g(x))  also.

(h \circ g)(x) \space = \space h(g(x)) = \space 2(4x \space {\text{--}} \space 2) + 1

= \space 8x \space {\text{--}} \space 4 + 1 \space = \space 8x \space {\text{--}} \space 3

It’s usually the case that changing the order of composition of two functions will produce a different result, but sometimes they can be the same.

Examples

(2.1)

f(r) = \space 3r \space \space \space , \space \space \space g(r) = \space 2r + 1

Find   (f \circ g)(r)   and   (g \circ f)(r).

Solution

(f \circ g)(r) \space = \space f(g(r)) \space = \space 3(2r + 1) \space = \space 6r + 3

(g \circ f)(r) \space = \space g(f(r)) \space = \space 2(3r) + 1 \space = \space 6r + 1

(2.2)

m(x) = \space 3x \space \space \space , \space \space \space n(x) = \space 4x

Find   (m \circ n)(x)   and   (n \circ m)(x).

Solution

(m \circ n)(x) \space = \space m(n(x)) \space = \space 3(4x) \space = \space 12x

(n \circ m)(x) \space = \space n(m(x)) \space = \space 4(3x) \space = \space 12x

(2.3)

f(x) = \space 2x + 5

Find   (f \circ f)(x).

Solution

This example asks to find the result of a function composed with itself.
Things work just the same here as before.

(f \circ f)(x) \space = \space f(f(x))

= \space 2(2x + 5) + 5 \space = \space 10x + 10 + 5 \space = \space 10x + 15

## Composition of Functions, Domain

Sometimes we need to pay attention to how the domain values that go into a function is affected by a composition with another.

We could have two functions,   g(x) = \ln(x)    and    h(x) = (x)^3.

A bit of consideration is needed if we wanted to perform the composition  (g \circ h)(x).

It’s the case that the function  \ln(x)  only works for positive values of  x.

But  (x)^3  produces a negative value as a result when a negative number is input.

So when the composition   (g \circ h)(x)   gives us   \ln((x)^3),

The domain of  h(x)  would have to be restricted to positive real numbers, even though the function on it’s own is fine to work with all real numbers, including negative ones.

1. Home
2.  ›
3. Algebra 1
4. › Function Composition