Ask Your Question
1

Variable elimination in Sage

asked 2020-06-01 20:12:06 +0100

mathdude94 gravatar image

updated 2020-06-02 11:25:20 +0100

FrédéricC gravatar image

Besides maxima.eliminate, are there any other functions in Sage that can be used to eliminate variables in a system of equations? Eg. those that use algorithms other than Maxima?

edit retag flag offensive close merge delete

Comments

Could you please provide a concrete example of system you are considering, and which behaviour you expect ?

tmonteil gravatar imagetmonteil ( 2020-06-01 22:40:25 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2020-06-06 01:29:35 +0100

dan_fulea gravatar image

updated 2020-06-06 01:30:15 +0100

Here is an example using the avatar of ideals in polynomial rings, algorithms are using Gröbner bases or related techniques. Let us consider the system: $$ \left\{ \begin{aligned} x^2+y^2+z^2 &= 14\ ,\\ xy+yz+zx &= 11\ ,\\ xyz - y^2 &= 2\ . \end{aligned} \right. $$ So we associate the ideal generated by "these equations" inside the ring $\Bbb Q[x,y,z]$, and ask for partial eliminations. For instance:

R.<x,y,z> = PolynomialRing(QQ)
gens = [ x^2 + y^2 + z^2 - 14, x*y + y*z + z*x -11, x*y*z - y^2 -2]
J = R.ideal(gens)
J.elimination_ideal([x,y])

And we get as result of the last elimination, here explicitly required once more in the ipython sage console:

sage: J.elimination_ideal([x, y])                                                                                                                             
Ideal (z^12 + 2*z^11 - 25*z^10 - 40*z^9 + 329*z^8 - 4*z^7 - 1763*z^6 
        + 3984*z^5 + 2475*z^4 - 43722*z^3 + 75942*z^2 - 60588*z + 23409) 
of Multivariate Polynomial Ring in x, y, z over Rational Field

(Result was manually rearranged to fit in the landscape.)

We can ask for the factorization of the above polynomial:

sage: J.elimination_ideal([x, y]).gens()[0].factor()                                                                                                          
(z - 3) * (z - 1) * (z^4 - 7*z^3 + 22*z^2 - 42*z + 51) * (z^6 + 13*z^5 + 65*z^4 + 137*z^3 + 69*z^2 - 66*z + 153)

So we already expect solutions of the given equations having $z=1$, and/or having $z=3$. Since the associated variety is a set of points, we can ask for this points:

sage: J.variety()                                                                                                                                             
[{z: 3, y: 2, x: 1}, {z: 1, y: 2, x: 3}]

We can also ask for partial eliminations of one variable:

J.elimination_ideal([x]) 
J.elimination_ideal([y]) 
J.elimination_ideal([z])

The same works also in the case we have "fewer equations". For instance:

J = R * [ x^2 + y^2 + z^2 - 1, x*y + y*z + z*x - 3]
print( f"J is {J}" )
J.elimination_ideal(z)

And we obtain:

J is Ideal (x^2 + y^2 + z^2 - 1, x*y + x*z + y*z - 3)
    of Multivariate Polynomial Ring in x, y, z over Rational Field
Ideal (x^4 + 2*x^3*y + 3*x^2*y^2 + 2*x*y^3 + y^4 - x^2 - 8*x*y - y^2 + 9)
    of Multivariate Polynomial Ring in x, y, z over Rational Field
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

1 follower

Stats

Asked: 2020-06-01 20:12:06 +0100

Seen: 1,663 times

Last updated: Jun 06 '20