Hi Erik [sorry, the first mail was sent to you directly]
On 17.09.2014 19:21, Erik Massop wrote: > On Wed, 17 Sep 2014 17:59:49 +0200 >> It doesn't (also note that the polynomials here have deg=4 < 8). > > "the polynomials"? > > sage: el2 = (791264*AA(2*cos(pi/8))^2 - 463492).sqrt() > sage: el2._exact_value() > [ something horrible involving a polynomial of degree 16 ] Right. > This is pretty fast though: > sage: x = var('x') > sage: el1 = AA((x^4 - 2238072*x^2 + 44133904).roots()[1][0]) > sage: el3 = (791264*AA(2*cos(pi/8))^2 - 463492) > sage: el1 > 0 > True > sage: el3 > 0 > True > sage: el1^2 == el3 > True > Perhaps there is a way around the sqrt in your algorithm? Note really but see below + my other mail. > Actually this is interesting: > sage: el3 = (791264*AA(2*cos(pi/8))^2 - 463492) > sage: el2 = el3.sqrt() > sage: el2._descr > Root 1496.012125692029503? of x^2 - 2.238052280217585?e6 > sage: el2.exactify() > sage: el2._descr > [ that horrible thing ] > So in this case the old description would give a much more efficient > comparison. Unfortunately, it's discarded... The description looks nice but internally the exact field beeing used is still the one with the polynomial of degree 16. The problem occurs during the binary operation (sub). Sage tries to find a common parent for that operation which calls union for the exact_fields, which in turn calls pari_field() which for el2 takes forever and produces a horrible^2 (actually worse than ^2) result. If el2 is simplified first all (performance) issues are solved: sage: el1 = AA((x^4 - 2238072*x^2 + 44133904).roots()[1][0]) sage: el2 = (791264*AA(2*cos(pi/8))^2 - 463492).sqrt() sage: el2.simplify() sage: el1 == el2 What about simplifying elements by default or for non-trivial binary operations? It might slow down some calculations but it would probably avoid the strange "pari_field()" calculations (and speed up the calculation in this case by a huuuge factor). Also in general it would probably speed up calculations of complicated expressions in AA... Best Jonas -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.