g(x) = x - 3
h(x) = 3x + 1
To find g(h(x)), you have to replace x = h(x) into g(x), as follows:
g(h(x)) = (3x + 1) - 3
g(h(x)) = 3x + (1 - 3)
g(h(x)) = 3x - 2
To find h(h(x)), you have to replace x = h(x) into h(x), as follows:
h(h(x)) = 3(3x + 1) + 1
h(h(x)) = 3(3x) + 3(1) + 1
h(h(x)) = 9x + 3 + 1
h(h(x)) = 9x + 4