Jump to content
xisto Community
Sign in to follow this  
mitchellmckain

Representing Fractions With Continued Fractions An alternative to the decimal system

Recommended Posts

The decimal method of representing fractions has its peculiarities such as .99999... = 1 and the need for infinite repeating threes to represent a third. Then there are the irrational numbers who are represented by an infinite sequence of digits with no pattern.

 

I have been exploring the possibility of using continued fractions to represent fractions instead. The advantages include the fact that all rational numbers are represented by a finite sequence and that square roots are represented by repeating patterns. One of the biggest disadvantages is that not all the numbers in the sequence are less than 9, not to mention the difficulty of arithmetical operations on them and the difficulty of comparing of sizes.

 

A continued fraction is of following form

 

1/[a + 1/[b + 1/[c + 1/[d + 1/[e + .....

To add this to a whole integer we write

N + 1/[a + 1/[b + 1/[c + 1/[d + 1/[e + .....

and for brevity I will use the following notation

N#abcde... for the infinite continued fraction above.

For a finite continued fraction like 2 + 1/[1 + 1/[5 + 1/[3 + 1/[7]]]]

2#1537

if any of the numbers a,b,c,d,e are more than one digit (greater than 9) they will be in parentheses like this

#12( 14)53 for the finite continued fraction 1/[1 + 1/[2 + 1/[14 + 1/[5 + 1/[3]]]]]

 

The continued fraction can be computed from the decimal form of the number by the following proceedure (using 4.146 as an example). First take off the number in front of the decimal point (take off 4 leaving .146) and this goes in front of the #. Next invert what remains (so .146 becomes 6.849315068) then take off the number in front of the decimal point and this added after the # (so you have 4#6 with .849315068 remainder). Keep inverting the remainder and taking off the number in front of the decimal point and putting it at the end of your continued fraction. This is repeated until there is no remainder.

(invert .849315068 to get 1.177419355 to give us 4#61 with .177419355 remaining)

(invert to get 5.63636363.. to give us 4#615 with .63636363... remaining)

(invert to get 1.571428572 to give us 4#6151 with .571428572 remaining)

(invert to get 1.75 to give us 4#61511 with .75 remaining)

(invert to get 1.333333... to give us 4#615111 with .333333... remaining)

(invert to get 3 which gives us a final answer of 4#6151113)

4.146 = 4#6151113

 

For example:

 

2/3 = 1/[1 + 1/2] = #12

4.123 = 1/[8 + 1/[7 + 1/[1 + 1/[2 + 1/5]]]] = 4#87125

7/8 = #17

7/9 = #132

7/10 = #123

7/11 = #1113

7/12 = #1122

7/13 = #116

.9 = #19

.99 = #1(99)

 

 

Now for the square roots which can be represented by infinite continued fractions with repeating patterns. A truncated continued fraction with 3 or more of the repeated pattern will produce a good approximation.

 

suppose the square root can be represented by a repeating continued fraction like this

p + 1/[a + 1/[b + 1/[a + 1/[b + 1/[a + ..... = p#abababab....

with only 2 repeating digits (or only 1 repeating digit if a = B)

where p is the largest digit whose square is less than the number

Then for the square root of q, a and b are given as follows:

b = 2 p, a = b / (q - p^2)

 

This formula will not work if (q-p^2) does not divide b

In such cases you can use the previous method of converting their decimal form (calculated using a calculator) to a continued fraction but stopping when the repeating pattern is found.

 

So for example:

 

sqrt(2) = 1#222...

if this is truncated to 1#222 this gives 1.41666... which when squared gives 2.006944..

sqrt(3) = 1#1212...

if this is truncated to 1#121212 this gives 1.731707317 which when squared gives 2.9988

sqrt(5) = 2#444...

if this is truncated to 2#444 this gives 2.236111... which when squared gives 5.000193

sqrt(6) = 2#4242...

for the square root of 7 the above method does not work, b = 4, a = 4/3

sqrt(7) = 2#111411141114.... pattern length 4

sqrt(8) = 2#1414...

sqrt(10) = 3#666...

sqrt(11) = 3#6363...

sqrt(12) = 3#6262...

for the square root of 13 the above method does not work, b = 6, a = 6/4

sqrt(13) = 3#1111611116.... pattern length 5

for the square root of 14 the above method does not work, b = 6, a = 6/5

sqrt(14) = 3#12161216... pattern length 4

sqrt(15) = 3#1616...

sqrt(17) = 4#888...

sqrt(18) = 4#8484...

for the square root of 19 the above method does not work, b = 8, a = 8/3

sqrt(19) = 4#213128213128... pattern length 5

sqrt(20) = 4#8282...

for the square root of 21 the above method does not work, b = 8, a = 8/5

sqrt(21) = 4#112118112118... pattern length 6

for the square root of 22 the above method does not work, b = 8, a = 8/6

sqrt(22) = 4#124218124218... pattern length 6

for the square root of 23 the above method does not work, b = 8, a = 8/7

sqrt(23) = 4#13181318... patern length 4

sqrt(24) = 4#8181...

sqrt(26) = 5#(10)(10)(10)...

sqrt(27) = 5#5(10)5(10)...

 

Here is some emacs lisp code for playing with this idea.

(defun frac (a)  (- a (floor a)))(defun cf (d n) (if (= n 0) d   (if (< d .000000001) '()	 (let ((inv (/ 1.0 d)))	   (if (> (frac inv) .99999999) (list (+ 1 (floor inv)))		 (cons (floor inv) (cf (frac inv) (- n 1))))))))(defun cntf (d) (cf d 20))(defun evalcf2 (a r)  (if (null r) (/ 1 a)	(evalcf2 (+ (car r) (/ 1.0 a)) (cdr r))))(defun evalcf (c)  (let ((r (reverse c)))	(evalcf2 (car r) (cdr r))))(cntf (- (sqrt 1435) 37))(1 7 2 3 7 3 2 7 1 74 1 8 2 1 35 176 2 4 6 4 . 0.6934215039804723)Examples://converting the #2222222 to decimal(evalcf '(2 2 2 2 2 2 2)).41421568627450983 //add 1 to get the approximation of the square root of two// square it to check (* 1.41421568627450983 1.41421568627450983) 2.000006007304883//compute the continued fraction form of the square root of five// first subtract off the integer part(cntf (- (sqrt 5) 2))(4 4 4 4 4 4 4 4 4 4 4 4 2 1 10 2 1 7 8 1 . 0.7256998704588513)//so this gives accurate results up to 12 continued fraction digits in this case
Edited by mitchellmckain (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.