# Solving system of polynomial equations over rationals

I want to solve a system of polynomial equations but I need only rational solutions. What is the best method to do it in Sage?

For example:

Input:

```
R.<a1,b1,b2,c1,c2> = QQ[]
J = R.ideal(5*(9 + 2*a1^2 - b2), 5*(-324 + 4*a1*b1 + b2^2 - c2), 10*(729 + 2*a1 + b1^2 + 243*b2 - 9*b2^2 + 2*a1*c1 + b2*c2), 5*(6561 + 4*b1 - 2916*b2 + 4*b1*c1 + 486*c2 - 36*b2*c2 + c2^2), 2*(-59048 + 10*c1 + 5*c1^2 - 7290*c2 - 45*c2^2))
J.variety()
```

Output:

```
[]
```

Or example with some solutions (same as above but added constant 1889566 to last equation):

Input:

```
R.<a1,b1,b2,c1,c2> = QQ[]
J = R.ideal(5*(9 + 2*a1^2 - b2), 5*(-324 + 4*a1*b1 + b2^2 - c2),
10*(729 + 2*a1 + b1^2 + 243*b2 - 9*b2^2 + 2*a1*c1 + b2*c2),
5*(6561 + 4*b1 - 2916*b2 + 4*b1*c1 + 486*c2 - 36*b2*c2 + c2^2),
2*(-59048 + 10*c1 + 5*c1^2 - 7290*c2 - 45*c2^2)+1889566)
J.variety()
```

Output:

```
[{a1: 0, c1: 0, b1: 0, b2: 9, c2: -243},
{a1: 0, c1: -2, b1: 0, b2: 9, c2: -243}]
```

It takes quite a lot of time for the output to appear, while in Mathematica it takes a second. So is there a better method in Sage than the one I used?

Please add the system. Otherwise we have to make guesses and assumptions which may not apply to your case.

@rburing: I added an example of the system.

Howdo you "solve" this with Mathematica ?@Emmanuel Charpentier: Reduce[

the system,Rationals]