Dear Mike, Thank you very much for your explanation and solution. The amended code now works perfectly. You made my day! Best regards, John
Mike Hansen wrote: > Hi, > > The issue is that .roots() now returns tuples with the root and its > multiplicity. You can see this if you look at v. You need to select > the 0th entry of the tuple to raise to a power. > > sage: RDF = RealDoubleField() > sage: R.<y> = PolynomialRing(RDF) > sage: # Let y be x^(1/9). > sage: f = y + RDF(2^(8/9) - 2^(1/9))*(y^9-1) - y^8 > sage: v = f.roots(); v > [(0.925874712287, 1), (1.0, 1), (1.08005973889, 1)] > sage: [a[0]^9 for a in v] > [0.5, 1.0, 2.0] > > --Mike > > > On Mon, Apr 7, 2008 at 2:06 PM, John P. Burkett <[EMAIL PROTECTED]> wrote: >> Last September I asked how to use SAGE to find the roots of >> f = x^(1/9) + (2^(8/9) - 2^(1/9))*(x - 1) - x^(8/9). >> William Stein then kindly offered the following code: >> sage: RDF = RealDoubleField() >> sage: R.<y> = PolynomialRing(RDF) >> sage: # Let y be x^(1/9). >> sage: f = y + RDF(2^(8/9) - 2^(1/9))*(y^9-1) - y^8 >> sage: v = f.roots(); v >> sage: [a^9 for a in v] >> >> This code worked well on my machines when I first tried it. However, >> today in SAGE 2.11 the same code running on the same machines produces >> the following error message: >> >> <type 'exceptions.TypeError'> Traceback (most recent call last) >> >> /home/john/<ipython console> in <module>() >> >> /home/john/integer.pyx in sage.rings.integer.Integer.__pow__() >> >> <type 'exceptions.TypeError'>: unsupported operand type(s) for ** or >> pow(): 'tuple' and 'int' >> >> I would be very grateful for ideas about what has gone wrong and how to >> fix it. >> >> Best regards, >> John >> -- >> John P. Burkett >> Department of Environmental and Natural Resource Economics >> and Department of Economics >> University of Rhode Island >> Kingston, RI 02881-0808 >> USA >> >> phone (401) 874-9195 >> >> > >> > > > > -- John P. Burkett Department of Environmental and Natural Resource Economics and Department of Economics University of Rhode Island Kingston, RI 02881-0808 USA phone (401) 874-9195 --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---