3
$\begingroup$

Consider:

$$a_1=\sqrt{2}\qquad\text{and}\qquad a_{n+1}=\sqrt{2a_n}$$

I can do this:

RecurrenceTable[{a[n + 1] == Sqrt[2 a[n]], a[1] == Sqrt[2]}, a, {n,5}]

Now, is there a way I can HoldForm so that the RecurrenceTable command produces this sequence:

$$\sqrt{2}, \sqrt{2\sqrt{2}}, \sqrt{2\sqrt{2\sqrt{2}}},... $$

$\endgroup$
7
$\begingroup$

How about translating the recurrence relation into Nest?

Nest[HoldForm[Sqrt[2 #]] &, Sqrt[2], 4]

enter image description here


To generate the sequence, simply turn Nest into NestList:

NestList[HoldForm[Sqrt[2 #]] &, Sqrt[2], 4]

enter image description here

$\endgroup$
5
  • 2
    $\begingroup$ To generate the sequence use NestList rather than Nest $\endgroup$ – Bob Hanlon Mar 21 '17 at 23:48
  • 3
    $\begingroup$ Instead of HoldForm[], use Defer[], so that the results can be copied, pasted, and executed without needing a ReleaseHold[]. $\endgroup$ – J. M.'s torpor Mar 22 '17 at 2:10
  • $\begingroup$ @J.M. I'm curious about "the results can be copied, pasted, and executed" because I tried (using Bob Hanlon's idea below) seq = NestList[Sqrt[2 #] &, Sqrt[2], 4], then 2^FindSequenceFunction[Log[2, seq], n] and it worked. Then I tried using the Defer command, using seq = NestList[Defer[Sqrt[2 #]] &, Sqrt[2], 4], then 2^FindSequenceFunction[Log[2, seq], n], but this time it did not work. $\endgroup$ – David Mar 22 '17 at 16:07
  • $\begingroup$ @David, the Defer[] prevents execution. Try this for yourself: run s = Defer[1 - 1] in a cell. In a new cell, run s. Then, copy the output cell of the first cell (which should be showing 1 - 1), paste into a new cell, and run it. $\endgroup$ – J. M.'s torpor Mar 22 '17 at 16:35
  • $\begingroup$ @J.M. Aha! So what I should have read from your comment is to copy and paste the output into the FindSequence function. Thanks. $\endgroup$ – David Mar 22 '17 at 17:09
5
$\begingroup$
Clear[a]

seqHold = RecurrenceTable[{a[1] == Sqrt[2], 
   a[n + 1] == Sqrt[HoldForm[2 a[n]]]},
  a[n], {n, 1, 5}]

enter image description here

The actual sequence is

seq = Map[ReleaseHold, seqHold, Infinity]

(*  {Sqrt[2], 2^(3/4), 2^(7/8), 2^(15/16), 2^(31/32)}  *)

Using FindSequenceFunction to determine the closed-form from this sequence

a1[n_] = 2^FindSequenceFunction[Log[2, seq], n] // Simplify

(*  2^(1 - 2^-n)  *)

Alternatively, using RSolve to find the closed-form

a2[n_] = a[n] /. RSolve[
      {a[1] == Sqrt[2], a[n + 1] == Sqrt[2 a[n]]},
      a[n], n][[1]] // Simplify // Quiet

(*  2^(1 - 2^-n)  *)

The two approaches are equivalent

a1[n] == a2[n]

(*  True  *)

EDIT: The limit of the sequence is

Limit[a2[n], n -> Infinity]

(*  2  *)

This can also be obtained using FixedPoint

FixedPoint[Sqrt[2 #] &, Sqrt[2.]]

(*  2.  *)
$\endgroup$
3
  • $\begingroup$ Nice answer. I do have a question. I tried seq = RecurrenceTable[{a[n + 1] == Sqrt[2 a[n]], a[1] == Sqrt[2]}, a[n], {n, 1, 5}], then FindSequenceFunction[seq, n] and it didn't work. Now, I know that $2^\log_{2}x=x$, but what made you think to use this fact to get the FindSequence function to work? Can you explain? Thanks. $\endgroup$ – David Mar 22 '17 at 15:52
  • $\begingroup$ @David - seq consists only of powers of 2. The sequence of the exponents is clearly a simpler sequence for FindSequenceFunction to deal with, and converting back to powers of 2 is straightforward. $\endgroup$ – Bob Hanlon Mar 22 '17 at 16:16
  • $\begingroup$ Aha! That's how you came up with your idea. A very nice move. Thanks. $\endgroup$ – David Mar 22 '17 at 17:11

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.