4

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}}},... $$

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
David
  • 14,883
  • 4
  • 44
  • 117

2 Answers2

8

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

corey979
  • 23,947
  • 7
  • 58
  • 101
  • 2
    To generate the sequence use NestList rather than Nest – Bob Hanlon Mar 21 '17 at 23:48
  • 3
    Instead of HoldForm[], use Defer[], so that the results can be copied, pasted, and executed without needing a ReleaseHold[]. – J. M.'s missing motivation Mar 22 '17 at 02:10
  • @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. – David Mar 22 '17 at 16:07
  • @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. – J. M.'s missing motivation Mar 22 '17 at 16:35
  • @J.M. Aha! So what I should have read from your comment is to copy and paste the output into the FindSequence function. Thanks. – David Mar 22 '17 at 17:09
5
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.  *)
Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • 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. – David Mar 22 '17 at 15:52
  • @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. – Bob Hanlon Mar 22 '17 at 16:16
  • Aha! That's how you came up with your idea. A very nice move. Thanks. – David Mar 22 '17 at 17:11