Consider two linear function $f(x) = m_fx + b_f $ and $g(x) = m_gx + b_g $.

There is a very important way to combine these functions that is fundamental to understanding linear functions and a vast number of other functions:
First find $g(x)$, then find $f(g(x))$. 

We can see this as a new function called the composition of $f$ with $g$ , denoted usually as $f \circ g$.
So $(f \circ g)(x) = f(g(x))$ and $f \circ g : x \rightarrow g(x) \rightarrow f(g(x))$.

In this section we will study how mapping diagrams visualize and illuminate some fundamental features of linear functions by understanding composition. Though a visualization of composition is possible with graphs, the simplicity of the mapping diagram for composition makes it the choice for visualization as a learning tool. But first we will formally define the key concept of function composition.

Definition: FC Function Composition.

Two linear examples.
In these two examples we use GeoGebra to visualize composition for linear functions.
Example LF.COMP.1 : $ f(x) = 2x -1; g(x) = 3x + 2$
Example LF.COMP.2 $ g(x) = 2x - 1; f(x) = 3x + 2$


Compositions are a key to understanding linear functions. the key result is not hard to understand, but is very useful.

Theorem LF.COMP

This result says linear functions are built by composing two core linear functions: constant addition and scalar multiplication.
Here is an example that visualizes the theorem.

Example LF.COMP.3 Suppose $ g(x) =3x$ and  $f(x)=x+2$ then $(f \circ g)(x) = 3x + 2;$

You can use this next dynamic example with GeoGebra to investigate further the effects of composition in a mapping diagram  of $f$ composed with a mapping diagram of $g$.

Example LF.DCOMP.0 Dynamic Visualization of Composition for Linear Functions: Graphs, and Mapping Diagrams