Suppose a polynomial $P(x,y)$ is given and it is to be written in terms of two base polynomials $R(x,y)$ and $S(x,y)$. How does Mathematica do this?
The assumption is that $P$ will turn out to be a polynomial in $R$ and $S$. For example $P=x^6+3x^4y^2+3x^2y^4+y^6+5x^2y^4$ and $R=x^2+y^2$ and $S=xy^2$. The program is to produce $P=R^3+5S^2$.