Continued fraction expansion of quadratic irrationals
Let me emphasize that I am very new to sage and to computing in general, but I did research as much as I could before asking this question.
It is well know that that quadratic irrationals has eventuallyperiodic continued fraction expansion. I really tried to find a function that gives me the period of a given quadratic irrational. The best I could find was in this forum: http://www.mail-archive.com/sage-supp...
It explains that you can get using GAP the PrePeriod+Period. It has two disadvantages: the first, you can't get the pure period, i.e., without the preperiod, and the second is that it is the input is not the number itself but the polynomial it solve. If this polynomial has many positive roots it is a problem...
I tried to look also in PARI and didn't find anything. I did see that it is written that sage itself does not have this function.
Let me also remark that such algorithm exist. My question: Is there a way (via packages that are contained in sage) to find the period of a given quadratic irrational?
Thanks a lot! Menny
It seems that you are correct that this is not the case - yet. In fact, see http://groups.google.com/group/sage-support/tree/browse_frm/month/2008-05?_done=%2Fgroup%2Fsage-support%2Fbrowse_frm%2Fmonth%2F2008-05%3F& for something related. Can you point us to some of the algorithms? Also, the current expansion is in pure Python, so rather slow.
I didn't find the algorithm yet, but you can see that it is implemented in maple: http://www.maplesoft.com/support/help/Maple/view.aspx?path=numtheory/cfrac I'll go hunting for the algorithms.
It's also implemented (for some quadratic irrationals) in Mathematica / Wolfram|Alpha. See: http://www.wolframalpha.com/input/?i=continued+fraction+sqrt%2817%29%2F12 (period is 6) and http://www.wolframalpha.com/input/?i=continued+fraction+sqrt%28100027%29%2F12 (period is large, you'd have to count it yourself I guess after clicking "more terms" a bunch of times).
I think what @Menny wanted was something that gives the period without having to count and click more terms :)
I mainly want to be able to work with it through sage and manipulate the results I'm getting. I can seems to find the algorithms.... I looked in Cohen books, and asked for the help of google and didn't find anything yet. Is there a generic references of Number theory algorithms?