ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 03 Jan 2014 01:30:09 -0600Declare arithmetic with formal variableshttp://ask.sagemath.org/question/10863/declare-arithmetic-with-formal-variables/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 < ...?
Fri, 27 Dec 2013 17:50:04 -0600http://ask.sagemath.org/question/10863/declare-arithmetic-with-formal-variables/Answer by tmonteil for <p>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</p>
<p>xi*xj = 0 (in the ring of polynomials, if necessary)</p>
<p>or that </p>
<p>x1 < y1 < x2 < y2 < ...?</p>
http://ask.sagemath.org/question/10863/declare-arithmetic-with-formal-variables/?answer=15883#post-id-15883In 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
Fri, 03 Jan 2014 01:30:09 -0600http://ask.sagemath.org/question/10863/declare-arithmetic-with-formal-variables/?answer=15883#post-id-15883