A polynomial $f\in K[x]$ is a sum of squares (SOS) if it can be written as $$f = \sum_i d_i g_i^2,$$ where the $g_i$ are polynomials in $K[x]$ and the $d_i$ are positive weights in $K$. This data type stores polynomials as sums of squares. The type is a hash table consisting of the polynomials to be squared and summed (the 'generators'), corresponding coefficients, and the base ring. We can construct an object of type SOSPoly from the result of sumofsquares problem. See SDPResult for more on this.




One can also construct an object of type SOSPolys by specifying all their ingredients.



The ingredients of a sum of squares can be recovered using the expected commands.



The length of a sumofsquares polynomial is the number of squares.

Sums of squares support many common operations with polynomials.




The actual polynomial can be recovered using value(SOSPoly).

We can also produce a formal Expression.

Objects of type SOSPoly support the substitute command. This cannot be used to change the coefficient field, though. See coefficient field for some of the limitations.

