| 1 | initial version |
How did you define x and y? If you simply use
sage: x, y = var('x, y')
then Sage has now way of knowing what is a variable and what is a coefficient in you polynomial. Still, for one variable it is possible to do:
sage: p = 4*x^2+2*x+1
sage: all([coef>=0 for coef, degree in p.coefficients(x)])
True
For multivariate polynomials you should use PolynomialRing:
sage: PXY.<x, y> = PolynomialRing(QQ)
sage: p = x^2+y+2*x*y
sage: all([coef>=0 for coef in p.coefficients()])
True
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.