Ask Your Question
0

Absolute value of a polynomial

asked 2017-06-29 20:23:21 +0200

anonymous user

Anonymous

How can I generate a random polynomial with two variables x, y of fix degree which is not of type : <type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular' ?

I would like to compute the absolute value of this polynomial, but when I generate it using : R = ZZ['x','y']; F = R.random_element(4, 1000)

for example, I get : TypeError: bad operand type for abs(): 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'

What would be a good alternative to get |F(x,y)| ? Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-06-30 10:39:03 +0200

tmonteil gravatar image

updated 2017-06-30 10:39:33 +0200

You can turn your polynomial into a symbolic expression, then it is possible to take its absolute value:

sage: f = SR(F) ; f
-x^3*y - x^2*y^2 + x*y^3 + y^4 - x^3 - 3*x^2*y + 9*x*y^2 + 2*y^3 + x^2 - x*y + 3*x + 2*y + 1
sage: g = abs(f) ; g
abs(-x^3*y - x^2*y^2 + x*y^3 + y^4 - x^3 - 3*x^2*y + 9*x*y^2 + 2*y^3 + x^2 - x*y + 3*x + 2*y + 1)
sage: g.parent()
Symbolic Ring
sage: g(x=2,y=3)
258
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

1 follower

Stats

Asked: 2017-06-29 20:23:21 +0200

Seen: 353 times

Last updated: Jun 30 '17