Yes, that is where it should go. I don't think it will be that hard to combine. There is a Java code <http://www.alpertron.com.ar/CONTFRAC.HTM> that is used in Dario Alpern's website.
I need the continued_fraction representation of quadratic irrational numbers in the Diophantine equation module. I can implement it in diophantine module but I think that does not belong there. We should implement it in ntheory and then use it in Diophantine module. Shall I start on this? On Fri, Jun 28, 2013 at 8:49 AM, Stephen Loo <[email protected]> wrote: > 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]> 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/**modu**les/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 sympy+un...@**googlegroups.com. >>> To post to this group, send email to [email protected]. >>> >>> Visit this group at >>> http://groups.google.com/**group/sympy<http://groups.google.com/group/sympy> >>> . >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<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. > > > -- 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.
