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

edit retag close merge delete

Sort by ยป oldest newest most voted

It 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

more

Thanks!

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?

( 2016-11-12 13:16:29 -0500 )edit

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

( 2016-11-12 14:50:23 -0500 )edit

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

( 2016-11-12 15:32:53 -0500 )edit