TITLE: How to compose two functions?
QUESTION [6 upvotes]: I have three functions: 

$$f(x) = x+1 ,\; g(x) = x - 1 ,\; h(x) = 2x$$

I want to find $g\circ f$ such that $g(f(x))$, which equals $(x+1)-1=x$ but how? 
I don't understand the steps.
Also, I want to find $h\circ f$ which equals $h(f(x)) = 2x-1$ but I dont know how to get that answer either.
Thanks

REPLY [28 votes]: The function $f$ will take an input and return an output equal to one more than the input.
$f(\underbrace{\color{red}{x}}) = \underbrace{\color{red}{x}}+1$
Similarly $f(\underbrace{\color{red}{55}})=\underbrace{\color{red}{55}}+1$ and $f(\underbrace{\color{red}{8x^2-3}})=\underbrace{\color{red}{8x^2-3}}+1$
The function $g$ will take an input and return an output equal to one less than the input.
$g(\underbrace{\color{blue}{x}})=\underbrace{\color{blue}{x}}-1$
So, we have $(g\circ f)(x)=g(\underbrace{\color{blue}{f(x)}}) = g(\underbrace{\color{blue}{x+1}})=(\underbrace{\color{blue}{x+1}})-1 = x+1-1=x$
Similar manipulation can be done for $h$

REPLY [2 votes]: $g(f(x))$ means you substitute $f(x)$ in wherever you see $x$ in $g(x)$, therefore we get $g(f(x)) = (x+1)-x = x$
Performing the same for $h(f(x))$, we get $h(f(x)) = 2(x+1) = 2x + 2$