It's a trivial result that if $a,b$ are integers then there is an integer $c$ such that $c^2 = (a^2)(b^2)$
A slightly deeper result is that if $a,b$ are integers such that $a = u_a^2 + v_a^2$ (for integers $u_a, v_a$) and $b = u_b^2 + v_b^2$ (for integers $u_a, v_b$) then $c = ab$ can also be decomposed into the form $u_c^2 + v_c^2$ where $u_c, v_c$ are integers.
This motivates a natural question:
For which multivariate polynomials (interpreted as functions) $ p: \mathbb{Z}^n \rightarrow \mathbb{Z}$ is it the case:
That if you have two elements $a,b \in \mathbb{Z}$ such that there are are $\hat{u}_a, \hat{u}_b \in \mathbb{Z}^n$ where $ a = p(\hat{u}_a), b = p( \hat{u}_b)$
that there must exist a $\hat{u}_c \in \mathbb{Z}^n $ such that $ab = p(\hat{u}_c)$
Is there a classification of such polynomials? When is it possible to "algebraically" express the components of $\hat{u}_c$ in terms of the components of $\hat{u}_a, \hat{u}_b$?
It seems that if $p_1, p_2$ are two such polynomials (over the same number of $n$ variables) then $p_3 = p_1 p_2$ will obviously have the property [so the space of these polynomials clearly forms a semi-group] and there is some notion of "primality" that could be made here for fixed $n$.
It also follows that if $p$ has the entirety of the integers in its image then the rule trivially follows. (It might be much less interesting however)
Are there any known references on this set of polynomials?
This naturally generalizes for almost all rings, but i'll focus it over the integers first.