To find a continued fraction expansion for real numbers, we use a similar technique to how we did so for rational numbers.
First let's try an example, 5. Well, we know that this is equivalent to 15. When we do the division, we have
5=2+(5−2).
sqrt{5}=2.23606=2+0.236... which is an integer plus irrational part less than .
Where did we get the 2 from?
Yes, we just took the the largest integer less than or equal to 5. We will deonte this by ⌊5⌋=2. So, we know that
5=2+x1,
for some x. Then, let's solve for x to get
x=5−21=2+5.
Now we repeat the process to get
2+5=4+x1,
where x=2+5. However, note that we computed the continued fraction for 2+5 already! So, we know that it repeats.
5=2+4+4+⋱11=[2,4,4,4,4,⋯].
We will express the repeating part of the continued fraction with a bar on top, like so:
5=[2,4,4,4,⋯]=[2,4].
Now let's generalize
If n is irrational, by the division algorithm, we can write an equation in the following form:
n=1q1+rwhere n−r1<1.
However, note that r1=n−⌊n⌋ is also irrational. Thus, we can write a similar equation:
1=r1q2+r2.
Since we will always get an irrational remainder, we can continue this process infinitely. Now let's rearrange the equations to get what we want.
n=1q1+r11=r1q2+r2r1=r2q3+r3⟹n=q1+r111.⟹r11=q2+r2r11⟹r2r1=q3+r3r21⋮
So, we can just repeatedly substitute into the previous equation to get the continued fraction
n=q1+r111=q1+q2+r2r111=q1+q2+q3+r3r2111=⋮=[q1,q2,⋯].