Ask Your Question
2

Declare arithmetic with formal variables

asked 2013-12-28 00:50:04 +0100

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 < ...?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-01-03 08:30:09 +0100

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
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: 2013-12-28 00:50:04 +0100

Seen: 465 times

Last updated: Jan 03 '14