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).
I think the following can help. Define:$$a=x^2+x+{5\over 2}\\ b=6x+1$$and $g(x)=f(x+0.5)$, therefore$$g(a)g(b)=g(2ab)$$
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 &amp;= 6a\\ 4a^2 + ab &amp;= 7a\\ 10a^2 + 4ab &amp;= 16a\\ 3a^2 + 4ab + b^2 &amp;= 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$$