Ask Your Question

a1846583's profile - activity

2016-06-17 10:03:41 +0100 received badge  Famous Question (source)
2015-12-14 18:02:24 +0100 received badge  Notable Question (source)
2015-10-26 07:05:37 +0100 received badge  Popular Question (source)
2014-12-02 11:09:13 +0100 received badge  Teacher (source)
2014-12-02 11:09:13 +0100 received badge  Self-Learner (source)
2014-12-02 07:09:45 +0100 received badge  Editor (source)
2014-12-02 07:09:22 +0100 commented answer Declaring variable to be in a particular field/ring/group

Some more head-smacking revealed I can take a quotient to get what I wanted; see my self-answer above. Thanks again for your feedback!

2014-12-02 07:07:43 +0100 answered a question Declaring variable to be in a particular field/ring/group

I think I found a workaround: make x not be the variable of the polynomial ring but rather that of the quotient of that ring by the ideal generated by z^2-z. In other words:

var('X'); x=PolynomialRing(Integers(3), 'X').quotient([X^2-1], 'x').gens()[0]
print x^3==x and x^2==1 and 3*x==0

evals to True

2014-12-01 18:52:34 +0100 received badge  Student (source)
2014-11-30 00:32:26 +0100 received badge  Scholar (source)
2014-11-30 00:32:24 +0100 commented answer Declaring variable to be in a particular field/ring/group

Thanks for your answer. I guess there are two issues here: 1) the feature request you point out as #9935 to make mod work with symbolic expressions; and 2) that sage should know that PolynomialRing(Integers(3)) doesn't need to track powers higher than 2 (and generally that PR(I(p)) doesn't need to track powers higher than p-1). Is that natural fallout from #9935 or do you think that deserves its own feature request?

At any rate, it seems the short answer to my original question is "it's not possible (yet)". Unless you can think of a workaround?

2014-11-28 17:44:44 +0100 asked a question Declaring variable to be in a particular field/ring/group

Is it possible to have Sage symbolically simplify expressions involving variables subject to the assumption that the variables take values in a defined domain (field/ring/group/etc)?

The closest I've gotten is to declare a dummy polynomial ring over my domain of interest so that its variable has some notion of the domain, e.g.:

Z3=Integers(3)
Dummy.<x> = PolynomialRing(Z3)
3*x

evaluates to "0" as I'd expect, but sage fails to simplify "x^3" to "x", which ISTM should be doable if it really understood that x is a variable in Z/3Z.

Related things I've found in my searches that haven't panned out:
1. var('x', domain=foo) -- apparently foo can only be one of real/complex/positive (where I'd like to be able to say 'Z3' in the example above)
2. assume('x is Z3') - doesn't seem to have any effect.