Home /
Expert Answers /
Advanced Math /
2-a-finite-continued-fraction-is-a0-a1-a2-an1111-and-may-be-denoted-pa122

(2) A finite continued fraction is: $a_{0}+a_{1}+a_{2}+?+a1?1?1?1?$ and may be denoted by $[a_{0};a_{1},a_{2},…,a_{n}]$. (a) Write a program that takes as inputs $[a_{0};a_{1},a_{2},…,a_{n}]$ and gives the floating point value of the finite continued fraction using the above definition. (b) An infinite continued fraction for the golden ratio is: $?=1+1+1+…1?1?$ A convergent is obtained by terminating a continued fraction at a finite number of operations. The convergents for the continued fraction above are: $1,1+1/1,1+1/(1+1/1),…$ Write a program that computes successive convergents until $?$ is found accurate to five significant digits. Include a copy of your code and a table with successive convergents. (c) A continued fraction for $2?$ is: $2?=1+2+2+…1?1?$ Assuming that you can work with infinite continued fractions the same way that you work with finite fractions, can you give a quick argument why this is true? Modify your program for the golden ratio above to compute $2?$ to five significant digits. (d) For a given finite continued fraction $[a_{0};a_{1},a_{2},…,a_{n}]$, define $p_{k}$ and $q_{k}$ by: $p_{k}q_{k}?=a_{k}p_{k?1}+p_{k?2}=a_{k}q_{k?1}+q_{k?2}?$ and $p_{?2}=0,p_{?1}=1,q_{?2}=1,q_{?1}=0$. Then the continued fraction equals $p_{n}/q_{n}$. Write a program that uses this recurrence relation to compute the continued fraction expansion for any $[a_{0};a_{1},a_{2},…,a_{n}]$, and compare the values you get for $?$ and $2?$ with those you arrived at in parts (b), (c) above.

(a) Here is an example program in Python that takes a list of integers as input and returns the floating point value of the finite continued fraction: