Let us understand the composition of two functions from the following real-life situation.
Suppose that you are about to buy a set of fruits in a grocery.
in supermarket.jpg
The billing for the fruits is based on the weight of each fruit.
This is where the composition of functions takes place.
You load each fruit into the weighing machine. The system is programmed in such a way that it displays the price of each fruit you buy based on its weight.
Let \(A\) be the set of all fruits.
Let \(B \subset \mathbb{R}\) be the set of all weights or quantity of the fruits you bought and \(C \subset \mathbb{R}\) be the set of all prices for each fruit.
This process of buying fruits in a grocery is represented using an arrow diagram as follows:
The above process gives rise to two functions say \(f: A \rightarrow B\) and \(g: B \rightarrow C\) given by \(b = f(a)\) which is the weight or quantity of each fruit \(a\) and \(c = g(b)\) which is the price per fruits for the required quantity \(b\), where \(a \in A\), \(b \in B\) and \(c \in C\).
The whole process can be mathematically written as follows:
\(c = g(b) = g\left(f(a)\right)\)
Therefore, by combining the above two functions, each fruit is eventually rated with a particular price.
Based on this illustration, we will define the composition of two functions as follows.
Let \(f: A \rightarrow B\) and \(g: B \rightarrow C\) be two functions. Then the composition of \(f\) anf \(g\) denoted by \(g \circ f\) is defined as the function \(g \circ f(x) = g\left(f(x)\right)\) for all \(x \in A\).