sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.2k stars 413 forks source link

solve of ideal over QQ[x,y] does not give solution anymore (since 6.3) #16848

Open dkrenn opened 9 years ago

dkrenn commented 9 years ago

In Sage 6.3 we have

sage: R.<x,y> = QQ[]
sage: I = R.ideal(y^2 - 2*y + 1, x + 1/4*y - 5/4)
sage: solve(I.gens(), [SR(x) for x in R.gens()], solution_dict=true)
[]

But in 6.1.1 we got

sage: solve(I.gens(), [SR(x) for x in R.gens()], solution_dict=true)
[{x: 1, y: 1}]

which was the correct solution.

Component: algebra

Issue created by migration from https://trac.sagemath.org/ticket/16848

dkrenn commented 9 years ago
comment:1

I've narrowed the search: It works in 6.3.beta5, but not anymore in 6.3.beta6.

videlec commented 9 years ago
comment:2

Hi,

I would not say this is a bug. If you want to use the function solve, you need to feed it with symbolic polynomials

sage: R.<x,y> = QQ[]
sage: Sx, Sy = var('x,y')
sage: I = R.ideal(y^2 - 2*y + 1, x + 1/4*y - 5/4)
sage: f0,f1 = I.gens()
sage: f0 = f0.subs(x=Sx, y=Sy); f1 = f1.subs(x=Sx, y=Sy)
sage: solve([f0,f1], [Sx,Sy], solution_dict=true)
[{x: 1, y: 1}]

The "bug" comes from solve which does not type check the input as it should. Note that when the input is one polynomial the check is done

sage: f0,f1 = I.gens()
sage: solve(f0, [Sx,Sy])
Traceback (most recent call last): 
...
TypeError: The first argument must be a symbolic expression or a list of symbolic expressions.

Vincent

lftabera commented 9 years ago
comment:3

See also #13360 automatically coercing from polynomials to symbolics can cause unexpected problems. So, while I acknowledge that this ugly and unconvenient I am more inclined to get used to write

sage: R.<x,y> = QQ[]
sage: I = R.ideal(y^2 - 2*y + 1, x + 1/4*y - 5/4)
sage: solve(map(SR,I.gens()), map(SR,R.gens()), solution_dict=true)
[{y: 1, x: 1}]
dkrenn commented 9 years ago
comment:4

Replying to @lftabera:

See also #13360 automatically coercing from polynomials to symbolics can cause unexpected problems. So, while I acknowledge that this ugly and unconvenient I am more inclined to get used to write

sage: R.<x,y> = QQ[]
sage: I = R.ideal(y^2 - 2*y + 1, x + 1/4*y - 5/4)
sage: solve(map(SR,I.gens()), map(SR,R.gens()), solution_dict=true)
[{y: 1, x: 1}]

Ok, this is definitly a workaround and maybe should be mentioned somewhere. Anyhow, I do not like that solve as in the original problem accepts polynomials but then does not give a solution (while it did some versions ago)