# How to find the limit of an infinite recursion relation

The recursive relation is $f(n+1) = 2 + \frac{1}{f(n)}$, I would like to find $$\lim_{n\to\infty} f(n)$$ given $f(1)=3$.

I tried to use RSolve but it does not give me a definite value.

RSolve[{f[n + 1] - 1/f[n] == 2}, f == 3, n]

• Try this: FixedPoint[2 + 1/# &, 3.]. It applies the function repeatedly until the output doesn't change. – Anjan Kumar Sep 27 '17 at 16:22
• Thank you, FixedPoint worked! – Henry Wang Sep 27 '17 at 16:26
• @AnjanKumar - FixedPoint[2 + 1/# &, 3.] // RootApproximant – Bob Hanlon Sep 27 '17 at 16:45
• @BobHanlon That's much better. – Anjan Kumar Sep 27 '17 at 16:50
• You have incorrect syntax for RSolve. – Edmund Sep 27 '17 at 22:13

In Version 11.2, you can use RSolveValue to obtain the answer as shown below (unfortunately, earlier versions return Indeterminate for this input).

=================

RSolveValue[{f[n + 1] - 1/f[n] == 2, f == 3},
f[Infinity], n]
(* 1 + Sqrt *)

N[%]
(* 2.41421 *)

FixedPoint[2 + 1/# &, 3.]
(* 2.41421 *)


=====================

Hope this helps.

It should be RSolve rather than Rsolve and the boundary condition must be inside the list of equations.

Clear[f];
eqns = {f[n + 1] - 1/f[n] == 2, f == 3};

soln = RSolve[eqns, f, n][];


Verifying that the solution satisfies the equations

eqns /. soln // Simplify

(*  {True, True}  *)

f[n] /. soln // FullSimplify

(*  1 + Sqrt - (2 Sqrt (1 - Sqrt)^n)/((1 - Sqrt)^n + (1 + Sqrt)^n)  *)

Limit[f[n] /. soln, n -> Infinity]

(*  1 + Sqrt  *)

Limit[f[n] /. soln, n -> -Infinity]

(*  1 - Sqrt  *)


Just for fun:

cp = {x, x} /. Solve[x == 2 + 1/x, x];
fp = cp[[2, 1]]
f[x0_, n_] :=
Sequence @@ {{##}, {{##}[], {##}[]}} & @@@
Partition[NestList[2 + 1/# &, x0, n], 2, 1]
Plot[{2 + 1/x, x}, {x, -5, 5},
Epilog -> {Red, PointSize[0.02], Point@cp}]
ListAnimate@
Table[Plot[{2 + 1/x, x}, {x, 2.3, 3},
Epilog -> {Red, PointSize[0.02], Point[cp], Line[f[3, j]]},
PlotRange -> {2.3, 2.45}], {j, 1, 5}] 