2
$\begingroup$

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

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[1] == 3}, 
f[Infinity], n]
(* 1 + Sqrt[2] *)

N[%]
(* 2.41421 *)

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

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

Hope this helps.

Devendra Kapadia, Wolfram Research, Inc.

$\endgroup$
7
$\begingroup$

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[1] == 3};

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

Verifying that the solution satisfies the equations

eqns /. soln // Simplify

(*  {True, True}  *)

f[n] /. soln // FullSimplify

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

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

(*  1 + Sqrt[2]  *)

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

(*  1 - Sqrt[2]  *)
$\endgroup$
2
$\begingroup$

Just for fun:

cp = {x, x} /. Solve[x == 2 + 1/x, x];
fp = cp[[2, 1]]
f[x0_, n_] := 
 Sequence @@ {{##}, {{##}[[2]], {##}[[2]]}} & @@@ 
  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}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.