bug with variety(): order of the variables seem to matter!

33 views
Skip to first unread message

Pierre

unread,
May 2, 2013, 9:44:12 AM5/2/13
to sage-s...@googlegroups.com
hi all,

the following happens with both sage 5.5 and sage 5.8 on a macbook, osx 10.7.

Consider first these computations, which work fine:

B= PolynomialRing(QQ, ["c", "b1", "b2", "v1", "v2", "v3", "v4", "b0"], order= "lex") 
#making sure we use "lex", so not using B.<c, ...>= QQ[]
c, b1, b2, v1, v2, v3, v4, b0= B.gens()
A.<z>= B[]

FF= c*(z-b0)^4*(z-b1)*(z-b2)^2
FFto= c*(z-1)^2*(z-v1)^2*(z^3 + v2*z^2 + v3*z + v4)

rel= FFto - (FF-1)

J= ( [b0]+rel.coefficients() ) * B

if J.dimension() == 0:
    V= J.variety(ring= QQbar)
else:
    print "not even of dimension 0!"

This produces 8 points on the variety, great. Now if I only change the order in which I put the variables in the polynomial ring, as follows:

B= PolynomialRing(QQ, ["c", "b0", "b1", "b2", "v1", "v2", "v3", "v4"], order= "lex")
c, b0, b1, b2, v1, v2, v3, v4= B.gens()
A.<z>= B[]

FF= c*(z-b0)^4*(z-b1)*(z-b2)^2
FFto= c*(z-1)^2*(z-v1)^2*(z^3 + v2*z^2 + v3*z + v4)

rel= FFto - (FF-1)

J= ( [b0]+rel.coefficients() ) * B

if J.dimension() == 0:
    V= J.variety(ring= QQbar)
else:
    print "not even of dimension 0!"

...the whole thing now fails with

TypeError: keys do not match self's parent

Of course this is a "minimal" example, and in practice I just cannot try to reorder the variables until things work!!...

any idea, anyone?

thanks!
Pierre

Volker Braun

unread,
May 2, 2013, 9:50:51 AM5/2/13
to sage-s...@googlegroups.com
Both produce the same output (J.vector_space_dimension() == 8) in Sage-5.10.beta1.


Justin C. Walker

unread,
May 3, 2013, 1:03:31 AM5/3/13
to sage-s...@googlegroups.com

On May 2, 2013, at 06:50 , Volker Braun wrote:

> Both produce the same output (J.vector_space_dimension() == 8) in
> Sage-5.10.beta1.

Odd. I get the same result as the OP with both 5.10-b0 and -b1. This is on Mac OS X, 10.6.8.

Justin

--
Justin C. Walker, Curmudgeon-At-Large, Director
Institute for the Enhancement of the Director's Income
--------
The path of least resistance:
it's not just for electricity any more.
--------



Dominique Unruh

unread,
Feb 16, 2014, 9:03:03 AM2/16/14
to sage-s...@googlegroups.com
Hi,

I can reproduce the OP's problem on
Sage Version 6.0, Release Date: 2013-12-17
on Ubuntu 13.10, 3.8.0-35-generic.

In fact, I ran into the same problem.

The reason seems to be that the polynomial ring is over QQ, while the the root-extraction in the variety(ring=QQbar) command is over QQbar. During the computation of the variety, polynomials over both rings occur, and mixing them leads to the error.

A fix is to convert all polynomials to QQbar before attempting the extraction. On my system, the following change works:

        for t in T:
+            t = [P(p) for p in t]
            Vbar = _variety(list(t),[])
            #Vbar = _variety(list(t.gens()),[])

            for v in Vbar:
                V.append(dict([(P(var),val) for var,val in v.iteritems()]))
        V.sort()

(in rings/polynomial/multi_polynomial_ideal.py, function variety).

Best wishes,
Dominique.
Reply all
Reply to author
Forward
0 new messages