On Mar 19, 2009, at 1:17 AM, Chris Godsil wrote: > I want to compute determinants of matrix polynomials, for matrices up > to 20 x 20, say. > The attached transcript seems to indicate 9 or 10 might be my limit. > (Or it's late and I am being stupd?)
It depends on what ring you're over. sage: M = random_matrix(ZZ, 100); M 100 x 100 dense matrix over Integer Ring sage: time M.det() CPU times: user 0.06 s, sys: 0.00 s, total: 0.07 s Wall time: 0.07 s 227532739129946890993919801650069690831259013161380617147968485792614242 900489259103289021402067670696965272359625204046028722848602428730109991 83429371192981564969154912060350722012918063477112770597042 There isn't optimized code for doing it over QQ[t], so that's why it's really slow. It looks like what you really want is the characteristic polynomial, which on matrices of this size should be virtually instantaneous. sage: P = graphs.PetersenGraph() sage: P.delete_edge([0,1]) sage: A = P.am() sage: A.charpoly() x^10 - 14*x^8 + 65*x^6 - 16*x^5 - 128*x^4 + 72*x^3 + 84*x^2 - 80*x + 16 > ---------------------------------------------------------------------- > | Sage Version 3.4, Release Date: > 2009-03-11 | > | Type notebook() for the GUI, and license() for information. | > ---------------------------------------------------------------------- > # intel mac pro, binary distribution > > sage: P = graphs.PetersenGraph() > sage: P.delete_edge([0,1]) > sage: P.degree() > [2, 2, 3, 3, 3, 3, 3, 3, 3, 3] > sage: P > Petersen graph: Graph on 10 vertices ## but P is not the Petersen > graph now > sage: A = P.am() > sage: Id = identity_matrix(10) > sage: R.<t> = QQ[] > sage: (t+1)^5 > t^5 + 5*t^4 + 10*t^3 + 10*t^2 + 5*t + 1 > sage: M = t*Id - A; M > > [ t 0 0 0 -1 -1 0 0 0 0] > [ 0 t -1 0 0 0 -1 0 0 0] > [ 0 -1 t -1 0 0 0 -1 0 0] > [ 0 0 -1 t -1 0 0 0 -1 0] > [-1 0 0 -1 t 0 0 0 0 -1] > [-1 0 0 0 0 t 0 -1 -1 0] > [ 0 -1 0 0 0 0 t 0 -1 -1] > [ 0 0 -1 0 0 -1 0 t 0 -1] > [ 0 0 0 -1 0 -1 -1 0 t 0] > [ 0 0 0 0 -1 0 -1 -1 0 t] > sage: M.det() ## and sage hangs > > ## but the following worked > sage: K =graphs.CompleteGraph(3) > sage: B =K.am() > sage: Id = identity_matrix(3) > sage: (t*Id-B).det() > t^3 - 3*t - 2 > > sage: C = graphs.CubeGraph(3) > sage: C > 3-Cube: Graph on 8 vertices > sage: Id = identity_matrix(8) > sage: (t*Id-C.am()).det() > t^8 - 12*t^6 + 30*t^4 - 28*t^2 + 9 > > # and the cycle on 9 vertices hangs > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---