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, 26 Aug 2017 11:13:06 +0200Solving equations in polynomial ring if ideal is positive dimensionalhttps://ask.sagemath.org/question/38637/solving-equations-in-polynomial-ring-if-ideal-is-positive-dimensional/I will be outlining the situation, and at the bottom I will describe my actual `problems'.
I'm coming from [this question](https://ask.sagemath.org/question/38519/sage-wrongly-suggests-there-are-only-trivial-solutions-why/), nbruin suggested I use polynomial rings. I'm afraid I'm missing something here. What I did was the following.
P.<a1,a2,b1,b2,q> = QQ[]
def eq(a,b,c,d):
return q*(a**2 + b**2) + 2*(a*c + b*d)
I = ideal( eq(a1,a2,b1,b2), eq(b1,b2,a1,a2) )
B = I.groebner_basis()
Note that my equations are in fact only quadratic.
As I understand from [the wiki page on systems of polynomial equations](https://en.wikipedia.org/wiki/System_of_polynomial_equations#What_is_solving.3F), we can already tell - by looking at the reduced Gröbner basis - whether solutions exist at all.
Sage computes the reduced Gröbner basis, so here is $B$:
a1^3*b1 + a1*a2^2*b1 - a1*b1^3 + a1^2*a2*b2 + a2^3*b2 - a2*b1^2*b2 - a1*b1*b2^2 - a2*b2^3,
a1^2*q + a2^2*q + 2*a1*b1 + 2*a2*b2,
b1^2*q + b2^2*q + 2*a1*b1 + 2*a2*b2
So our system is not inconsistent, but unfortunately it is also not zero dimensional, which is why $\texttt{I.variety()}$ does not work.
________
My problems:
1.) $q$ is actually just a parameter in the underlying field, or rather in $\mathbb{R}$, that is: for given equations it is constant. But how do I use variables/constants in polynomial rings? I didn't find anything.
2.) In reality, I want to work over $\mathbb{R}$, but I read somewhere it is preferred to use $\texttt{QQ}$ or $\texttt{ZZ}$. Changing the base ring doesn't change the solvability tho (also not with $\texttt{QQbar}$)
3.) I know there are 4 one-parameter solutions for $\texttt{a1,a2,b1,b2}$. Is it possible to get sage to find an expression for them? ($\texttt{solve}$ finds them, but this is just a small example of much larger systems I want to solve)Thu, 24 Aug 2017 10:24:53 +0200https://ask.sagemath.org/question/38637/solving-equations-in-polynomial-ring-if-ideal-is-positive-dimensional/Comment by dan_fulea for <p>I will be outlining the situation, and at the bottom I will describe my actual `problems'.</p>
<p>I'm coming from <a href="https://ask.sagemath.org/question/38519/sage-wrongly-suggests-there-are-only-trivial-solutions-why/">this question</a>, nbruin suggested I use polynomial rings. I'm afraid I'm missing something here. What I did was the following.</p>
<pre><code>P.<a1,a2,b1,b2,q> = QQ[]
def eq(a,b,c,d):
return q*(a**2 + b**2) + 2*(a*c + b*d)
I = ideal( eq(a1,a2,b1,b2), eq(b1,b2,a1,a2) )
B = I.groebner_basis()
</code></pre>
<p>Note that my equations are in fact only quadratic. </p>
<p>As I understand from <a href="https://en.wikipedia.org/wiki/System_of_polynomial_equations#What_is_solving.3F">the wiki page on systems of polynomial equations</a>, we can already tell - by looking at the reduced Gröbner basis - whether solutions exist at all.</p>
<p>Sage computes the reduced Gröbner basis, so here is $B$:</p>
<pre><code>a1^3*b1 + a1*a2^2*b1 - a1*b1^3 + a1^2*a2*b2 + a2^3*b2 - a2*b1^2*b2 - a1*b1*b2^2 - a2*b2^3,
a1^2*q + a2^2*q + 2*a1*b1 + 2*a2*b2,
b1^2*q + b2^2*q + 2*a1*b1 + 2*a2*b2
</code></pre>
<p>So our system is not inconsistent, but unfortunately it is also not zero dimensional, which is why $\texttt{I.variety()}$ does not work.</p>
<hr>
<p>My problems:</p>
<p>1.) $q$ is actually just a parameter in the underlying field, or rather in $\mathbb{R}$, that is: for given equations it is constant. But how do I use variables/constants in polynomial rings? I didn't find anything.</p>
<p>2.) In reality, I want to work over $\mathbb{R}$, but I read somewhere it is preferred to use $\texttt{QQ}$ or $\texttt{ZZ}$. Changing the base ring doesn't change the solvability tho (also not with $\texttt{QQbar}$)</p>
<p>3.) I know there are 4 one-parameter solutions for $\texttt{a1,a2,b1,b2}$. Is it possible to get sage to find an expression for them? ($\texttt{solve}$ finds them, but this is just a small example of much larger systems I want to solve)</p>
https://ask.sagemath.org/question/38637/solving-equations-in-polynomial-ring-if-ideal-is-positive-dimensional/?comment=38653#post-id-38653There are a lot of "problems" with this toy example, so the message, but nothing is unexpected.
The Groebner basis `B` tells us that instead of solving algebraically the initial system, one can better solve it using `B`. Fine!
(1) `q` is an algebraic variable, so we cannot play games like $\sqrt{4-q^2}$. (Not even $1/q$.) We could pass to the fraction field of $\mathbb Q(q)$, then to its algebraic closure, not in sage yet. Sometimes it works a construction like:
S.<q> = QQ[]
S = S.fraction_field()
P.<a1,a2,b1,b2> = S[]
Not here. The model cannot be applied.
(2) Which is the question? The post comes first with `q` being transcendental. Now we want it to be in `QQbar`. (+ further positivity problems.)
(3) Similar to "Parametrize $x^2+y^2=1$". No algorithm so far.Thu, 24 Aug 2017 21:54:12 +0200https://ask.sagemath.org/question/38637/solving-equations-in-polynomial-ring-if-ideal-is-positive-dimensional/?comment=38653#post-id-38653Comment by Jo Be for <p>I will be outlining the situation, and at the bottom I will describe my actual `problems'.</p>
<p>I'm coming from <a href="https://ask.sagemath.org/question/38519/sage-wrongly-suggests-there-are-only-trivial-solutions-why/">this question</a>, nbruin suggested I use polynomial rings. I'm afraid I'm missing something here. What I did was the following.</p>
<pre><code>P.<a1,a2,b1,b2,q> = QQ[]
def eq(a,b,c,d):
return q*(a**2 + b**2) + 2*(a*c + b*d)
I = ideal( eq(a1,a2,b1,b2), eq(b1,b2,a1,a2) )
B = I.groebner_basis()
</code></pre>
<p>Note that my equations are in fact only quadratic. </p>
<p>As I understand from <a href="https://en.wikipedia.org/wiki/System_of_polynomial_equations#What_is_solving.3F">the wiki page on systems of polynomial equations</a>, we can already tell - by looking at the reduced Gröbner basis - whether solutions exist at all.</p>
<p>Sage computes the reduced Gröbner basis, so here is $B$:</p>
<pre><code>a1^3*b1 + a1*a2^2*b1 - a1*b1^3 + a1^2*a2*b2 + a2^3*b2 - a2*b1^2*b2 - a1*b1*b2^2 - a2*b2^3,
a1^2*q + a2^2*q + 2*a1*b1 + 2*a2*b2,
b1^2*q + b2^2*q + 2*a1*b1 + 2*a2*b2
</code></pre>
<p>So our system is not inconsistent, but unfortunately it is also not zero dimensional, which is why $\texttt{I.variety()}$ does not work.</p>
<hr>
<p>My problems:</p>
<p>1.) $q$ is actually just a parameter in the underlying field, or rather in $\mathbb{R}$, that is: for given equations it is constant. But how do I use variables/constants in polynomial rings? I didn't find anything.</p>
<p>2.) In reality, I want to work over $\mathbb{R}$, but I read somewhere it is preferred to use $\texttt{QQ}$ or $\texttt{ZZ}$. Changing the base ring doesn't change the solvability tho (also not with $\texttt{QQbar}$)</p>
<p>3.) I know there are 4 one-parameter solutions for $\texttt{a1,a2,b1,b2}$. Is it possible to get sage to find an expression for them? ($\texttt{solve}$ finds them, but this is just a small example of much larger systems I want to solve)</p>
https://ask.sagemath.org/question/38637/solving-equations-in-polynomial-ring-if-ideal-is-positive-dimensional/?comment=38664#post-id-38664Thank you, but unfortunately for the larger cases (the next system consists of 24 very long equations in 10 variables) this is not so easily done.
However, the last part in your second reply gave me an idea! Namely: Just don't solve for all variables, only for some and treat the rest as parameters.
I think I might be able to work with that, and from then on kind of 'see' solutions (I'm not necessarily interested in all solutions). Might work :)Sat, 26 Aug 2017 11:13:06 +0200https://ask.sagemath.org/question/38637/solving-equations-in-polynomial-ring-if-ideal-is-positive-dimensional/?comment=38664#post-id-38664Comment by dan_fulea for <p>I will be outlining the situation, and at the bottom I will describe my actual `problems'.</p>
<p>I'm coming from <a href="https://ask.sagemath.org/question/38519/sage-wrongly-suggests-there-are-only-trivial-solutions-why/">this question</a>, nbruin suggested I use polynomial rings. I'm afraid I'm missing something here. What I did was the following.</p>
<pre><code>P.<a1,a2,b1,b2,q> = QQ[]
def eq(a,b,c,d):
return q*(a**2 + b**2) + 2*(a*c + b*d)
I = ideal( eq(a1,a2,b1,b2), eq(b1,b2,a1,a2) )
B = I.groebner_basis()
</code></pre>
<p>Note that my equations are in fact only quadratic. </p>
<p>As I understand from <a href="https://en.wikipedia.org/wiki/System_of_polynomial_equations#What_is_solving.3F">the wiki page on systems of polynomial equations</a>, we can already tell - by looking at the reduced Gröbner basis - whether solutions exist at all.</p>
<p>Sage computes the reduced Gröbner basis, so here is $B$:</p>
<pre><code>a1^3*b1 + a1*a2^2*b1 - a1*b1^3 + a1^2*a2*b2 + a2^3*b2 - a2*b1^2*b2 - a1*b1*b2^2 - a2*b2^3,
a1^2*q + a2^2*q + 2*a1*b1 + 2*a2*b2,
b1^2*q + b2^2*q + 2*a1*b1 + 2*a2*b2
</code></pre>
<p>So our system is not inconsistent, but unfortunately it is also not zero dimensional, which is why $\texttt{I.variety()}$ does not work.</p>
<hr>
<p>My problems:</p>
<p>1.) $q$ is actually just a parameter in the underlying field, or rather in $\mathbb{R}$, that is: for given equations it is constant. But how do I use variables/constants in polynomial rings? I didn't find anything.</p>
<p>2.) In reality, I want to work over $\mathbb{R}$, but I read somewhere it is preferred to use $\texttt{QQ}$ or $\texttt{ZZ}$. Changing the base ring doesn't change the solvability tho (also not with $\texttt{QQbar}$)</p>
<p>3.) I know there are 4 one-parameter solutions for $\texttt{a1,a2,b1,b2}$. Is it possible to get sage to find an expression for them? ($\texttt{solve}$ finds them, but this is just a small example of much larger systems I want to solve)</p>
https://ask.sagemath.org/question/38637/solving-equations-in-polynomial-ring-if-ideal-is-positive-dimensional/?comment=38662#post-id-38662Even with the best wiill, i could not find an algebraic scheme that delivers the answer. Maybe it is best to work on the mathematical side, sage and math go hand in hand. The system of 2 eq's from the link may be written as:
$$ d^2|a|^2 + d(\bar ab+a\bar b) + |b|^2 = |b|^2$$
$$ d^2|b|^2 + d(\bar ab+a\bar b) + |a|^2 = |a|^2$$
$a,b\in \mathbb C^*$, $d>0$.
Take $z=a/b$. Rewrite as $|da+b|^2=|b^2|$ + symmetrically, so
$$ 1=|1+dz|=|1+d/z|\ . $$
Now argue geometrically. First: $1=|dz+1|\ge |dz|-|1|$. So both $|dz|$ and $|d/z|$ are $\le 2$, so the product is $\le 4$ giving $|d|\le 2$.
Assuming it, $\sqrt{4-d^4}$ makes sense & the 2 equations from the ideal in the post, solved for some choices... E.g.
var('a1,a2,a3,a4,q' )
solve( [eq(a1,a2,b1,b2), eq(b1,b2,a1,a2)], [a1,a2] )Sat, 26 Aug 2017 05:07:35 +0200https://ask.sagemath.org/question/38637/solving-equations-in-polynomial-ring-if-ideal-is-positive-dimensional/?comment=38662#post-id-38662