# Composition of Functions

### What Is a Composition of Functions?

The composition of functions is defined by using the output of one function as the input of another.

A function is a relation (set of ordered pairs) in which each element of the domain corresponds to exactly one element of the range. The domain of a function is the set of first coordinates of the ordered pairs in the function. A value in the domain of a function is called the input. The range of a function is the set of second coordinates of the ordered pairs in the function. A value in the range of a function is called the output.

Combining two functions by using the output of one as the input for the other is called composition of functions. The composition of functions $f$ and $g$ is shown with symbols as:
$(f \circ g)(x)=f(g(x))$
Composite notation uses a small circle, as in $(f \circ g)(x)$. It can also be written using nested function, as in $f(g(x))$. Both forms can be read as "$f$ of $g$ of $x$."

The composition of two functions can be used to solve different types of problems, including conversion problems. If one function converts kilometers to meters and another converts meters to centimeters, then the composition converts kilometers to centimeters.

Step-By-Step Example
Use Composition to Convert Units
Write a function $g(x)$ for converting kilometers to meters and a function $f(x)$ for converting meters to centimeters. Then write the composite function $f(g(x))$ for converting kilometers (km) to centimeters (cm). Show how the simple functions and composite function convert 5 km to centimeters.
Step 1
Write a function $g(x)$ for converting kilometers to meters.
\begin{aligned}\text{kilometers}&\rightarrow\text{meters}\\g(x)&=1,\!000x\end{aligned}
Step 2
Write a function $f(x)$ for converting meters to centimeters.
\begin{aligned}\text{meters}&\rightarrow\text{centimeters}\\f(x)&=100x\end{aligned}
Step 3
Write the composite function $f(g(x))$ for converting kilometers to centimeters.
\begin{aligned}\text{kilometers}&\rightarrow\text{centimeters}\\ f(g(x))&=f(1,\!000x)\\&=100(1,\!000x)\\&=100,\!000x\end{aligned}
Solution
Show how the simple functions and composite function convert 5 km to centimeters.
\begin{aligned}\text{kilometers}&\rightarrow\text{meters}\\g(x)&=1,\!000x\\g(5)&=1,\!000(5)\\&=5,\!000\end{aligned}
\begin{aligned}\text{meters}&\rightarrow\text{centimeters}\\f(x)&=100x\\f(5,\!000)&=100(5,\!000)\\&=500,\!000\end{aligned}
\begin{aligned}\text{kilometers}&\rightarrow\text{centimeters}\\f(g(x))&= 100,\!000x\\f(g(5)) &= 100,\!000(5)\\&=500,\!000\end{aligned}

### Evaluating Composite Functions

To evaluate the composition of two functions $f(g(x))$ for a value of $x$, first find $g(x)$ and then substitute the value in $f$, or find a general rule for $f(g(x))$ and then evaluate for the value of $x$.

The composition of two functions $f(g(x))$ is evaluated by first finding the value of $g(x)$ and then substituting that value into $f(x)$ and evaluating. This can be thought of as placing an input into a function to arrive at an output and then using that value as an input of a second function to get a final output.

For example:
\begin{aligned}f(x)&=100-3x\\g(x)&=5x+9\end{aligned}
With the initial input 3, the final output is:
$f(g(3))=28$
A general rule for $f(g(x))$ can be found by replacing the variable in $f(x)$ with the function rule from $g(x)$ to find that:
$f(g(x))=73-15x$
The general rule yields:
$f(g(3))=28$
The functions $f(x)$ and $g(x)$ can be composed in different ways. For example, $f(g(x))$, $g(f(x))$, and $g(g(x))$. When evaluating the composition of two functions, always evaluate the inside function first, and then use the result to evaluate the outside function.
The composition of functions can also be evaluated using their graphs. The coordinates of points on the graphs of the functions are used to determine the input and output values for each function.
Step-By-Step Example
Evaluating a Composition of Functions from a Graph
Use the graph to identify the function:
$(f\circ g)(-1)$
Step 1
Write the composite notation $(f\circ g)(-1)$ using nested functions.
$(f\circ g)(-1)=f(g(-1))$
Step 2

