PolynomialSumOfSquaresList[f,vars]
attempts to find polynomials with real coefficients {f1,…,fn} such that f==f12+…+fn2.
PolynomialSumOfSquaresList
PolynomialSumOfSquaresList[f,vars]
attempts to find polynomials with real coefficients {f1,…,fn} such that f==f12+…+fn2.
Details
- PolynomialSumOfSquaresList is typically used to show that a real polynomial is non-negative.
- f should be a polynomial in vars with real numeric coefficients.
Examples
open all close allBasic Examples (1)
Find a sum-of-squares representation of a polynomial:
PolynomialSumOfSquaresList[x ^ 2 + x y + y ^ 2, {x, y}]x ^ 2 + x y + y ^ 2 - %.%//ExpandA polynomial representable as a sum of squares is non-negative:
Plot3D[{x ^ 2 + x y + y ^ 2, 0}, ...]Scope (6)
Find a sum-of-squares representation of a polynomial:
PolynomialSumOfSquaresList[x ^ 4 + x y + y ^ 2 + 1 / 60, {x, y}]x ^ 4 + x y + y ^ 2 + 1 / 60 - %.%//ExpandThe polynomial is non-negative:
Plot3D[{x ^ 4 + x y + y ^ 2 + 1 / 60, 0}, ...]Find a sum-of-squares representation of a polynomial with exact real numeric coefficients:
PolynomialSumOfSquaresList[E x ^ 2 + Sqrt[2] x y + Pi y ^ 4 + Log[2], {x, y}]E x ^ 2 + Sqrt[2] x y + Pi y ^ 4 + Log[2] - %.%//ExpandFind a sum-of-squares representation of a polynomial with machine-precision real coefficients:
f = 1.23 x ^ 2 + 4.56 x y + 7.89 y ^ 4 + 3.21x ^ 2z ^ 6 + 9.87;PolynomialSumOfSquaresList[f, {x, y, z}]The difference of
and the sum of squares has small coefficients:
f - %.%//ExpandFind a sum-of-squares representation of a polynomial with arbitrary-precision real coefficients:
f = 1.23`20 x ^ 2 + 4.56`20 x y + 7.89`20 y ^ 4 + 3.21`20x ^ 2z ^ 6 + 9.87`20;PolynomialSumOfSquaresList[f, {x, y, z}]The difference of
and the sum of squares has arbitrary-precision zero coefficients:
f - %.%//ExpandA polynomial may not be representable as a sum of squares:
PolynomialSumOfSquaresList[x ^ 4 + x y + y ^ 2, {x, y}]The polynomial attains negative values, hence it cannot be a sum of squares:
FindInstance[x ^ 4 + x y + y ^ 2 < 0, {x, y}]Show[Plot3D[{x^4 + x y + y^2, 0}, {x, -1, 1}, {y, -1, 1}, ...], Graphics3D[{Red, Arrow[{{x, y, 1}, {x, y, x^4 + x y + y^2}} /. %[[1]]]}]]PolynomialSumOfSquaresList may fail even if a sum-of-squares representation exists:
PolynomialSumOfSquaresList[16 x^4 + 16 x y + 16 y^4 + 2, {x, y}]Expand[16 x^4 + 16 x y + 16 y^4 + 2 - ((4 y^2 - 1)^2 + (2 Sqrt[2] (x + y))^2 + (4 x^2 - 1)^2)]Applications (1)
Prove non-negativity of a large polynomial:
f = 717 + 6 u + 77 u^2 + 87 u^4 + 14 v + 10 u v - 6 u^3 v + 43 v^2 + 10 u v^2 + 205 u^2 v^2 + 20 u v^3 + 38 v^4 + 26 x + 66 u x + 36 u^2 x - 90 u^3 x - 14 v x + 38 u v x - 14 u^2 v x + 8 v^2 x - 2 x^2 + 239 u^2 x^2 - 44 u v x^2 + 27 v^2 x^2 - 12 v x^3 + 25 x^4 + 62 y - 184 u y + 2 u^2 y + 14 u^3 y - 42 v y - 32 u v y - 94 u^2 v y + 14 u v^2 y + 16 v^3 y - 30 x y + 16 u x y - 106 u^2 x y - 6 v x y - 38 u v x y - 10 v^2 x y + 6 x^2 y + 32 x^3 y + 83 y^2 + 22 u y^2 + 501 u^2 y^2 + 10 v y^2 + 108 u v y^2 + 146 v^2 y^2 - 14 u x y^2 + 48 v x y^2 + 42 x^2 y^2 - 24 y^3 - 6 u y^3 - 4 v y^3 + 66 y^4 - 14 z + 154 u z + 74 u^2 z - 4 u^3 z + 110 v z - 38 u v z + 10 u^2 v z - 22 v^2 z + 18 u v^2 z + 12 v^3 z - 6 x z - 52 u x z + 64 u^2 x z - 2 v x z + 10 u v x z - 12 v^2 x z - 4 u x^2 z + 158 y z + 70 u y z - 66 u^2 y z + 8 v y z - 106 u v y z + 4 v^2 y z - 8 x y z - 42 u x y z + 36 v x y z - 6 x^2 y z + 6 y^2 z + 60 u y^2 z - 22 v y^2 z + 40 z^2 - 10 u z^2 + 251 u^2 z^2 - 12 v z^2 + 100 u v z^2 + 251 v^2 z^2 - 20 x z^2 + 6 u x z^2 + 4 v x z^2 + 56 x^2 z^2 - 30 y z^2 - 108 u y z^2 + 74 v y z^2 - 16 x y z^2 + 210 y^2 z^2 + 8 z^3 - 10 u z^3 + 22 v z^3 - 40 y z^3 + 121 z^4;Compute a sum-of-squares representation:
(ff = PolynomialSumOfSquaresList[f, {x, y, z, u, v}];)//AbsoluteTiming
is a sum of squares, hence it is non-negative:
f - ff.ff//ExpandFindInstance uses a method based on sum-of-squares representation here:
FindInstance[f < 0, {x, y, z, u, v}]//AbsoluteTimingDeciding non-negativity of f using CylindricalDecomposition takes much more time:
TimeConstrained[CylindricalDecomposition[f < 0, {x, y, z, u, v}], 300]Properties & Relations (3)
A polynomial that has a sum-of-squares representation is non-negative:
f = x ^ 2 + 2y ^ 2 + 3 z ^ 2 - x y - x z - y z;PolynomialSumOfSquaresList[f, {x, y, z}]Use FindInstance to show that
is non-negative:
FindInstance[f < 0, {x, y, z}]The Motzkin polynomial is non-negative, but is not a sum of squares:
f = x ^ 4 y ^ 2 + x ^ 2 y ^ 4 - 3 x ^ 2 y ^ 2 + 1;PolynomialSumOfSquaresList[f, {x, y}]Use Resolve to show that
is non-negative:
Resolve[ForAll[{x, y}, f >= 0], Reals]Use MinValue to find the infimum of values of a polynomial:
f = 16 x^4 + 16 x y + 16 y^4;m = MinValue[f, {x, y}]PolynomialSumOfSquaresList fails for the non-negative polynomial
:
PolynomialSumOfSquaresList[f - m, {x, y}]PolynomialSumOfSquaresList succeeds for the strictly positive polynomial
:
PolynomialSumOfSquaresList[f - m + 1 / 100, {x, y}]%.% - f + m - 1 / 100//ExpandPossible Issues (1)
PolynomialSumOfSquaresList may fail even if a sum-of-squares representation exists:
PolynomialSumOfSquaresList[16 x^4 + 16 x y + 16 y^4 + 2, {x, y}]Expand[16 x^4 + 16 x y + 16 y^4 + 2 - ((4 y^2 - 1)^2 + (2 Sqrt[2] (x + y))^2 + (4 x^2 - 1)^2)]See Also
Related Guides
History
Text
Wolfram Research (2021), PolynomialSumOfSquaresList, Wolfram Language function, https://reference.wolfram.com/language/ref/PolynomialSumOfSquaresList.html.
CMS
Wolfram Language. 2021. "PolynomialSumOfSquaresList." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PolynomialSumOfSquaresList.html.
APA
Wolfram Language. (2021). PolynomialSumOfSquaresList. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PolynomialSumOfSquaresList.html
BibTeX
@misc{reference.wolfram_2026_polynomialsumofsquareslist, author="Wolfram Research", title="{PolynomialSumOfSquaresList}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/PolynomialSumOfSquaresList.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_polynomialsumofsquareslist, organization={Wolfram Research}, title={PolynomialSumOfSquaresList}, year={2021}, url={https://reference.wolfram.com/language/ref/PolynomialSumOfSquaresList.html}, note=[Accessed: 12-June-2026]}