TeflonĀ® Weltanschauung
Aug. 29th, 2009
02:22 pm - Continued Fractions III: General Arithmetic and Finalizing the Matrix
In general we can use any polynomial as the z function. ( Single variable forms, mutlivariable forms, emission, and finalization )
Aug. 26th, 2009
09:25 pm - Continued Fractions II: Simple Arithmetic
In the previous entry I talked about the basic form of a continued fraction. Here I will look at basic arithmetic operations.
( Read more... )All these rationals and irrationals at our fingertips with only integers!
Aug. 21st, 2009
09:28 am - Continued Fractions I
Continued fractions are (to me) a really interesting way of representing a wide variety a rational and irrational numbers using only integers. They have some drawbacks over floating point arithmetic, namely that they require more time (no hardware support) and memory (in the general case you need bignums). But they offer unlimited precision within those bounds.
A simple continued fraction is basically represented by [a0 a1 a2...]. This stands for
Rational numbers always have a finite representation in this scheme. Finding the continued fraction form is fairly simple. Let's relate millimeters and inches. For every inch, there are exactly 25.4 millimeters. Converting from millimeters to inches then involves multiplying by 1/25.4, or 10/254, or 5/127. What's 5/127 in decimal? 0.0393700787... If we came across this factor in this form, we'd not know much about it. Is it supposed to represent a rational? (i.e., does it terminate or repeat?) Is it irrational? No clue. In continued fraction form, though, we could say
5/127 is 0
But not quite zero, more like 0 + 1/127/5
Which is 0 + 1/25.
But not quite 25, more like 25 + 1/5/2
which is 25 + 1/2.
But not quite 2, it is 2 + 1/2.
And we get to the continued fraction [0 25 2 2].
So, for today's purpose, a continued fraction is a finite list of whole numbers that exactly stands for an equivalent rational number.
Let's look at a general algorithm to generate terms:
1) find the floor of numerator/denominator. This is our term.
2) find the remainder of numerator/denominator
3) our new number is denominator/remainder
4) stop if the denominator is 1 and output the remainder; otherwise, go to (1).
In the next entry I will delve into the mathematics of addition, subtraction, multiplication, and division by integers of continued fractions. This will also enable us to understand how to regenerate the rational number in the numerator/denominator form without having to reverse the list and perform the rational arithmetic.
