2016-11-06 08:58:08 -0600 | received badge | ● Famous Question (source) |

2015-11-02 09:26:36 -0600 | received badge | ● Famous Question (source) |

2014-06-28 20:14:52 -0600 | marked best answer | Continued fraction expansion of quadratic irrationals Let me emphasize that It is well know that that quadratic irrationals has 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 |

2014-05-06 17:15:49 -0600 | received badge | ● Notable Question (source) |

2013-12-21 05:49:57 -0600 | received badge | ● Popular Question (source) |

2013-09-17 14:46:00 -0600 | received badge | ● Notable Question (source) |

2013-09-14 23:07:31 -0600 | received badge | ● Famous Question (source) |

2012-12-25 08:14:36 -0600 | received badge | ● Taxonomist |

2012-11-06 01:06:29 -0600 | received badge | ● Popular Question (source) |

2012-03-19 02:37:46 -0600 | received badge | ● Notable Question (source) |

2011-12-21 16:42:43 -0600 | marked best answer | sqaure root type In general if Note also that %1 and .frac() are different: I guess you want the latter. Actually %1 is a bit weird: |

2011-12-21 01:13:06 -0600 | commented answer | sqaure root type It works. But I'm having similar problems when I, for example, take x to be some complex number, and y=x.real_part. Then, y%1 return a type error... where do I found how to deal with these errors? |

2011-12-21 01:07:05 -0600 | commented question | sqaure root type Yes. when you write the code above you get an error regarding the type of the objects. |

2011-12-20 09:04:47 -0600 | asked a question | sqaure root type I guess this is a very simple question: What changes do I need to make in order to make work? Also, what chapter in the manual I need to read in order not to ask such basic questions again?? Thanks a lot, Menny |

2011-11-12 02:42:42 -0600 | received badge | ● Popular Question (source) |

2011-10-11 00:14:05 -0600 | commented answer | Number Fields and the Norm This method also gives the trace :) |

2011-10-02 01:14:15 -0600 | commented answer | splitting of primes @parzan - you're the man! |

2011-10-02 01:12:53 -0600 | marked best answer | splitting of primes Are the ramified primes the ones which divide the field discriminant? If this is so you can get them by If splitting means that the prime factors then you can check this like this: for example: |

2011-09-27 09:17:08 -0600 | asked a question | splitting of primes Given a quadratic field, say, Is there a method to know if a given prime splits/ stay inert/ ramify in K? (For number-theoretic background: http://en.wikipedia.org/wiki/Splittin... ) I tried to look it up but didn't find anything. Thanks a lot!!! Menny |

2011-08-31 04:24:49 -0600 | commented answer | extracting the coefficients of a linear combination thanks a lot! this is an act of pure giving... Menny |

2011-08-31 04:23:28 -0600 | marked best answer | extracting the coefficients of a linear combination I take it you understand how to get the coefficients in the standard basis, e.g.: Then going to your preferred basis is just a linear algebra problem. For example, if your preferred QQ-basis is (1,1) and (2,0) then you could do: Check that this is correct: |

2011-08-28 03:23:10 -0600 | asked a question | extracting the coefficients of a linear combination Let me just say that I'm quite new to sage (although I'm making a progress!) I wish to input a number field (in my case real quadratic field), a basis $w_1,w_2$ over $ \mathbb Q$ and an element $v$ of this number field and get the coefficient of $v$ as a linear combination of $w_1$ and $w_2$. I.e., if $v=aw_1+bw_2$ I wish to get (a,b). I tried doing this with just solving equations in matrices but I didn't find a way to make it solve the equations over the base field $ \mathbb Q$. Thanks a lot for helping! Menny |

2011-07-12 17:05:38 -0600 | answered a question | Continued fraction expansion of quadratic irrationals Via the reference within this page: http://www.numbertheory.org/php/surd.... I found a more elegant algorithm than the one sketched above:
Input: $(a,b,c)\in Z \times N\times Z$ and $b$ not a perfect square. This triple represents $\frac{a+\sqrt{b}}{c}$. If $c$ does not divide $b-a^{2}$ then multiply everything by $\frac{|c|}{|c|}$ , and get new triple that we call $(a',b',c')$ Set $P_{0}=a'$ , $Q_{0}= c'$, $d=c'$. For $k\geq0$ set
(a) $\alpha_{k}=\frac{P_{k}+\sqrt{d}}{Q_{k}}$ (b) $a_{k}=\lfloor\alpha_{k}\rfloor$ (c) $P_{k+1}=a_{k}Q_{k}-P_{k}$ (d) $Q_{k+1}=\frac{d-P_{k+1}^{2}}{Q_{k}}$ Then $\alpha_{0}=\frac{a+\sqrt{b}}{c}=[a_{0},a_{1},a_{2},...]$ Let $k< l$ be the first pair of integers which satisfy that $$(P_{k},Q_{k})=(P_{l},Q_{l})$$ then the period of $\alpha_{0}$ is $(a_{k},\dots,a_{l-1})$ .
Hopefully this will help implementing it... |

2011-05-17 13:27:31 -0600 | received badge | ● Good Question (source) |

2011-05-17 11:32:22 -0600 | received badge | ● Scholar (source) |

2011-05-17 11:32:22 -0600 | marked best answer | Continued fraction expansion of quadratic irrationals As far as I can tell, there aren't any packages available in Sage beyond the GAP package you mention above. There is a relatively simple algorithm for finding the period and I think it would be worth implementing this in the continued fractions module in Sage. I created a trac ticket for this enhancement: Trac #11345 A colleague of mine who works on diophantine approximation communicated an algorithm to me which I'll paraphrase below. The algorithm takes a specific quadratic irrational and would determine the pre-period (if desired), the periodic sequence, and the length of the period. The algorithm makes use of the following classical results (which I don't have specific references for yet).
INPUT: $\zeta$, a positive quadratic irrational in the form $\zeta = q + r\sqrt{D}$ for rational numbers $q, r$. - Check if $\zeta$ is purely periodic (using the theorem above).
- If so, we know that the period has length at most $2D$. We then determine the period by listing enough terms in the continued fraction approximation.
- If $\zeta$ isnt purely periodic, replace $\zeta$ with $\frac{1}{\zeta}-\text{floor}(\frac{1}{\zeta})$ and go to step 1.
We get the length of the pre-period by counting the number of iterations above and we have an immediate upper bound on how much farther we have to search for the length of the period $2D$. |

2011-05-17 11:28:34 -0600 | answered a question | Continued fraction expansion of quadratic irrationals As a continuation of the reply by Benjamin, Let me give some references and give more information. Both Theorems appear in the book "Continued Fractions" By Andrew Mansfield Rockett and Peter Szüsz. The first is Theorem 3 on page 45, and the second is a remark before Theorem 1 on page 50. The second is not stated correctly (there should not be any coeffiecient before the square root):
A better asymptotics is given by the following (which is Theorem 1 of page 50):
I'm not sure what the constant is (it is related to the divisor function)... I didn't read the proof yet! |

2011-05-17 10:31:29 -0600 | received badge | ● Supporter (source) |

2011-05-17 04:02:18 -0600 | commented question | Continued fraction expansion of quadratic irrationals 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? |

2011-05-16 08:48:22 -0600 | commented question | Continued fraction expansion of quadratic irrationals 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. |

2011-05-16 05:27:09 -0600 | received badge | ● Nice Question (source) |

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.