# Function Composition

### Function Composition Calculator

$f(x)=$

$g(x)=$

### Function Inputs & Outputs

When you see something like $f(g(x))$ or $(f∘g)x$, you have function composition.

First off, think of handling functions like doing a find & replace.

When we have a function like $f(x)=4x_{2}+6x+5,$ plugging an input in for $x$ means finding & replacing every $x$ with the input value. For example, if our input is $3$, we find & replace to get:

$f(x)=4(x)_{2}+6(x)+5$⬇️

$f(3)=4(3)_{2}+6(3)+5$And you have to make sure you replace every $x.$ It's like how they had to replace every creepy Sonic with the new, cute Sonic, otherwise the creepiness would still be there ☠️.

If you need more help with functions, check out our functions lesson and calculator here!

### What is Function Composition?

The idea behind function composition is that instead of a number, another function acts as the input.

So, let's say we have these two functions:

$f(x)g(x) =4x_{2}+6x+5=2x+1 $If we're asked for $f(g(x)),$ then our input is $g(x),$ and we need to replace every $x$ in $f(x)$ with $g(x):$

$f(x)=4(x)_{2}+6(x)+5$⬇️

$f(g(x))=4(g(x))_{2}+6(g(x))+5$

And since we know that $g(x)=2x+1$, we can simplify $f(g(x))$ by using $2x+1$ instead of $g(x)$ on the right side:

$f(g(x))=4(2x+1)_{2}+6(2x+1)+5$

And that's how we get $f(g(x))!$

### Plugging in a Value

Now, if we're asked for $f(g(3))$ instead of $f(g(x)),$ then we need to do another find & replace to replace every $x$ in our new $f(g(x))$ equation with our input value of $3:$

$f(g(x))=4(2x+1)_{2}+6(2x+1)+5$

⬇️

$f(g(3))=4(2(3)+1)_{2}+6(2(3)+1)+5$

Then we have all numbers on the right side of the equation, and we can just calculate to find our final answer of $f(g(3))=243.$

### Graphing Function Composition

You might get the functions in graph forms, like this:

$f(x)$

$g(x)$

In this case, we use our graphs to find the function composition. Let's say we're asked for $f(g(1)).$

This means, first we need to find what $g(1)$ is. Let's look at our graph for $g(x)$ where our $x=1:$

$g(x)$

Looking at the point on the line where $x=1,$ we can see that the $y$ value is $2.$ This means that $g(1)=2.$

Now, if we go back to our original composition of $f(g(1)),$ we can replace $g(1)$ with $2$ to get $f(g(1))=f(2).$

Now, we just look at our graph of $f(x)$ at the point where $x=2:$

$f(x)$

Looking at the point on the line where $x=2,$ we can see that the $y$ value is $4.$ This means that $f(2)=4.$

So to review, to solve for $f(g(1)),$ we first needed to find the value of $g(1).$ Once we found that $g(1)=2,$ we replaced $g(1)$ with $2$ to get:

$f(g(1))=f(2)$Looking at the graph for $f(x),$ we find:

$f(g(1))=f(2)=4$#### Function Composition through Graphs

Let's say we're looking for $f(g(3)).$

#### Step 1: Find the inner value.

First, we use the graph for $g(x)$ to find the value of $g(3).$

#### Step 2: Plug in the inner value.

Next, we plug in the value we found into the composition. Let's say we found that our value was $2.$ We plug that into our composition to replace $g(3)$ to get $f(g(3))=f(2).$

#### Step 3: Find the final value.

Finally, we use the graph for $f(x)$ to find the value of $f(2).$ Once we do that, we're done!