Bug in Polyhedron from equations in number field

40 views
Skip to first unread message

Mark Bell

unread,
Oct 18, 2014, 3:37:41 PM10/18/14
to sage-s...@googlegroups.com
Hi,

I was trying to create a function which constructed the "largest" eigenspace of a matrix as a Polygon. I created the following function:

def f(matrix):
    m = max(matrix.eigenvalues(), key=lambda x: x.real())  # Get the eigenvalue with largest real part
    eqns = [[0] + list(row) for row in (matrix - m)]  # Construct the system of equations representing (matrix - m) * x == 0. 
    return Polyhedron(eqns=eqns)

I tried this with the following example:
M = Matrix([
    [-2, -8,  2],
    [-2,  6,  9],
    [-9,  5, -7]])
f(M)
And this gives the expected:
  "A 1-dimensional polyhedron in (Algebraic Field)^3 defined as the convex hull of 1 vertex and 1 line"

However, to make this faster (for larger matrices it is very slow) I followed the advice here (http://www.sagemath.org/doc/reference/geometry/sage/geometry/polyhedron/constructor.html#base-rings) and created a new function which works over the correct number field:

def g(matrix):
    m = max(matrix.eigenvalues(), key=lambda x: x.real())  # Get the eigenvalue with largest real part
    N.<L> = NumberField(m.minpoly(), 'L', embedding=m.n())  # Use the number field that m lies in.
    eqns = [[0] + list(row) for row in (matrix - L)]
    return Polyhedron(eqns=eqns)

However now g(M) returns:
  "A 3-dimensional polyhedron in (Number Field in L with defining polynomial x^3 + 3*x^2 - 83*x - 1022)^3 defined as the convex hull of 1 vertex, 2 rays, 1 line"

The one line appears to correspond to the line in the Polyhedron returned by f(M), but why are there 2 additional rays? Is there something wrong with the second function? Why does the polyhedron returned by g(M) not even correspond to a subspace of RR^3?

A copy of this is included in the attached file. 

I am working in Sage 6.3 on Ubuntu 14.04.

Thanks,
Mark Bell
polyhedron.sage

Mark Bell

unread,
Oct 22, 2014, 10:10:08 AM10/22/14
to sage-s...@googlegroups.com
I've moved this to trac. See: http://trac.sagemath.org/ticket/17197#ticket
Reply all
Reply to author
Forward
0 new messages