Ask Your Question
2

Declare arithmetic with formal variables

asked 11 years ago

Zach H gravatar image

I want to create variables in SAGE and and declare arithmetic relations between them. For example, it is easy enough to declare that x1, ..., xn and y1, ..., yn be variables. Is there a way to state that

xi*xj = 0 (in the ring of polynomials, if necessary)

or that

x1 < y1 < x2 < y2 < ...?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 11 years ago

tmonteil gravatar image

In the algebraic way, you can do something like:

sage: R.<x,y> = PolynomialRing(ZZ) ; R
Multivariate Polynomial Ring in x, y over Integer Ring
sage: I = R.ideal(x*y)
sage: I
Ideal (x*y) of Multivariate Polynomial Ring in x, y over Integer Ring
sage: S = R.quotient_ring(I) ; S
Quotient of Multivariate Polynomial Ring in x, y over Integer Ring by the ideal (x*y)
sage: S(3*x*y+x^2+4*y)
xbar^2 + 4*ybar

In the symbolic way, you can do (but it is much less reliable):

sage: var('x y')
(x, y)
sage: assume(x*y==0)
sage: bool(3*x*y+x^2+4*y == x^2+4*y)
True

But is seems not able to decide simplifications by itself:

sage: (3*x*y+x^2+4*y).full_simplify()
x^2 + (3*x + 4)*y

For the orderings, you can also work symbolically:

sage: var('x y')
(x, y)
sage: assume(x<y)
sage: bool(3*x<3*y)
True
Preview: (hide)
link

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: 11 years ago

Seen: 499 times

Last updated: Jan 03 '14