Putting functions together to make new ones

To compose two functions is to put one inside the other. We already know that f(x) means to take x and follow the instructions in f(x) for what to do with it to get the corresponding y-value. But what if we replace x with another function?

Let's do this by a simple example. Let f(x) = x + 2 and g(x) = x2.

To find f(g(x)), we just put in g(x) everywhere there's an x in f(x):

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


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

Why are function compositions useful?

Making compositions of functions can be a really powerful way of solving all kinds of problems, and it's not too difficult after some practice.

Here's an example: You probably recall that the area of a circle is a function of its radius, A(r) = πr2. But how about finding the area of a circle as a function of its circumference, A(c) ?

Recall that c = 2πr, so then r = c/2π. That last equation is r as a function of c, or r(c).

Now let's find the composition A(r(c)):   A(r(c)) = π (c/2π )2= c2/4π.

The function we were looking for, A(c) = c2/4π is a composition. Compositions of functions will be extremely useful as we go along.

Example 1

Given functions   f(x) = x + 1   and   g(x) = 3x - 1,   find the composite functions f(g(x)) and g(f(x)).


We start with our two original functions

For f(g(x)), we're just plugging in the definition of g(x) wherever there is an x in the definition of f(x), like this.

Now just put in the rest of f(x):

and simplify (1 - 1 = 0) to get the result:

For g(f(x)) we follow the same pattern: First insert f(x) anywhere into g(x) where there's an x:

The instructions for g(x) say to multiply the input by 3 and subtract 1, so we'll do that:

Finally, simplifying yields our new composite function:

Example 2

Now let's look at some more complicated functions. If f(x) = x2 + 1 and g(x) = -2x - 1, find the composite functions f(g(x)), g(f(x)), f(f(x)) and g(g(x)). The last two are sometimes called self-referential functions, or recursive functions. They can be very important, especially in computer programming.


Here's f(g(x))

g(f(x)) goes like this:

f(f(x)) seems weird, but you're really just following the same instructions:

... and likewise for g(g(x)):

Example 3

The number of widgets* (n) produced by a factory after t hours of operation is modeled by the function n(t) = 1000t - 8t2. If the cost (C, in dollars) of producing n widgets is C(n) = 10,000 + 350n, find the cost C(t) as a function of the time of factory operation.


What we're trying to do here is make C(t) from C(n) and n(t), which means finding the composition C(t) = C(n(t)).

If we take C(n) and plug the function n(t) in everywhere we see an n, we get:

C(t) = 10,000 + 350(1000t - 8t2)

= 10,000 + 350,000t - 2800t2

Now we've got a new function for cost as a function of time. We made it by knowing how cost changes with number of widgets made, and how number of widgets depends on time – n(t). That kind of thing can be pretty useful.

* "widget" is often used in economics to describe some fictional product.

Example 4

A conical water tank has a radius of 10 meters and a height of 12 m, as shown below. If water is flowing into the tank at a rate of 0.5 m3 per hour, find a function for the height of the water in the tank over time. That is, find h(t) from V(t) and the known volume of a cone.


Here's a picture of what's going on:

The volume of a cone is

Now the problem with that definition of a cone is that it is a function of two variables, r and h. Because we eventually want a function h(t), we'll need to 'get rid' of r, which means we'll need a piece of information relating r to h. Luckily we have one.

Notice that the cone and the inner cone of liquid are similar, exactly in the sense of the similar triangles you learned in geometry, so the ratio of their radii and heights are the same. So we have:

Rearranging gives us r(h),

We'll need r2, which is

which we can insert into our volume function to get V(r):

Now we have two functions that give us the tank volume, the one we just made and the one that was given originally: Water flows into the tank at a rate of 0.5 m·h-1, which gives us the function

We can equate the two functions (after all, they represent exactly the same thing) like this:

Now solving for h gives us

Taking the third (cube) root of each side gives us our final function for the height of water in the tank as a function of time.

Here's how that looks on a graph, and it makes sense. At first, when the tank is narrow, the height grows rapidly, but as the area of the top of the water gets larger, it fills more slowly, and slowest right at the top, at a height of 12 m.


Always take a minute to ask, at the end of the problem, does my answer make sense?

Practice problems

First, here are some simple problems to practice putting one function inside of another. Practice these to get the hang of it.

Given the functions f(x), g(x), h(x) and k(x) below, find each of the values or compositions indicated in the problems that follow.

  1. f(-1)
  2. g(3)
  3. h(7)
  4. k(-3)
  5. f(g(x))
  1. g(f(x))
  2. h(k(x))
  3. k(f(x))
  4. k(g(x))
  5. g(g(x))
  1. h(h(-6))
  2. k(k(1))
  3. k(g(-2))
  4. h(h(h(x)))
  5. f(k(x))

You can help

This site is a one-person operation and a labor of love. If you can manage it, I'd appreciate anything you could give to help defray the cost of keeping up the domain name, server, search service and my time.

Creative Commons License   optimized for firefox
xaktly.com by Dr. Jeff Cruzan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. © 2012, Jeff Cruzan. All text and images on this website not specifically attributed to another source were created by me and I reserve all rights as to their use. Any opinions expressed on this website are entirely mine, and do not necessarily reflect the views of any of my employers. Please feel free to send any questions or comments to jeff.cruzan@verizon.net.