Graphing Continued Fractions of Quadratic Irrationals

Let , . The continued fraction of is either finite (when is a perfect square so that is rational) or eventually periodic (when is not a perfect square so that is irrational).
If is rational, the elements of its continued fraction are plotted.
If is irrational, let its continued faction be , where the repeating part under the bar starts as soon as possible. In that case, the plot is of the repeating part , with the initial elements ignored.
Sometimes is a palindrome; that is, is the same read from right to left as from left to right, , and its graph is symmetric. Often is the concatenation of two palindromes, like . If is rational and not a perfect square, then ; that is, is a palindrome concatenated with twice the integer part of , which is a trivial palindrome. Finally, there are cases where is not a palindrome. Colors distinguish the various cases.
The continued fraction is shown under the plot in the Mathematica notation .


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


[1] E. R. Burger, "A Tail of Two Palindromes," The American Mathematical Monthly, 112, 2005 pp. 311–321.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.