# 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, 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, 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)

There 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: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.

Even 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 ...(more)

Thank 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 :)