I certainly agree that this should work. I found that if I set M=mu*E1+E3 I could compute det(M).discriminant() immediately, and similarly for 2 of the other 3. So there is something funny happening, as the basic operation of computing the discriminant of a cubic with coefficients in your 7-variable polynomial ring is ok; it's the (E3,E4) case which is hanging. When I substituted the coefficients of det(mu*E3+E4) into the generic discriminant forumla the reult was an expression 3759965 characters long. The first three are only [14360, 14360, 50720] so the last one is more complicated,
Looking at the code used, it uses the resultant formula which in turn evaluates a determinant. I agree with you that for small degrees it would be better (almost certainly in a lot of cases) be better to substitute into the generic formula. John Cremona On 26 March 2014 08:48, <[email protected]> wrote: > The following sage code dies on me, after computing for quite some time: > > ┌────────────────────────────────────────────────────────────────────┐ > │ Sage Version 6.1.1, Release Date: 2014-02-04 │ > │ Type "notebook()" for the browser-based notebook interface. │ > │ Type "help()" for help. │ > └────────────────────────────────────────────────────────────────────┘ > sage: PR.<b,t1,t2,x1,y1,x2,y2> = QQ[] > sage: PR2.<mu> = PR[] > sage: E1 = diagonal_matrix(PR, [1, b^2, -b^2]) > sage: RotScale = matrix(PR, [[1, -t1, 0], [t1, 1, 0], [0, 0, 1]]) > sage: E2 = diagonal_matrix(PR, [1, 1, > 1+t1^2])*RotScale.transpose()*E1*RotScale > sage: Transl = matrix(PR, [[1, 0, -x1], [0, 1, -y1], [0, 0, 1]]) > sage: E3 = Transl.transpose()*E2*Transl > sage: E4 = E3.subs(t1=t2, x1=x2, y1=y2) > sage: Transl = matrix(PR, [[1, 0, 0], [0, 1, 1+b], [0, 0, 1]]) > sage: E2 = Transl.transpose()*diagonal_matrix(PR, [b^2, 1, -b^2])*Transl > sage: eqs = [det(mu*Ei + Ej).discriminant() for Ei, Ej in > ....: [(E1, E3), (E1, E4), (E2, E3), (E3, E4)]] > Segmentation fault > > Attaching a debugger, I got thousands of stack frames from within the python > interpreter: > symtable_visit_expr from Python-2.7.6/Python/symtable.c:1191 seems to be > calling itself till the call stack overflows. > > The above is from Sage on Gentoo, but the Sage 6.1.1 official release for > Mac segfaults as well. > > I'm a bit surprised both at the segfault and at the fact that this takes so > long. After all, I'm just computing the discriminant of a bunch of cubic > polynomials. Wikipedia has a formula for this, and using that formula, > things complete in no time at all. Should discriminants for polynomials of > small degree be special-cased to avoid such issues? Or perhaps the > discriminant should be computed first for a generic polynomial (i.e. one > variable for every non-zero coefficient of the input), and the actual > coefficients of the input substituted into that in a second step. > > I guess I'll be using that hardcoded formula for cubic discriminants for > now, but it would be nice if such things could work out of the box. > > -- > 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. -- 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.
