©2025 Compass Learning Technologies ← GXWeb Showcase ← GXWeb Fractured Fractions Collection → Inverted Continued Fractions
Inverted Continued Fractions
Saltire Software, home of Geometry Expressions and GXWeb
Symbolic computations on this page use Nerdamer Symbolic JavaScript to complement the in-built CAS of GXWeb
With thanks to the late Dr Keith Tognetti for pointing me in the direction of continued fractions many years ago and igniting in me a life-long passion, and to Dr Bruce Bates (both of the University of Wollongong) for revealing to us all the beautiful Stern-Brocot Continued Fraction. With colleague Dr Martin Bunder they have brought to light many wonderful and often surprising connections between binary trees and continued fractions.
Introduction to Inverted Continued Fractions
In how many different ways can you express a number like \(\frac{24}{7}\)?
As a decimal? Sure: \(3.4285714286...\)
As a mixed numeral? Perhaps... \(3 + \frac{3}{7}\)
But also as a continued fraction.
If you have not come across continued fractions in your mathematical travels, then it is high time you did!
Every real number, rational and irrational, can be represented as a continued fraction. While normal fractions can only represent rational numbers, continued fractions are different - full of surprising patterns and relationships.
Not surprisingly, rational numbers produce finite continued fractions, while irrationals become infinite continued fractions.
Unlike irrational decimals, however, even irrational continued fractions can be predictable and are an ideal way to calculate approximate values - as accurately as you like!
\[ \frac{24}{7}\]\[= 3+\frac{3}{7}\]\[= 3 + \frac{1}{\frac{7}{3}}\]\[= 3 + \cfrac{1}{2 + \cfrac{1}{3}} \]\[= 3 + \cfrac{1}{2 + \cfrac{1}{2 + \cfrac{1}{1}}} \]
\[ \sqrt{13}\]\[= 3 + \cfrac{4}{6 + \cfrac{4}{6 + \cfrac{4}{6 + \cfrac{4}{6+...}}}} \]
Simple continued fractions are calculated by repeatedly taking the floor of a real number and inverting the remainder, resulting in a string of unit values as the numerators. Negative or reversal continued fractions involve taking the ceiling of a given number and subtracting the difference.
Alternative approaches might involve setting all denominators to 1 - or even setting denominators to any constant value! These different forms offer interesting new ways to compute and explore these fascinating mathematical creations.
The focus here lies with what we define as inverted continued fractions (in which denominators rather than numerators are set to the same repeated value).
Two varieties are defined: Type 1 inverted continued fractions, for which the leading value (the floor of the real number) remains separate, and Type 2, in which the leading value is merged into the overall continued fraction. We will further define a simple inverted continued fraction as an inverted continued fraction with constant denominator 1.
\[\frac{24}{7} = 3 + \frac{1}{7}\] = \(3 + \cfrac{1}{2 + \cfrac{1}{2 + \cfrac{1}{1}}}\) = \(4 - \cfrac{1}{2 - \cfrac{1}{4}}\)
\(= 3 + \cfrac{1}{1 + \cfrac{2}{1 + \cfrac{1}{1 + \cfrac{1}{1}}}}\) = \(= 3 + \cfrac{1}{2 + \cfrac{1}{2 + \cfrac{2}{2}}}\) = \(3 + \cfrac{2}{3 + \cfrac{6}{3 + \cfrac{2}{3 + \cfrac{2}{3 + \cfrac{9}{3}}}}} \cdots \)
= \(\cfrac{4}{1 + \cfrac{1}{1 + \cfrac{5}{1 + \cfrac{1}{1}}}}\) = \(\cfrac{7}{2 + \cfrac{1}{2 + \cfrac{44}{2}}}\) = \(\cfrac{11}{3 + \cfrac{1}{3 + \cfrac{6}{3 + \cfrac{2}{3 + \cfrac{9}{3}}}}} \cdots \)
Type 1 Inverted Continued Fractions: \(cfi(x,n)\)
\[\frac{24}{7} = 3 + \cfrac{1}{1 + \cfrac{2}{1+ \cfrac{1}{1+ \cfrac{1}{1}}}}\]
If simple continued fractions are calculated by repeatedly taking the floor of a real number and inverting the remainder, how might we set denominators (after the initial floor value) to a constant value? What are termed here Type 1 Inverted Continued Fractions retain the leading term (the floor) and operate upon the fractional remainder.
\[⇒ [3;1,2,1,1]_{1}\]\[\approx 3.4285714285714284\]\[⇒ \ Convergents:\]\[[3,4,\frac{10}{3},\frac{7}{2}, \frac{17}{5}, \frac{24}{7}]\]\[Error = 0 \%\] [3,1,1,1,1]
[1,2,1,1,0]Compare a range of values of n for \(\frac{24}{7}\)?
\[\frac{24}{7} = 3 + \frac{3}{7}\]\[= 3 + \cfrac{1}{\frac{7}{3}}\]\[= 3 + \cfrac{1}{1 + \frac{4}{3}}\]\[= 3 + \cfrac{1}{1 + \cfrac{2}{2 \cdot \frac{3}{4}}}\cdots \]\[where \ 2 = \lceil \frac{4}{3}\rceil \ and \ \frac{2}{2 \cdot \frac{3}{4}} = \frac{4}{3} \]\[Then \ 2\cdot \frac{3}{4} - 1 = \frac{3}{2} - 1 = \frac{1}{2}\]\[= 3 + \cfrac{1}{1 + \cfrac{2}{1 + \cfrac{1}{1 + \frac{1}{1/2} \cdots }}}\] \[cfi(x,n)\]\[To \ begin, \ let \ a_0 = \lfloor x \rfloor, \ b_0 = x - a_0 \]\[⇒ \ x = a_0 + b_0\]\[Let \ c_0 = \lceil n\cdot b_0\rceil \ and \ b_0 = \frac{c_0}{c_0\cdot \frac{1}{b_0}}\]\[\ Let \ b_1 = \frac{c_0}{b_0}-n\]\[ ⇒ x = a_0 + \cfrac{c_0}{n + b_1}\]\[Subsequent \ steps: \]\[Let \ c_1 = \lceil n\cdot b_1\rceil \ and \ b_1 = \frac{c_1}{c_1\cdot \frac{1}{b_1}}\]\[⇒ \ b_2 = \frac{c_1}{b_1}-n \ and \ c_2 = \lceil n\cdot b_2\rceil\]\[ ⇒ x = a_0 + \cfrac{c_0}{n + \cfrac{c_1}{n + c_2}}\cdots \] 1. First, try the inverted continued fraction for Eulers Number \(e\).
2. Quadratic irrationals, of course, are always of interest. As expected, these will have periodic forms - but you may need to try different denominator values!
For denominator 1, try \(\sqrt(2)\), \(\sqrt(5)\) and \(\sqrt(10)\) (square roots of the form \(n^2+1\)?) but \(\sqrt(6)\) and \(\sqrt(7)\) both work with denominator 4, \(\sqrt(11)\) and \(\sqrt(15)\) like denominator 6, while \(\sqrt(19)\) seems to have a preference for 8!
The challenge here lies in discovering if there is a way to predict what this will be for any given quadratic.
\[\sqrt{2} = \sqrt{(1^2+1)} \ = \ [1;1,1,1,1,1,1,...]_{2} = cfi(\sqrt{2},2)\] \[\sqrt{3} = \sqrt{(1^2+2)} \ = \ [1;2,2,2,2,2,2,...]_{2} = cfi(\sqrt{3},2)\] \[\sqrt{4} = 2\] \[\sqrt{5} = \sqrt{(2^2+1)} \ = \ [2;1,1,1,1,1,1,...]_{4} = cfi(\sqrt{5},4)\] \[\sqrt{6} = \sqrt{(2^2+2)} \ = \ [2;2,2,2,2,2,2,...]_{4} = cfi(\sqrt{6},4)\] \[\sqrt{7} = \sqrt{(2^2+3)} \ = \ [2;3,3,3,3,3,3,...]_{4} = cfi(\sqrt{7},4)\] \[\sqrt{8} = \sqrt{(2^2+4)} \ = \ [2;4,4,4,4,4,4,...]_{4} = cfi(\sqrt{8},4)\] \[\sqrt{9} = 3\] \[\sqrt{10} = \sqrt{(3^2+1)} \ = \ [3;1,1,1,1,1,1,...]_{6} = cfi(\sqrt{10},6)\] \[\sqrt{11} = \sqrt{(3^2+2)} \ = \ [3;2,2,2,2,2,2,...]_{6} = cfi(\sqrt{11},6)\] \[\sqrt{12} = \sqrt{(3^2+3)} \ = \ [3;3,3,3,3,3,3,...]_{6} = cfi(\sqrt{12},6)\] \[\sqrt{13} = \sqrt{(3^2+4)} \ = \ [3;4,4,4,4,4,4,...]_{6} = cfi(\sqrt{13},6)\] \[\sqrt{14} = \sqrt{(3^2+5)} \ = \ [3;5,5,5,5,5,5,...]_{6} = cfi(\sqrt{14},6)\] \[\sqrt{15} = \sqrt{(3^2+6)} \ = \ [3;6,6,6,6,6,6,...]_{6} = cfi(\sqrt{15},6)\] Can you see a pattern emerging? Can you predict the inverted continued fraction for any quadratic irrational of the form \(\sqrt{x^2+n}\)? Like a hint?
3. Further, the inverted continued fraction for some rationals occurs in more than one form: what might be thought of as a compact form as well as an expanded form.
For example,
\[\frac{24}{7} = [3;1,2,1,1]\]\(= [3;1,2,1,2,1]\)
and
\[\frac{22}{7} = [3;1,6]\]= \([3;1,7,1,6,1,5,1,4,1,3,1,2,1]\)
and also
\[\frac{73}{17} = [4;1,3,1,3]\]= \([4;1,3,1,4,1,3,1,2,1]\)
And perhaps more dramatically
\[\frac{117}{29} = [4;1,28]\]= \([4;1,29,1,28,1,27,1,26,1,25,1,24,1,23,...]\)
(to 16 decimal places!)But why does this happen for some values and not others?
Explore...
Type 2 Continued Fractions with Constant Partial Denominators: \(cdn(x,n)\)
A similar approach arises from the work of Topi Törmä (University of Oulu, Finland): GENERALIZED CONTINUED FRACTION EXPANSIONS WITH CONSTANT PARTIAL DENOMINATORS (2018), proving that, for any rational number, there exist infinitely many finite, periodic and aperiodic expansions, and that for any quadratic irrational number there exist infinitely many periodic and aperiodic expansions.
While the computation process for each term is essentially the same, this alternative differs from that described above by merging the leading term of the given real number (the floor) into the continued fraction: thus, for example,
\[cfi(\frac{24}{7}) = 3 + \cfrac{1}{1 + \cfrac{2}{1+ \cfrac{1}{1+ \cfrac{1}{1}}}}\] \[cdn(\frac{24}{7},1) = \cfrac{4}{1 + \cfrac{1}{1+ \cfrac{5}{1}}}\] \[cfi(\frac{24}{7}) = 3 + \cfrac{2}{3 + \cfrac{6}{3+ \cfrac{2}{3+ \cfrac{2}{3+ \cfrac{9}{3}}}}}\] \[cdn(\frac{24}{7},3) = \cfrac{11}{3 + \cfrac{1}{3+ \cfrac{6}{3+ \cfrac{2}{3+ \cfrac{9}{3}}}}}\] Consequently, for real number values between 0 and 1, the different approaches described here will result in identical continued fractions.
\[cfi(\frac{5}{17}) = 0 + \cfrac{2}{6 + \cfrac{5}{6+ \cfrac{2}{6+ \cfrac{12}{6}}}}\] \[cdn(\frac{5}{17},6) = \cfrac{2}{6 + \cfrac{5}{6+ \cfrac{2}{6+ \cfrac{12}{6}}}}\] What remains challenging may be predicting what might be thought of as optimal values of n for rationals and periodic irrationals: arrays of minimal length for rational values, and periodic elements for irrationals.
\[cdn(\frac{5}{17},1)\]\[⇒\]
\[\cfrac{1}{1+\cfrac{3}{1+\cfrac{1}{1+\cfrac{3}{1}}}}\] \[= \frac{5}{17}\]\[\approx 0.29411764705882354\]\[⇒\] [1,3,1,3]
[1,1,1,1]\[⇒ [1,3,1,3]_{1}\]
Error: 0%
Some Examples ⇓
The Challenge: To find the optimal value of \(n\) for each real number.
\[\frac{5}{17}\] \[1\]\[10\] \[[1,3,1,3]\]\[[3,2]\] \[\sqrt{2}\] \[1\]\[2\]\[7\] \[[1,2,1,2,1,2,1,2...]\]\[[3,1,13,1,21,1,24,1,27,1,136,1,140,1,7849...]\]\[[10,1,50,1,50,1,50...]\] \[\pi\] \[1\]\[2\] \[[4,1,3,1,7,1,37,1,71,1,449,1,657,1,991...]\]\[[7,1,5,1,17,1,20,1,108,1,204,1,239,1,326...]\] \[e\] \[1\]\[7\] \[[3,1,9,1,24,1,65,1,67,1,335,1,881,1,1152... ]\]\[[20,3,10,2,23,2,5,6,4,5,9,2,4,2,22... ]\] \[e-2\] \[1\] \[[1,1,2,1,3,1,4,1,5,1,6,1,7,1,8... ]\] Study the first and last examples: Can you see a connection with our inverted continued fractions?
Compare a range of values of n for \(\frac{5}{17}\)?
Mathematical ToolBox
About the MathBoxes...
Hint: When entering mathematical expressions in the math boxes below (f(x), g(x) and h(x)), use the space key to step out of fractions, powers, etc. On Android, begin entry by pressing Enter.
Type simple mathematical expressions and equations as you would normally enter these: for example, "x^2[space]-4x+3", and "2/3[space]". For more interesting elements, use Latex notation (prefix commands such as "sqrt" and "nthroot3" with a backslash (\)): for example: "\sqrt(2)[space][space]". Learn More?
Behind the Scenes
©2025 Compass Learning Technologies ← GXWeb Showcase ← GXWeb Fractured Fractions Collection → Inverted Continued Fractions