Ask Your Question
1

Check if a symbolic polynomial is positive

asked 2020-07-26 21:18:29 +0100

zzzwz gravatar image

Is there a way to check if a symbolic polynomial has all positive coefficients?

something like, (x^2+y+2xy).is_positive() = True (x+y-xy).is_positive()=False?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-07-26 22:52:39 +0100

Florentin Jaffredo gravatar image

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
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2020-07-26 21:18:29 +0100

Seen: 666 times

Last updated: Jul 26 '20