#5107: incorrect trailing digits for continued fraction
------------------------------+---------------------------------------------
 Reporter:  robertwb          |       Owner:  somebody  
     Type:  defect            |      Status:  new       
 Priority:  critical          |   Milestone:  sage-4.1.2
Component:  basic arithmetic  |    Keywords:            
 Reviewer:                    |      Author:            
   Merged:                    |  
------------------------------+---------------------------------------------

Comment(by AlexGhitza):

 The computation is done in the function {{{continued_fraction_list()}}} of
 {{{rings/arith.py}}}, where it says "This may be slow for real number
 input, since it's implemented in pure Python. For rational number input
 the PARI C library is used."

 I wonder why we're not using PARI also when the input is a real number.
 It's fast, and it looks right:

 {{{
 sage: x = sqrt(2)
 sage: CFF = ContinuedFractionField()
 sage: CFF(pari(x).contfrac().python())
 [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
 sage: timeit("CFF(pari(x).contfrac().python())
 625 loops, best of 3: 258 µs per loop
 sage: timeit("CFF(continued_fraction_list(x))")
 625 loops, best of 3: 1.17 ms per loop
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5107#comment:2>
Sage <http://sagemath.org/>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to