A continued fraction is a fraction whose numerator is an integer and whose denominator is an integer added to a fraction whose numerator is an integer and whose denominator is an integer added to a fraction, and so on.
$$1+\frac{1}{1+\frac{1}{1+\frac{1}{1+\frac{1}{1+\frac{1}{...}}}}},$$
First, we will create a formula that expresses the above expression as a sequence. Second, we will calculate the first ten terms of the sequence that have created and represent it graphically. We will also try to calculate the 200th term of the sequence and finally, Finally, we will study the "connection" that continued fractions have with the quadratic equation.
We can write this "infinite fraction" as a sequence of terms, $t_n$, where
$t_0=1$
$t_1=1+1$
$t_2=1+\frac{1}{1+1}$
$t_3=1+\frac{1}{1+\frac{1}{1+1}}$
$\cdots$
So, if we determinate a generalized formula for $t_{n+1}$ in terms of $t_n$, we have the following formula $$t_{n+1}=1+\frac{1}{t_n}$$
Now, let's compute the decimal equivalents of the first 10 terms.
$t_0=1.000$
$t_1=1+1=2.000$
$t_2=1+\frac{1}{1+1}=1+\frac{1}{2}=\frac{3}{2}=1.500$
$t_3=1+\frac{1}{1+\frac{1}{1+1}}=1+\frac{1}{\frac{3}{2}}=1+\frac{2}{3}=\frac{5}{3}=1.666$
$t_4=1+\frac{1}{\frac{5}{3}}=1+\frac{3}{5}=\frac{8}{5}=1.600$
$t_5=1+\frac{1}{\frac{8}{5}}=1+\frac{5}{8}=\frac{13}{8}=1.625$
$t_6=1+\frac{1}{\frac{13}{8}}=1+\frac{8}{13}=\frac{21}{13}\simeq 1.615$
$t_7=1+\frac{1}{\frac{21}{13}}=1+\frac{13}{21}=\frac{34}{21}\simeq 1.619$
$t_8=1+\frac{1}{\frac{34}{21}}=1+\frac{21}{34}=\frac{55}{34}\simeq 1.618$
$t_9=1+\frac{1}{\frac{55}{34}}=1+\frac{34}{55}=\frac{89}{55}\simeq 1.618$
$t_{10}=1+\frac{1}{\frac{89}{55}}=1+\frac{55}{89}=\frac{144}{89}\simeq 1.618$
fromTerms[terms_List] := Fold[#2 + 1/#1 &, Reverse@terms]
set = {1, 2, 3, 4, 5};
fromTerms[set];
FromContinuedFraction[set];
proceduralFromTerms[terms_List] :=
Module[{frac = terms[[-1]]},
Do[frac = terms[[i]] + 1/frac, {i, -2, -Length[terms], -1}];
frac]
fromTerms[Array[x, 10]]
My question is the following: how could I use the code above to calculate the first ten terms and then plot them?
x[1] + Table[ContinuedFractionK[x[i], {i, 2, b}], {b, 2, 10}] /. x -> (1 &)
(you can remove the replacement rule if you want a symbollic expression) $\endgroup$SubstitutionSystem[{n_-> 1+ 1/n}, {1}, 10]//Flatten
$\endgroup$