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

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Attachment: polyhedron.sage
Description: Binary data

Reply via email to