How to detect when continued fractions period terminates I'm doing continued fractions arithmetic. Is there a method to detect when a continued fractions period terminates?
Let me give you an example:
$\sqrt{2} = [1; \overline{2}]$, $\sqrt{7} = [2; \overline{1, 1, 1, 4}]$ and $\sqrt{14} = [3; \overline{1, 2, 1, 6}]$.
Now clearly $\sqrt{2} \times \sqrt{7} = \sqrt{14}$, but if we do continued fractions arithmetic we get: $[1; \overline{2}] \times [2; \overline{1, 1, 1, 4}] = 3, 1, 2, 1, 6, 1, 2, 1, 6, 1, 2, 1, 6, \dots$. Obviously this sequence never ends, since the continued fraction can always input a term from either $\sqrt{2}$ or $\sqrt{7}$ (as they are infinite).  
So my question is: is there a mathematical method to detect when the period ends (during addition, subtraction, multiplication and division), rather than guessing and checking?
Maybe using the $z$ object (this "thing")? For example, after it emits the first $1$ it is:
$\left \langle \begin{matrix}13 & 31 & 28 & 67\\ 
 11 & 27 2& 8 & 20
\end{matrix}\right \rangle$
and when the period starts again:
$\left \langle \begin{matrix} 549 & 1317 & 2226 & 5335\\ 95 & 239 & 814 & 2010 \end{matrix} \right \rangle$
and again: $\left \langle \begin{matrix} 92029 & 222405 & 122610 &  296283\\ 41317 & 99487 & 37841 & 91039 \end{matrix} \right \rangle$.  
Is there some kind of a pattern? I've noted none.  
Thank you,
rubik
 A: In the case of $\sqrt n$, it is extremely easy to tell when you've reached the end of the period; it's when you get a partial quotient twice the integer part. Look at your examples for $n=2,7,14$; the integer parts are $1,2,3$, respectively, and the periods end with $2,4,6$, respectively. 
But if you don't know you're working with $\sqrt n$; if, say, you have the continued fractions for $\sqrt2/\pi$ and $\pi$, but you don't know it, I don't see how you'll ever know for sure that the product is periodic. But surely the same question arises if you have the decimal expansions of $\pi$ and $1/\pi$ and you don't know it; how can you ever know for sure that the product is $1$?
A: A continuous fraction ends its period when $a_i = 2 * a_0$
example : $\sqrt{23} = [4;1,3,1,8]$ => $8 = 2* 4$
Or am I misunderstanding the question ?
A: It may sound a bit trivial, but actually, the important qustion would be: When has a fraction a period, i.e., when is there repetitive bahvior in the digits. It is known that irrational numbers are non-terminating, non-periodic decimal fractions. Using simple set-theory, i.e., taking the complement of the set of irrational numbers in the set of real numbers, we find, that either the rational numbers are terminating decimal fractions or periodic fractions. In either case, by the construction of the rational numbers, it is possible to find an expression like this: $q=\dfrac{n}{m}, n\in\mathbb{Z}, m\in\mathbb{N}$. Note that this expression needn't be unique!. Hence, after having added $m$ times the number $q$ we're done. So far about the theory.
My experience has told me that these questions are the practical ones, i.e., those of little mathematical interest (b.t.w.: I am a pure mathematician working in global analysis, differntial topology and differential geometry <---- Purest mathematics apart from logic). I think that numerically one could find the answer to your problem, but in general, you will have to stick to guessing and checking. But perhaps when you learn abstract algebra and number theory combined with logic, you come across some solution (I have heard abstract algebra in the shortened version for geometers :D)
