xaktly | Functions

Compositions of

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)) = (x^2 + 2) + 2 = x^2 + 4$$


$$ \begin{align} g(f(x)) &= (x + 2)^2 + 2 \\ &= (x + 2)(x + 2) + 2 \\ &= x^2 + 4x + 6 \end{align}$$

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))$.

Solutions: We start with our two original functions

$$f(x) = x + 1 \;\;\;\; g(x) = 3x - 1$$

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.

$$f(g(x)) = f(3x - 1)$$

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

$$f(g(x)) = (3x - 1) + 1$$

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

$$f(g(x)) = 3x$$

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

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

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

$$g(f(x)) = 3(x + 1) + 1$$

Finally, simplifying yields our new composite function:

$$ \begin{align} g(f(x)) &= 3x + 3 - 1 \\ &= 3x + 2 \end{align}$$

Example 2

Now let's look at some more complicated functions. If   $f(x) = x^2 + 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.

Solutions: Here's   $f(g(x))$

$$ \begin{align} f(g(x)) &= (-2x - 1)^2 + 1 \\ &= (4x^2 + 4x + 1) + 1 \\ &= 4x^2 + 4x + 2 \end{align}$$

$g(f(x))$   goes like this:

$$ \begin{align} g(f(x)) &= -2 (x^2 + 1) - 1 \\ &= -2x^2 - 2 - 1 \\ &= -2x^2 - 3 \end{align}$$

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

$$ \begin{align} f(f(x)) &= (x^2 + 1)^2 + 1 \\ &= x^4 + 2x^2 + 1 + 1 \\ &= x^4 + 2x^2 + 2 \end{align}$$

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

$$ \begin{align} g(g(x)) &= -2(-2x - 1) - 1 \\ &= 4x + 2 - 1 \\ &= 4x + 1 \end{align}$$

Example 3

The number of widgets* (n) produced by a factory after t hours of operation is modeled by the function  $n(t) = 1000t - 8t^2$. 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.

Solution: 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:

$$ \begin{align} C(t) &= 10,000 + 350(1000t - 8t^2) \\ &= 10,000 + 350,000t - 2800t^2 \end{align}$$

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.

Solution: 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:

$$\frac{H}{R} = \frac{h}{r} \; \longrightarrow \; r = \frac{Rh}{h}$$

Rearranging gives us r(h),

$$r = \frac{10 h}{12} = \frac{5h}{6}$$

We'll need r2, which is

$$r^2 = \frac{25 h^2}{36}$$

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

$$V(h) = \frac{25 \pi h^3}{108}$$

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

$$V(t) = 0.5 t$$

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

$$0.5 t = \frac{25 \pi h^3}{108}$$

Now solving for h gives us

$$h^3 = \frac{54 t}{25 \pi}$$

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.

$$h = \sqrt[3]{\frac{54 t}{25 \pi}}$$

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.

Pro tip

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

Practice problems

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))$
6. $g(f(x))$
7. $h(k(x))$
8. $k(f(x))$
9. $k(g(x))$
10. $g(g(x))$
11. $h(h(-6))$
12. $k(k(1))$
13. $k(g(-2))$
14. $h(h(h(x)))$
15. $f(k(x))$
16. The area of a circle as a function of its radius, r, is A = πr2. Express the area of a circle as a function of its circumference, c = 2πr.
17. The volume of a sphere of radius r is V = (4/3)πr3. The surface area of a sphere is A = 4πr2. Write a function for the volume of a sphere as a function of the surface area, V(A).

The volume of a cube is V = L3, where L is the length of one edge. Write a function V(d) for the volume of a cube as a function of the length of a diagonal (d) drawn between opposite corners of the cube, as shown:

19. The area of an isosceles triangle is A = ½bh, where b and h are the lengths of the base and the height of the triangle, respectively. Write a function for the area of an isosceles triangle with independent variables b, the width of the base and θ, one of the two (equivalent) base angles.
20. The cost of maufacturing n widgets depends on the number of widgets made, n, and on the cost of one material, m. The cost function is C(n, m) = 2.4n3/2m. The cost of that material is, in turn, a function of two factors, the cost of raw material r, and the cost of labor, L, according to the function m = 9.2 Lr. Write a function for the cost of manufacturing n widgets with independent variables n, r and L.

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.