I have considered this, in quantum module, the continued_fraction function 
is only work for rational number a/b = continued_fraction(a, b), but my 
function above is work for float and depending on the precision. I don't 
know how to combine into single function, and it is not suggested to place 
in quantum module, it should be in ntheory.

Stephen

Thilina Rathnayake於 2013年6月28日星期五UTC+8上午10時58分36秒寫道:
>
>
> Thanks guys for the help. Shouldn't we add this functionality to the 
> current continued_fraction or
> add a new function to SymPy so user can use it directly?
>
>
>
> On Fri, Jun 28, 2013 at 7:45 AM, Stephen Loo <[email protected]<javascript:>
> > wrote:
>
>> def continued_fraction(r):
>>     while True:
>>         i = int(r)
>>         yield i
>>         if i == r:
>>             break
>>         r = 1 / (r - i)
>>
>>
>> Thilina Rathnayake於 2013年6月28日星期五UTC+8上午4時16分34秒寫道:
>>
>>> Hi all,
>>>
>>> Is there a function in sympy which gives the continued fraction 
>>> representation
>>> of quadratic irrationalities like, (sqrt(17) + 5 ) / 4?
>>>
>>> I found an implementation of a continued fraction function in  Shor's 
>>> algorithm: 
>>> http://docs.sympy.org/dev/**modules/physics/quantum/shor.**html<http://docs.sympy.org/dev/modules/physics/quantum/shor.html>
>>>
>>> But it doesn't seem to give correct results when irrationalities are 
>>> involved.
>>>
>>> >>> from sympy.physics.quantum.shor import continued_fraction
>>>> >>> continued_fraction(sqrt(17)+5, 4)
>>>> [2, 4]
>>>>
>>>
>>> Actual answer should be 2, [3, 1, 1] with the numbers inside [] 
>>> repeating forever.
>>> Any help would be appreciated.
>>>
>>> Regards,
>>> Thilina.
>>> .
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] <javascript:>
>> .
>> Visit this group at http://groups.google.com/group/sympy.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" 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/sympy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to