Let f(x)=ax+b, x∈R, and g(x)=x+d, x∈R, then fog=gof if and only if
f(a)=g(c)
f(d)=g(b)
f(b)=g(d)
f(c)=g(a)
f(g(x))=g(f(x)) for all x∈R⇔f(cx+d)=g(ax+b)⇔ a(cx+d)+b=c(ax+b)+d⇔ad+b=cb+d⇔ f(d)=g(b)