I am hoping this question is alright for Math Overflow. I didn't get a definitive solution in [Math Stack Exchange](https://math.stackexchange.com/questions/4667105/if-a-homogeneous-polynomial-is-the-square-of-a-polynomial-modulo-x2-y2-1).


Let $f(x, y) \in \mathbb{R}[x, y]$ be a **homogeneous** polynomial with real coefficients in $2$ determinates $x , y$. Suppose that
$$f(x, y) \equiv g(x, y)^2 \pmod{x^2 + y^2 - 1}$$
for some polynomial $g(x, y)$, where $g(x, y)$ is not necessarily homogeneous.


Is it true that there exists **homogeneous** polynomials $h\_1(x, y), \dots, h\_n(x, y)$ such that
$$f(x, y) \equiv h\_1(x, y)^2 + \cdots + h\_n(x, y)^2 \pmod{x^2 + y^2 - 1}?$$



Modulo $x^2 + y^2 - 1$, is every homogeneous polynomial that is a square of a polynomial, necessarily of sum of squares of homogeneous polynomials?
Yes. Will Sawin's answer uses a topological fact about the unit circle in $\mathbb{R}^2$. Here is an answer replacing $\mathbb{R}$ with any field of characteristic not $2$.


First, working modulo $x^2+y^2-1$, we can multiply terms of $g$ with powers of $x^2+y^2$, so we can assume $g = g\_{2k} + g\_{2k+1}$ for some $k$, where each $g\_i$ is homogeneous of degree $i$. For convenience write these as $g\_0,g\_1$.


Observe that


$$ f \equiv (g\_0 + g\_1)^2 \equiv (g\_0^2(x^2+y^2) + g\_1^2) + 2 g\_0 g\_1 \pmod{x^2+y^2-1}. $$


There is a polynomial $h$ so that


$$ f + (x^2+y^2-1)h = (g\_0^2(x^2+y^2) + g\_1^2) + 2 g\_0 g\_1 . $$


Write $h = h\_0 + h\_1$ where $h\_0$ is all the terms of even degree and $h\_1$ is all the terms of odd degree (these are not necessarily homogeneous).


The first case is if $f$ is homogeneous of odd degree. In this case


$$ f + (x^2+y^2-1)h\_1 = 2 g\_0 g\_1, \qquad (x^2+y^2-1)h\_0 = g\_0^2(x^2+y^2) + g\_1^2 $$


In the second equation the right hand side is homogeneous. The only way for the left hand side to be homogeneous is to have $h\_0 = 0$. Then $g\_0^2(x^2+y^2) + g\_1^2 = 0$,
but $x^2+y^2$ is not a perfect square (or negative of a perfect square) outside of characteristic $2$. So it must be $g\_0=g\_1=0$, and then $f \equiv 0$.


If $f$ is homogeneous of even degree then


$$ f + (x^2+y^2-1)h\_0 = g\_0^2(x^2+y^2) + g\_1^2, \qquad (x^2+y^2-1)h\_1 = 2 g\_0 g\_1 $$


Since $x^2+y^2-1$ is irreducible outside characteristic $2$ (in characteristic $2$ it's equal to $(x+y+1)^2$) it must be either $g\_0 \equiv 0$ or $g\_1 \equiv 0$ modulo $x^2+y^2-1$.


So then $f \equiv g\_1^2$ or $f \equiv g\_0^2$. These are the same polynomials that Will Sawin's answer ends with.


