Graphing Continued Fractions of Quadratic Irrationals

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram CDF Player or other Wolfram Language products.

Requires a Wolfram Notebook System

Edit on desktop, mobile and cloud with any Wolfram Language product.

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 .


Contributed by: George Beck (July 2012)
Open content licensed under CC BY-NC-SA




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

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.