f(x) = ax - 1, g(x) = x^2 + 3x + 1
gf(x) = 4x^2 + ax + b.
to get gf(x) substitute f(x) in for each value of x in g(x).
gf(x) = (ax - 1)^2 + 3(ax - 1) + 1
gf(x) = a^2x^2 -2ax + 1 + 3ax - 3 + 1
gf(x) = a^2x^2 +ax - 1 combining common terms
gf(x) = 4x^2 + ax + b comparing and solving
4 = a^2
a = +or- 2
b = -1