Associated Topics || Dr. Math Home || Search Dr. Math

### Composing Functions

```
Date: 12/02/98 at 10:23:05
From: David Schoolcraft
Subject: Pre-calc

I'm trying to find f-of-g where f(x) = 2x and g(x) = 3x^2 + 1.
```

```
Date: 12/02/98 at 12:51:04
From: Doctor Rick
Subject: Re: Pre-calc

Hi, David.

To evaluate, say, f(3), you would substitute 3 for the x in f(x) = 2x,
so that

f(3) = 2*3 = 6

To evaluate the composition of the functions f and g, you do the same
thing, except that the thing you substitute for x is an expression,
not just a number.

f(g(x)) = f(3x^2 + 1)
= 2*(3x^2 + 1)
= 6x^2 + 2

Do you see what I did? It might be easier to see if we use a different
variable in the definition of f(x). It's just a place-holder, anyway.

f(y) = 2 y  = 2*(3x^2 + 1)
^
|
----+---
y = g(x) = 3x^2 + 1

- Doctor Rick, The Math Forum
http://mathforum.org/dr.math/
```

```
Date: 12/06/98 at 11:20:55
From: Doctor Maryanthe
Subject: Re: Pre-calc

Hi David! Thanks for writing Dr. Math.

It looks to me like you're composing functions. Here's how this works.

Let me run through functions just a minute before I explain composition
- you'll probably recognize what I'm saying, but I want to make sure
we're on the same page.

Remember that a function is just a machine that takes in a value,
changes it according to a certain rule, and returns the changed value.
So

f(x) = 2x means that "every time I put a number in the function, I
get back twice the number I put in"

g(x) = 3x^2 + 1 means "every time I put in a number, the rule is to
square it, multiply it by 3, add 1 and give it back to me"

So the question is: what happens when I put functions together?
F-of-g-of-x means: "I put a number into the function g, which does
something to the number and generates an answer. However, instead of
giving me the number back, g gives the number to f, which does
something else to it and then gives me the finished product."

Remember to start with what you know (x) and go one step at a time.
g-of-f-of-h-of-m-of-x means:

1. Put x into m. Get an answer.
2. Put that answer into h. Get another answer.
3. Put that answer into f. Get another answer.
4. Put that answer into G. Get the final answer.

So, with "nested-function" problems, there are really two ways to go
about actually solving them.

1. Plug the values in to the functions in order of nesting, as
described above.  Or

2. Simplify the expression first, and then plug in the value of x.

Concretely: Solve g-of-f-of-x, f(x) = 2x, g(x) = 3x^2 + 1, x = 5.
We'll use each method.

1. f(5) = (5) * 2 = 10
g(10) = 3*(10)^2+1 = 301
So the final answer is 301.

2. f(x) = 2x
Take the number f(x) returns and plug it into g:
g(2x) = 3(2x)^2 + 1
= 3(4x^2)+1
= 12x^2 + 1

Now we plug in x=5:

12(5)^2 + 1 = 12 * 25 + 1 = 301 (the same answer!)

In short, Method 1 works if you want to figure out the answer for a
particular x, and Method 2 is a good way to figure out the rule for
what exactly is going to happen to your x as a result of going through
all these functions. It gives you an idea of the compound effects, and
you can plug in a particular number to the compound rule and still get

So, for the functions you gave, we don't care about a particular value
for a particular x, we just want to know the compound effects of
putting x through both functions, so we use method 2 to get the rule:

g(x) = 3x^2+1
f(3x^2 + 1) = 2(3x^2 +1) = 6x^2 + 2

Does the rule make sense?

Hope this helps.

- Doctor Maryanthe, The Math Forum
http://mathforum.org/dr.math/
```
Associated Topics:
High School Functions

Search the Dr. Math Library:

 Find items containing (put spaces between keywords):   Click only once for faster results: [ Choose "whole words" when searching for a word like age.] all keywords, in any order at least one, that exact phrase parts of words whole words

Submit your own question to Dr. Math
Math Forum Home || Math Library || Quick Reference || Math Forum Search