Find all function $f(x)$ such that $f(x^2 + x + 3)f(3x + 1) = f(6x^3 + 7x^2 + 16x + 3), \forall x \in \mathbb R$. 
Find all function $f(x)$ such that $$\large f(x^2 + x + 3)f(3x + 1) = f(6x^3 + 7x^2 + 16x + 3), \forall x \in \mathbb R$$

I have provided my solution but there isn't a strong claim for why $f(x)$ is in the form of $(ax + b)^n$ where $a, b \in \mathbb R, n \ge 1$ (as Luca Bressan suggested). 

It can be seen that $f(x) = (ax + b)^n$ $(a, b \in \mathbb R, n \ge 1)$. We have that $$[a(x^2 + x + 3) + b][a(3x + 1) + b] = a(6x^3 + 7x^2 + 16x + 3) + b, \forall x \in \mathbb R$$
$$\iff a^2(3x^3 + 4x^2 + 10x + 3) + ab(x^2 + 4x + 4) + b^2$$
$$ = a(6x^3 + 7x^2 + 16x + 3) + b, \forall x \in \mathbb R$$
$$\iff 3a^2x^3 + (4a^2 + ab)x^2 + (10a^2 + 4ab)x + (3a^2 + 4ab + b^2)$$
$$ = 6ax^3 + 7ax^2 + 16ax + (3a + b), \forall x \in \mathbb R$$
$$\implies \left\{ \begin{align} 3a^2 &= 6a\\ 4a^2 + ab &= 7a\\ 10a^2 + 4ab &= 16a\\ 3a^2 + 4ab + b^2 &= 3a + b\end{align} \right., \forall x \in \mathbb R$$
$$\iff (a, b) \in \{(0, 0), (0, 1), (2, -1)\} \iff f(x) \in \{0, 1, (2x - 1)^n\}, \forall x \in \mathbb R, n \ge 1$$
