How to compose two functions
To find a composite function, substitute the whole inner function in place of every variable in the outer function, working from the inside out, because the output of the inner function becomes the input of the outer one.
A worked example
Let f(x) = 2x + 1 and g(x) = x² − 3. To find f(g(x)), replace x in f with the expression for g: f(g(x)) = 2(x² − 3) + 1 = 2x² − 5. To evaluate f(g(2)), work from the inside: g(2) = 4 − 3 = 1, and then f(1) = 3, which agrees with 2(2)² − 5 = 3.
The mistake people actually make
Composition isn't multiplication, and the order matters: f(g(x)) and g(f(x)) are usually different functions. For g(f(x)) here, you would square the whole expression 2x + 1.