Recall that composing functions is little more than taking the output of one function, then plugging it into another function as input.
We can take this same idea and apply it to functions defined by tables of values.
For example, let \(f\) and \(g\) be defined according to the table below.
\(x\) | \(f(x)\) | \(g(x)\) |
0 | 2 | 3 |
1 | 5 | 4 |
2 | 3 | 0 |
3 | 0 | 2 |
4 | 1 | 1 |
5 | 4 | 5 |
We can find the result of, for example, \(f(g(1))\) by first finding \(g(1)=4\) and then taking that output of \(4\) and using that as input for \(f\), effectively chaining the two functions together. The final result is \(f(g(1))=f(4)=1\).
Similarly, if one wanted to compute \(g(f(2))\), we first compute \(f(2)=3\) and plug that output of \(f\) into \(g\) as input. Thus, \(g(f(2))=g(3)=2\).
One can, in some cases, build a new function via composition using tables. This is done by feeding the outputs of one function into another as inputs. The table below shows the result of composing \(f\circ g\) and \(g\circ f\).
\(x\) | \(f(g(x))\) | \(g(f(x))\) |
0 | \(f(g(0))=f(3)=0\) | \(g(f(0))=g(2)=0\) |
1 | \(f(g(1))=f(4)=1\) | \(g(f(1))=g(5)=5\) |
2 | \(f(g(2))=f(0)=2\) | \(g(f(2))=g(3)=2\) |
3 | \(f(g(3))=f(2)=3\) | \(g(f(3))=g(0)=3\) |
4 | \(f(g(4))=f(1)=5\) | \(g(f(4))=g(1)=4\) |
5 | \(f(g(5))=f(5)=4\) | \(g(f(5))=g(4)=1\) |
\(x\) | \(f(x)\) | \(g(x)\) |
0 | 1 | 2 |
1 | 3 | 4 |
2 | 5 | 0 |
3 | 2 | 2 |
4 | 4 | 0 |
5 | 0 | 4 |
\(f(g(1))=f(4)=4\). First, find \(g(1)\), then plug the result into \(f\).
\(f(g(4))=f(0)=1\). First, find \(g(4)\), then plug the result into \(f\).
\(g(f(2))=g(5)=4\). First, find \(f(2)\), then plug the result into \(g\).
\(g(f(5))=g(0)=2\). First, find \(f(5)\), then plug the result into \(g\).
\(x\) | \(h(x)\) | \(g(x)\) | \(h(g(x))\) | \(g(h(x))\) |
-1 | 0 | 1 | ||
0 | -1 | -1 | ||
1 | 2 | 2 | ||
2 | 1 | 0 |
\(x\) | \(h(x)\) | \(g(x)\) | \(h(g(x))\) | \(g(h(x))\) |
-1 | 0 | 1 | 2 | -1 |
0 | -1 | -1 | 0 | 1 |
1 | 2 | 2 | 1 | 0 |
2 | 1 | 0 | -1 | 2 |
\(x\) | \(h(x)\) | \(g(x)\) | \(h(g(x))\) | \(g(h(x))\) |
\(-1\) | \(0\) | \(1\) | \(h(g(-1))=h(1)=0\) | \(g(h(-1))=g(0)=-1\) |
\(0\) | \(-1\) | \(-1\) | \(h(g(0))=h(-1)=0\) | \(g(h(0))=g(-1)=1\) |
\(1\) | \(2\) | \(2\) | \(h(g(1))=h(2)=1\) | \(g(h(1))=g(2)=0\) |
\(2\) | \(1\) | \(0\) | \(h(g(2))=h(0)=-1\) | \(g(h(2))=g(1)=2\) |
To compute the \(h(g(x))\) column, we are plugging in each possible \(x\) value into \(g\) first, and then taking the output and feeding it immediately into the function \(h\).
Then, for the \(g(h(x))\) column, we plug in each possible \(x\) value into \(h\) first, then take the output of \(h\) and plug that immediately into \(g\). All of this is expressed in the table just above.