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.Sat, 12 Nov 2016 15:32:53 -0600Simplify expressions with more variables related to each other?http://ask.sagemath.org/question/35545/simplify-expressions-with-more-variables-related-to-each-other/Is it possible to simplify expressions with more variables such like
(x^3 + 2x + 1)/y where y^2 = x^3 + x +1?
Using the relation between x and y the expression then becomes
(x^3 + x + 1 + x)/y = (y^2 + x)/y = y + x/y
Is it possible in Sage? Is Sage able to check in which form the expression (only in x, only in y, mixing) is the simplest?Sat, 12 Nov 2016 09:12:07 -0600http://ask.sagemath.org/question/35545/simplify-expressions-with-more-variables-related-to-each-other/Answer by tmonteil for <p>Is it possible to simplify expressions with more variables such like</p>
<p>(x^3 + 2x + 1)/y where y^2 = x^3 + x +1?</p>
<p>Using the relation between x and y the expression then becomes</p>
<p>(x^3 + x + 1 + x)/y = (y^2 + x)/y = y + x/y</p>
<p>Is it possible in Sage? Is Sage able to check in which form the expression (only in x, only in y, mixing) is the simplest?</p>
http://ask.sagemath.org/question/35545/simplify-expressions-with-more-variables-related-to-each-other/?answer=35547#post-id-35547It is doable as follows. Assuming that `y^2 = x^3 + x +1` is like working in a quotient polynomial ring modulo the ideal generated by `-y^2 + x^3 + x +1`. To be able to make polynomial divisions, you just have to extend your quotient polynomial ring into its fraction field:
sage: R = PolynomialRing(QQ,'x,y') ; R
Multivariate Polynomial Ring in x, y over Rational Field
sage: R.inject_variables()
Defining x, y
sage: I = R.ideal([-y^2 + x^3 + x +1]) ; I
Ideal (x^3 - y^2 + x + 1) of Multivariate Polynomial Ring in x, y over Rational Field
sage: Q = R.quotient(I) ; Q
Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^3 - y^2 + x + 1)
sage: F = Q.fraction_field() ; F
Fraction Field of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^3 - y^2 + x + 1)
sage: F((x^3 + 2*x + 1)/y)
(ybar^2 + xbar)/ybar
Sat, 12 Nov 2016 10:46:20 -0600http://ask.sagemath.org/question/35545/simplify-expressions-with-more-variables-related-to-each-other/?answer=35547#post-id-35547Comment by Thrash for <p>It is doable as follows. Assuming that <code>y^2 = x^3 + x +1</code> is like working in a quotient polynomial ring modulo the ideal generated by <code>-y^2 + x^3 + x +1</code>. To be able to make polynomial divisions, you just have to extend your quotient polynomial ring into its fraction field:</p>
<pre><code>sage: R = PolynomialRing(QQ,'x,y') ; R
Multivariate Polynomial Ring in x, y over Rational Field
sage: R.inject_variables()
Defining x, y
sage: I = R.ideal([-y^2 + x^3 + x +1]) ; I
Ideal (x^3 - y^2 + x + 1) of Multivariate Polynomial Ring in x, y over Rational Field
sage: Q = R.quotient(I) ; Q
Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^3 - y^2 + x + 1)
sage: F = Q.fraction_field() ; F
Fraction Field of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^3 - y^2 + x + 1)
sage: F((x^3 + 2*x + 1)/y)
(ybar^2 + xbar)/ybar
</code></pre>
http://ask.sagemath.org/question/35545/simplify-expressions-with-more-variables-related-to-each-other/?comment=35552#post-id-35552I also thought about just putting additional parameters/variables into the polynomial ring. It seems to work, thanks! The simplifications I tried exemplarily are usable.
Is there a way to substitute xbar by x (visually) and so on?Sat, 12 Nov 2016 15:32:53 -0600http://ask.sagemath.org/question/35545/simplify-expressions-with-more-variables-related-to-each-other/?comment=35552#post-id-35552Comment by tmonteil for <p>It is doable as follows. Assuming that <code>y^2 = x^3 + x +1</code> is like working in a quotient polynomial ring modulo the ideal generated by <code>-y^2 + x^3 + x +1</code>. To be able to make polynomial divisions, you just have to extend your quotient polynomial ring into its fraction field:</p>
<pre><code>sage: R = PolynomialRing(QQ,'x,y') ; R
Multivariate Polynomial Ring in x, y over Rational Field
sage: R.inject_variables()
Defining x, y
sage: I = R.ideal([-y^2 + x^3 + x +1]) ; I
Ideal (x^3 - y^2 + x + 1) of Multivariate Polynomial Ring in x, y over Rational Field
sage: Q = R.quotient(I) ; Q
Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^3 - y^2 + x + 1)
sage: F = Q.fraction_field() ; F
Fraction Field of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^3 - y^2 + x + 1)
sage: F((x^3 + 2*x + 1)/y)
(ybar^2 + xbar)/ybar
</code></pre>
http://ask.sagemath.org/question/35545/simplify-expressions-with-more-variables-related-to-each-other/?comment=35551#post-id-35551I guess it depends on what you want. For example, if you add `k` as an undeterminate in the polynomial ring `R`, you will get:
sage: F((x^3 + 2*x + 1)/y)
(ybar^2 - xbar*kbar + 2*xbar)/ybar
If you want to try for some small integer values of `k`, you can just make a loop.Sat, 12 Nov 2016 14:50:23 -0600http://ask.sagemath.org/question/35545/simplify-expressions-with-more-variables-related-to-each-other/?comment=35551#post-id-35551Comment by Thrash for <p>It is doable as follows. Assuming that <code>y^2 = x^3 + x +1</code> is like working in a quotient polynomial ring modulo the ideal generated by <code>-y^2 + x^3 + x +1</code>. To be able to make polynomial divisions, you just have to extend your quotient polynomial ring into its fraction field:</p>
<pre><code>sage: R = PolynomialRing(QQ,'x,y') ; R
Multivariate Polynomial Ring in x, y over Rational Field
sage: R.inject_variables()
Defining x, y
sage: I = R.ideal([-y^2 + x^3 + x +1]) ; I
Ideal (x^3 - y^2 + x + 1) of Multivariate Polynomial Ring in x, y over Rational Field
sage: Q = R.quotient(I) ; Q
Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^3 - y^2 + x + 1)
sage: F = Q.fraction_field() ; F
Fraction Field of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^3 - y^2 + x + 1)
sage: F((x^3 + 2*x + 1)/y)
(ybar^2 + xbar)/ybar
</code></pre>
http://ask.sagemath.org/question/35545/simplify-expressions-with-more-variables-related-to-each-other/?comment=35549#post-id-35549Thanks!
What if I have a relation, for example between x, y and an additional k, and I want that output of the simplified expression to be the simplest with respect to x and y as above (because I consider k just a parameter)? In other words: For example, is a parameter-dependent ideal
sage: I = R.ideal([-y^2 + x^3 + k*x +1])
be possible if R stays the same as defined originally? Or do I have to match anything in order to get what I want?Sat, 12 Nov 2016 13:16:29 -0600http://ask.sagemath.org/question/35545/simplify-expressions-with-more-variables-related-to-each-other/?comment=35549#post-id-35549