# Composition of Functions

## Composition of Functions:

Let f : A-> B and g : B -> C be two functions. Then the composition of f and g, denoted by gof, is defined as the function gof : A -> C given by
gof=g(f(x) for all x ∈ A

Example
f(x) =(x+3)
g(x) =x2

gof=g(f(x))=g(x+3)=(x+3)2
Similarly
fog=f(g(x))=f(x2)=x2 +3

In this case
fog ≠ gof

Example
1. Consider f : N -> N, g : N -> N and h : N -> R defined as
$f(x) = 2x$,$g(y) = 3y + 4$ and $h(z) = sin z$, for x, y and z in N.
Show that ho(gof ) = (hog) of.
Solution
We have
ho(gof) (x) = h(gof (x)) = h(g(f (x))) = h(g(2x))
= h(3(2x) + 4) = h(6x + 4) = sin (6x + 4) for x in N.
Also,
((hog)o f ) (x) = (hog) ( f (x)) = (hog) (2x) = h ( g (2x))
= h(3(2x) + 4) = h(6x + 4) = sin (6x + 4), for x in N.
This shows that ho(gof) = (hog) of

2. Given $f(x) = x^2 + 1$ and $g(x) = 5x +3$, find
(a) (f o g)(x)
(b) (g o f)(x)
Solution
(a) (f o g)(x)
$= f(5x+3)$
$= (5x+3)^2 + 1$
$= 25x^2 + 30x + 9 + 1$
$= 25x^2 + 30x + 10$
(b) (g o f)(x)
$= g(x^2 + 1)$
$= 5(x^2 + 1) + 3$
$= 5x^2 + 8$