Composite function
A composite function is formed when the output of the first function becomes the input of the second function.
Let f and g be functions and let x be the input of g. Then, g(x) is the output of function g.
g(x) is the input of function f and the output of function f is f(g(x))
f(g(x) is the composite function of f and g and it is defined as (f ∘ g)(x) = f(g(x))
We can also let x be the input of f. Then, f(x) is the output of function f.
f(x) is the input of function g and the output of function g is g(f(x))
g(f(x) is a composite function of g and f and it is defined as (g ∘ f)(x) = g(f(x))
Example
Let f(x) = x + 5 and let g(x) = x2
Find g ∘ f and f ∘ gTo find g ∘ f, we need to let x be the input of f.
g ∘ f(x) = g(f(x)) = g(x + 5)
Now this is when it is tricky! g(x) = x2
Notice that after we do the composition of functions g and f, x is replaced with x + 5 in g(x). We need to do the same thing with x2 and replace x with x + 5
g(f(x)) = g(x + 5) = (x + 5)2
= x2 + 5x + 5x + 25
= x2 + 10x + 25
f ∘ g(x) = f(g(x)) = f(x2)
f(x) = x + 5
Notice that after we do the composition of functions f and g, x is replaced with x2 in f(x). We need to do the same thing with x + 5 and replace x with x2
f(g(x)) = f(x2) = x2 + 5
Be careful ! g(f(x)) is not equal to f(g(x)) although it may in some cases.