Composition of Functions

Function composition chains two functions together: the output of one becomes the input of the other. This operation is central to differential calculus because the chain rule tells you how to differentiate composite functions. Nearly every non-trivial function you will differentiate is a composition of simpler ones.

Notation Meaning
( f g ) ( x ) f ( g ( x ) ) : apply g first, then f
Domain of f g All x in Dom( g ) such that g ( x ) Dom( f )

Building a Composition

Let f ( x ) = x 2 + 1 and g ( x ) = 1 / x . We can define a new function h by applying g first, then f :

h ( x ) = f ( g ( x ) ) = f ( 1 x ) = ( 1 x ) 2 + 1 = 1 x 2 + 1 = x 2 + 1 x 2 .

To obtain h ( x ) , we substituted g ( x ) in place of x in the expression for f ( x ) .

The General Definition

Suppose f and g are two given functions. Starting with x in the domain of g , we apply g to get g ( x ) , then apply f to g ( x ) to get f ( g ( x ) ) .

The new function that takes x and assigns f ( g ( x ) ) is called the composition of f and g , denoted f g . The symbol f g is read " f circle g ."

This composition is defined only when g ( x ) is in the domain of f , otherwise, we cannot use g ( x ) as the input for f .

Order Matters

In general, f g is not the same as g f . For example, if f ( x ) = sin x and g ( x ) = x + 1 :

f g ( x ) = f ( g ( x ) ) = f ( x + 1 ) = sin ( x + 1 )

but

g f ( x ) = g ( f ( x ) ) = g ( sin x ) = 1 + sin x .

These are clearly different functions with different domains.

If f ( x ) = x 2 and g ( x ) = x + 3 , find ( f g ) ( x ) and ( g f ) ( x ) .

Solution ( f g ) ( x ) = f ( g ( x ) ) = f ( x + 3 ) = ( x + 3 ) 2 = x 2 + 6 x + 9 . ( g f ) ( x ) = g ( f ( x ) ) = g ( x 2 ) = x 2 + 3 . These are different functions.

Decomposing Functions

It is equally important to recognize a given function as a composition of simpler pieces. For example, h ( x ) = sin ( x 2 ) is f g where f ( x ) = sin x and g ( x ) = x 2 . Identifying the inner and outer functions is the first step in applying the chain rule.

Frequently Asked Questions

Can I compose more than two functions? Yes. f g h means "apply h first, then g , then f ": ( f g h ) ( x ) = f ( g ( h ( x ) ) ) . Composition is associative: ( f g ) h = f ( g h ) , so the grouping does not matter, only the order.

How does composition connect to the chain rule? The chain rule says: if h ( x ) = f ( g ( x ) ) , then h'(x) = f'(g(x)) \cdot g'(x). The derivative of a composition is the derivative of the outer function (evaluated at the inner function) times the derivative of the inner function. Identifying the inner and outer functions of a composition is the key skill for applying the chain rule correctly.

What is the domain of a composition? The domain of f g consists of all x in the domain of g such that g ( x ) is in the domain of f . For example, if f ( x ) = x and g ( x ) = 1 x 2 , then ( f g ) ( x ) = 1 x 2 . For this to be defined, we need 1 x 2 0 , i.e., 1 x 1 . Domain: [ 1 , 1 ] .