ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 05 Mar 2011 14:54:49 +0100Method for solving a large system of under-determined equations?https://ask.sagemath.org/question/7966/method-for-solving-a-large-system-of-under-determined-equations/I am trying to parametrize and find a family of solutions to some equations. (I am using the `solve([eqns],vars)` function.) Unfortunately, the equations are just complicated enough so that rather than parametrize, sage gives up and outputs the equations themselves.
Here is a (partial) particular example that I had in mind. My real equation is actually a bit more complicated. But this is a point where it went from solving to simply spitting out the original equations. Here is the output:<p>
`10 equations, and 12 unknowns.
{s0 + s2 + s4: 1}
{s5: 0}
{s0 + s1 + s2 + s3 + s4 + s5: 2}
{w0: s5}
{w1: -s4}
{w2: s3}
{(s0*w0 + s1*w1)*(s0*w0 + s1*w1 + s2*w2): s2*w0 + s3*w1}
{w3: -s2}
{w4: s1}
{w5: -s0}`
Is there anything I can do? I've read the solve and x.solve pages, but I don't see a clear method I should try...
===========
Edit: I'm looking for the simplest representation of this system of equations. I would like Sage to parametrize a few of the variables and solve for the others.
For instance, a linear system example would be the following:<p>
`eq1=a+b+c==2`<br>
`eq2=b==1`<br>
`solve([eq1,eq2],a,b,c)`<br>
The output would be:<br>
`a=1-r1, b=1, c=r1`
Sage can do this using the `solve` function for small simple situations, even if they're non-linear equations. I want it to classify the family of all possible (real) solutions which satisfy all of the equations simultaneously. But it's stopping when I have a complicated system of equations.
In essence I want it to "solve" the system of equations. Clearly this requires a few parameters, since there are more variables than equations... and since it's not a linear system I can't just ask a linear algebra student to do it. ;-)Wed, 23 Feb 2011 21:30:43 +0100https://ask.sagemath.org/question/7966/method-for-solving-a-large-system-of-under-determined-equations/Answer by Volker Braun for <p>I am trying to parametrize and find a family of solutions to some equations. (I am using the <code>solve([eqns],vars)</code> function.) Unfortunately, the equations are just complicated enough so that rather than parametrize, sage gives up and outputs the equations themselves.</p>
<p>Here is a (partial) particular example that I had in mind. My real equation is actually a bit more complicated. But this is a point where it went from solving to simply spitting out the original equations. Here is the output:</p><p>
<code>10 equations, and 12 unknowns.
{s0 + s2 + s4: 1}
{s5: 0}
{s0 + s1 + s2 + s3 + s4 + s5: 2}
{w0: s5}
{w1: -s4}
{w2: s3}
{(s0*w0 + s1*w1)*(s0*w0 + s1*w1 + s2*w2): s2*w0 + s3*w1}
{w3: -s2}
{w4: s1}
{w5: -s0}</code></p>
<p>Is there anything I can do? I've read the solve and x.solve pages, but I don't see a clear method I should try...</p>
<p>===========</p>
<p>Edit: I'm looking for the simplest representation of this system of equations. I would like Sage to parametrize a few of the variables and solve for the others.
For instance, a linear system example would be the following:</p><p>
<code>eq1=a+b+c==2</code><br/>
<code>eq2=b==1</code><br/>
<code>solve([eq1,eq2],a,b,c)</code><br/>
The output would be:<br/>
<code>a=1-r1, b=1, c=r1</code></p>
<p>Sage can do this using the <code>solve</code> function for small simple situations, even if they're non-linear equations. I want it to classify the family of all possible (real) solutions which satisfy all of the equations simultaneously. But it's stopping when I have a complicated system of equations.</p>
<p>In essence I want it to "solve" the system of equations. Clearly this requires a few parameters, since there are more variables than equations... and since it's not a linear system I can't just ask a linear algebra student to do it. ;-)</p>
https://ask.sagemath.org/question/7966/method-for-solving-a-large-system-of-under-determined-equations/?answer=12139#post-id-12139If you have an underdetermined polynomial system of equations, you should probably think of the solution as an algebraic variety.
sage: AA.<x,y> = AffineSpace(QQ, 2)
sage: X = AA.subscheme(x^2+y^2-1)
sage: X
Closed subscheme of Affine Space of dimension 2 over Rational Field defined by:
x^2 + y^2 - 1
sage: X.dimension()
1
Its not clear to me what you mean by "solve"... You should rephrase your question as either a geometric property of the variety or an algebraic property of the defining ideal.
Thu, 24 Feb 2011 07:21:27 +0100https://ask.sagemath.org/question/7966/method-for-solving-a-large-system-of-under-determined-equations/?answer=12139#post-id-12139Answer by Volker Braun for <p>I am trying to parametrize and find a family of solutions to some equations. (I am using the <code>solve([eqns],vars)</code> function.) Unfortunately, the equations are just complicated enough so that rather than parametrize, sage gives up and outputs the equations themselves.</p>
<p>Here is a (partial) particular example that I had in mind. My real equation is actually a bit more complicated. But this is a point where it went from solving to simply spitting out the original equations. Here is the output:</p><p>
<code>10 equations, and 12 unknowns.
{s0 + s2 + s4: 1}
{s5: 0}
{s0 + s1 + s2 + s3 + s4 + s5: 2}
{w0: s5}
{w1: -s4}
{w2: s3}
{(s0*w0 + s1*w1)*(s0*w0 + s1*w1 + s2*w2): s2*w0 + s3*w1}
{w3: -s2}
{w4: s1}
{w5: -s0}</code></p>
<p>Is there anything I can do? I've read the solve and x.solve pages, but I don't see a clear method I should try...</p>
<p>===========</p>
<p>Edit: I'm looking for the simplest representation of this system of equations. I would like Sage to parametrize a few of the variables and solve for the others.
For instance, a linear system example would be the following:</p><p>
<code>eq1=a+b+c==2</code><br/>
<code>eq2=b==1</code><br/>
<code>solve([eq1,eq2],a,b,c)</code><br/>
The output would be:<br/>
<code>a=1-r1, b=1, c=r1</code></p>
<p>Sage can do this using the <code>solve</code> function for small simple situations, even if they're non-linear equations. I want it to classify the family of all possible (real) solutions which satisfy all of the equations simultaneously. But it's stopping when I have a complicated system of equations.</p>
<p>In essence I want it to "solve" the system of equations. Clearly this requires a few parameters, since there are more variables than equations... and since it's not a linear system I can't just ask a linear algebra student to do it. ;-)</p>
https://ask.sagemath.org/question/7966/method-for-solving-a-large-system-of-under-determined-equations/?answer=12173#post-id-12173There is no closed form for the roots of a polynomial in general. So we'll have to assume that you can somehow compute roots.
One nice trick to get a parametrization is to compute a Groebner basis in lexicographic order. You need to put your parameters last in the order of variables. Say,
sage: R.<x,y,z> = PolynomialRing(QQ, order='lex')
sage: I = R.ideal([5*x - 1/3*y^2 - 2*y*z + y - 5/4*z^2, -3/2*x - 1/13*y*z + 4])
These are two (random) polynomial equations in three variables, so we expect the solution to be a curve. Indeed, it is:
sage: I.dimension()
1
It is also an irreducible curve, that is, not two curves that are disjoint or intersect in a point:
sage: I.primary_decomposition()
[Ideal (52*y^2 + 352*y*z - 156*y + 195*z^2 - 2080, 39*x + 2*y*z - 104) of Multivariate Polynomial Ring in x, y, z over Rational Field]
The Groebner basis in the given lexicographic order is:
sage: I.groebner_basis()
[x + 2/39*y*z - 8/3,
y^2 + 88/13*y*z - 3*y + 15/4*z^2 - 40]
The last variable (in the lexicographic order) is z, which we take to be the parameter. The second equation in the Groebner basis depends only on y and z, so if you plug in a value for z then it is a polynomial equation in a single variable. Solving this univariate polynomial equation yields multiple (in this case, two) solutions for y. Then plug y,z into the first equation of the Groebner basis. You get one polynomial equation in x, which you have to solve again. Hence, you have determined y(z) and x(y(z),z), that is, parametrized your curve by z.Sat, 05 Mar 2011 12:16:09 +0100https://ask.sagemath.org/question/7966/method-for-solving-a-large-system-of-under-determined-equations/?answer=12173#post-id-12173Comment by David Ferrone for <p>There is no closed form for the roots of a polynomial in general. So we'll have to assume that you can somehow compute roots. </p>
<p>One nice trick to get a parametrization is to compute a Groebner basis in lexicographic order. You need to put your parameters last in the order of variables. Say, </p>
<pre><code>sage: R.<x,y,z> = PolynomialRing(QQ, order='lex')
sage: I = R.ideal([5*x - 1/3*y^2 - 2*y*z + y - 5/4*z^2, -3/2*x - 1/13*y*z + 4])
</code></pre>
<p>These are two (random) polynomial equations in three variables, so we expect the solution to be a curve. Indeed, it is:</p>
<pre><code>sage: I.dimension()
1
</code></pre>
<p>It is also an irreducible curve, that is, not two curves that are disjoint or intersect in a point:</p>
<pre><code>sage: I.primary_decomposition()
[Ideal (52*y^2 + 352*y*z - 156*y + 195*z^2 - 2080, 39*x + 2*y*z - 104) of Multivariate Polynomial Ring in x, y, z over Rational Field]
</code></pre>
<p>The Groebner basis in the given lexicographic order is:</p>
<pre><code>sage: I.groebner_basis()
[x + 2/39*y*z - 8/3,
y^2 + 88/13*y*z - 3*y + 15/4*z^2 - 40]
</code></pre>
<p>The last variable (in the lexicographic order) is z, which we take to be the parameter. The second equation in the Groebner basis depends only on y and z, so if you plug in a value for z then it is a polynomial equation in a single variable. Solving this univariate polynomial equation yields multiple (in this case, two) solutions for y. Then plug y,z into the first equation of the Groebner basis. You get one polynomial equation in x, which you have to solve again. Hence, you have determined y(z) and x(y(z),z), that is, parametrized your curve by z.</p>
https://ask.sagemath.org/question/7966/method-for-solving-a-large-system-of-under-determined-equations/?comment=22017#post-id-22017Thank you very much Volker. This is very clear, and is exactly what I was looking for.Sat, 05 Mar 2011 14:54:49 +0100https://ask.sagemath.org/question/7966/method-for-solving-a-large-system-of-under-determined-equations/?comment=22017#post-id-22017