Performing algebraic operations on functions combines them into a new function, but we can also create functions by composing functions. When we wanted to compute a heating cost from a day of the year, we created a new function that takes a day as input and yields a cost as output. The process of combining functions so that the output of one function becomes the input of another is known as a composition of functions*.* The resulting function is known as a *composite function*. We represent this combination by the following notation:

(
f∘g
)(
x
)=f(
g(
x
)
)
(
f∘g
)(
x
)=f(
g(
x
)
)

We read the left-hand side as
“f
“f
composed with
g
g at
x,”
x,”
and the right-hand side as
“f
“f
of
g
g of
x.”
x.”
The two sides of the equation have the same mathematical meaning and are equal. The open circle symbol
∘
∘ is called the composition operator. We use this operator mainly when we wish to emphasize the relationship between the functions themselves without referring to any particular input value. Composition is a binary operation that takes two functions and forms a new function, much as addition or multiplication takes two numbers and gives a new number. However, it is important not to confuse function composition with multiplication because, as we learned above, in most cases
f(g(x))≠f(x)g(x).
f(g(x))≠f(x)g(x).

It is also important to understand the order of operations in evaluating a composite function. We follow the usual convention with parentheses by starting with the innermost parentheses first, and then working to the outside. In the equation above, the function
g
g takes the input
x
x first and yields an output
g(
x
).
g(
x
). Then the function
f
f takes
g(
x
)
g(
x
) as an input and yields an output
f(
g(
x
)
).
f(
g(
x
)
).

In general,
f∘g
f∘g and
g∘f
g∘f are different functions. In other words, in many cases
f(
g(
x
)
)≠g(
f(
x
)
)
f(
g(
x
)
)≠g(
f(
x
)
) for all
x.
x. We will also see that sometimes two functions can be composed only in one specific order.

For example, if
f(
x
)=
x
2
f(
x
)=
x
2
and
g(
x
)=x+2,
g(
x
)=x+2,then

f(g(x))
=
f(x+2)
=
(x+2)
2
=
x
2
+4x+4
f(g(x))
=
f(x+2)
=
(x+2)
2
=
x
2
+4x+4

but

g(f(x))
=
g(
x
2
)
=
x
2
+2
g(f(x))
=
g(
x
2
)
=
x
2
+2

These expressions are not equal for all values of
x,
x, so the two functions are not equal. It is irrelevant that the expressions happen to be equal for the single input value
x=−
1
2
.
x=−
1
2
.

Note that the range of the inside function (the first function to be evaluated) needs to be within the domain of the outside function. Less formally, the composition has to make sense in terms of inputs and outputs.

When the output of one function is used as the input of another, we call the entire operation a composition of functions. For any input
x
x and functions
f
f and
g,
g, this action defines a composite function, which we write as
f∘g
f∘g such that

(
f∘g
)(
x
)=f(
g(
x
)
)
(
f∘g
)(
x
)=f(
g(
x
)
)

(9)
The domain of the composite function
f∘g
f∘g is all
x
x such that
x
x is in the domain of
g
g and
g(
x
)
g(
x
) is in the domain of
f.
f.

It is important to realize that the product of functions
fg
fg is not the same as the function composition
f(
g(
x
)
),
f(
g(
x
)
), because, in general,
f(
x
)g(
x
)≠f(
g(
x
)
).
f(
x
)g(
x
)≠f(
g(
x
)
).

Using the functions provided, find
f(
g(
x
)
)
f(
g(
x
)
) and
g(
f(
x
)
).
g(
f(
x
)
). Determine whether the composition of the functions is commutative.

f(x)=2x+1 g(x)=3−x
f(x)=2x+1 g(x)=3−x

Let’s begin by substituting
g(
x
)
g(
x
) into
f(
x
).
f(
x
).

f(g(x))
=
2(3−x)+1
=
6−2x+1
=
7−2x
f(g(x))
=
2(3−x)+1
=
6−2x+1
=
7−2x

Now we can substitute
f(
x
)
f(
x
) into
g(
x
).
g(
x
).

g(f(x))
=
3−(2x+1)
=
3−2x−1
=
−2x+2
g(f(x))
=
3−(2x+1)
=
3−2x−1
=
−2x+2

We find that
g(f(x))≠f(g(x)),
g(f(x))≠f(g(x)),
so the operation of function composition is not commutative.

The function
c(s)
c(s) gives the number of calories burned completing
s
s sit-ups, and
s(t)
s(t) gives the number of sit-ups a person can complete in
t
t minutes. Interpret
c(s(3)).
c(s(3)).

The inside expression in the composition is
s(3).
s(3). Because the input to the *s*-function is time,
t=3
t=3 represents 3 minutes, and
s(3)
s(3) is the number of sit-ups completed in 3 minutes.

Using
s(3)
s(3) as the input to the function
c(s)
c(s) gives us the number of calories burned during the number of sit-ups that can be completed in 3 minutes, or simply the number of calories burned in 3 minutes (by doing sit-ups).

Suppose
f(x)
f(x) gives miles that can be driven in
x
x hours and
g(y)
g(y) gives the gallons of gas used in driving
y
y miles. Which of these expressions is meaningful:
f(
g(y)
)
f(
g(y)
) or
g(
f(x)
)?
g(
f(x)
)?

The function
y=f(
x
)
y=f(
x
) is a function whose output is the number of miles driven corresponding to the number of hours driven.

number of miles =f (number of hours)
number of miles =f (number of hours)

The function
g(
y
)
g(
y
) is a function whose output is the number of gallons used corresponding to the number of miles driven. This means:

number of gallons =g (number of miles)
number of gallons =g (number of miles)

The expression
g(y)
g(y) takes miles as the input and a number of gallons as the output. The function
f(x)
f(x) requires a number of hours as the input. Trying to input a number of gallons does not make sense. The expression
f(
g(y)
)
f(
g(y)
) is meaningless.

The expression
f(x)
f(x) takes hours as input and a number of miles driven as the output. The function
g(y)
g(y) requires a number of miles as the input. Using
f(x)
f(x) (miles driven) as an input value for
g(y),
g(y), where gallons of gas depends on miles driven, does make sense. The expression
g(
f(x)
)
g(
f(x)
) makes sense, and will yield the number of gallons of gas used,
g,
g, driving a certain number of miles,
f(x),
f(x), in
x
x hours.

*Yes. For many pure mathematical functions, both compositions make sense, even though they usually produce different new functions. In real-world problems, functions whose inputs and outputs have the same units also may give compositions that are meaningful in either order.*

The gravitational force on a planet a distance *r* from the sun is given by the function
G(r).
G(r). The acceleration of a planet subjected to any force
F
F is given by the function
a(F).
a(F). Form a meaningful composition of these two functions, and explain what it means.

A gravitational force is still a force, so
a(
G(r)
)
a(
G(r)
) makes sense as the acceleration of a planet at a distance *r* from the Sun (due to gravity), but
G(
a(F)
)
G(
a(F)
) does not make sense.

AnalysisFigure 3 shows how we can mark the graphs with arrows to trace the path from the input value to the output value.

Figure 3