Use the graph to evaluate the inside function, $g(x)$, at $x=-1$ to find $g(-1)$.

Find the point on the graph of $g(x)$ where $x=-1$. Then determine the value of $g(x)$ at that point. The point is $(-1,2)$, so $g(-1)=2$.
Solution
Substitute and evaluate the outside function, $f(x)$, at $x=2$ to identify:
$f(g(-1))=f(2)$
Find the point on the graph of $f(x)$, where $x=2$. Then determine the value of $f(x)$ at that point. The point is $(2,4)$, so:
$f(2)=f(g(-1))=4$
In composite notation:
$(f\circ g)(-1)=4$

### Determining Composite Functions and Their Domains

To determine the rule for a composite function $f(g(x))$, substitute $g(x)$ into $f(x)$ and simplify. The domain of $f(g(x))$ is the set of values in the domain of $g$ for which $g(x)$ is in the domain of $f$.
To write the rule for a composite function, substitution for one function is used. For example, the expression $2x+3$ of this given function is the function rule:
$g(x)=2x+3$
Substituting the function rule into $f(x)$ results in the rule for a composite function. That means replacing each instance of the variable in the function $f(x)$ with the expression from $g(x)$.
Step-By-Step Example
Identifying the Rule for a Composite Function
Use the given functions to identify $f(g(x))$:
$f(x)=x^2-3x$
$g(x)=2x+3$
Step 1
Substitute the rule for $g(x)$ into $f$ in place of $x$.
$f(g(x))=(2x+3)^2-3(2x+3)$
Step 2
Simplify.
\begin{aligned}f(g(x))&=(2x+3)^2-3(2x+3)\\&=(4x^2+12x+9)-6x-9\\&=4x^2+6x\end{aligned}
Solution
$f(g(x))=4x^2+6x$

The domain of f(g(x)) is all the values of $x$ that meet the conditions that:

• $x$ is in the domain of $g$.
• $g(x)$ is in the domain of $f$.

The domain of $f(g(x))$ may be all or only part of the domain of $g$. When a value in the domain of $g$ produces an output that is not in the domain of $f$, the value is not in the domain of $f(g(x))$.

To determine the domain of the composite function $f(g(x))$, write the composite function rule and find its domain. Then consider any values of $x$ that are not in the domain of $g$. A value of $x$ that makes $g(x)$ undefined must be excluded from the domain of $f(g(x))$.

For example, if $f(x)=\sqrt{x-8}$ and $g(x)=x-3$, first find the composite function $f(g(x))$. Then find its domain.
\begin{aligned}f(g(x))&=\sqrt{(x-3)-8}\\&=\sqrt{x-11}\end{aligned}
The value under the square root cannot be negative, so the domain of $f(g(x))$ is $x \geq 11$. The domain of $g$ is all real numbers (all rational and irrational numbers), so there are no other values that must be excluded from the domain of $f(g(x))$.

There are often values that must be excluded from the domain of the composite function when the separate functions involve rational expressions with the variable in the denominator.

Step-By-Step Example
Determining the Domain of a Composite Function with Rational Expressions
Two functions are given:
$f(x)=\frac{3}{x}$
$g(x)=\frac{1}{x}$
First, identify the composite function $f(g(x))$, and then find its domain.
Step 1
Find $f(g(x))$.
$f(g(x))=\frac{3}{\frac{1}{x}}$
Step 2
Simplify. Multiply the numerator and denominator by $x$.
\begin{aligned}f(g(x))&=\frac{3}{\frac{1}{x}}\\&=\frac{3\cdot x}{\frac{1}{x}\cdot x}\\&=\frac{3x}{1}\\&=3x\end{aligned}
Solution
Determine the domain of $f(g(x))$.
$f(g(x))=3x$
The domain of $f(g(x))=3x$ is all real numbers. However, $g(x)$ is undefined when $x=0$ because the value in the denominator of this function cannot be zero:
$g(x)=\frac{1}{x}$
This means zero is not in the domain of $f(g(x))$.

So the domain of $f(g(x))$ can be written as $x\neq0$.