For example, I want to calculate the limit of $\frac{1}{1+\frac{2}{1+\frac{3}{1+\ldots}}}$. So I want to define:
$f(1)=1$
$f(2)=\frac{1}{1+2}$
$f(3)=\frac{1}{1+\frac{2}{1+3}}$
Then I calculate the $n\to\infty$ limit of $f(n)$.
However, I do not know how to define such a funcion in Mathematica. It seems we cannot change the parameter in Nest.
Answer
You can use Fold instead:
f[n_Integer] := Fold[#2/(1 + #) &, n, Reverse@Range[n - 1]]
f[3]
$\frac{1}{1+\frac{2}{1+3}}$
It not very useful analytically, but it allows you to invoke the CPU gods:
f /@ Range[50] // ListLinePlot[#, PlotRange -> All] &

Comments
Post a Comment