0

In order to calculate x = sqrt(1 + x) for a given number x, 40 times, I tried this:

f [x_] := Sqrt[1 + x]
N[Map[f, x = Range[40]]]

However, I got to apply the function f to every number from 1 to 40, not continuously.

The process should be Sqrt[Sqrt[Sqrt...[1+x]]]

In Matlab, I could do

x = 3
for k = 1:41
    x = sqrt(1 + x)
end

Data in Mathematica is inmutable by default, how can I do this?

Nick
  • 459
  • 4
  • 9

2 Answers2

2
f[x_] = Sqrt[1 + x];

The fixed point is the golden ratio, independent of the starting value

(x /. Solve[x == f[x], x][[1]]) == GoldenRatio

True

GoldenRatio == f[GoldenRatio] // FullSimplify

True

FixedPoint[f, {.01, .1, 1., 1.1, 10.}] // Union

{1.61803}

%[[1]] // RootApproximant

1/2 (1 + Sqrt[5])

% == GoldenRatio

True

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • Yes, I'm leaning Mathematica by calculating the Golden Ratio. It's good to know that there's even a GoldenRatio built-in the Mathematica. Thank you! – Nick Jan 30 '15 at 06:05
0

Nest is probably what you need.

Nest[f, x, 40]

enter image description here

Also worth reading the docs for Fold and FixedPoint

Mike Honeychurch
  • 37,541
  • 3
  • 85
  • 158
  • Thank you, especially for pointing out the documentation. FixedPoint is also an interesting function. – Nick Jan 30 '15 at 04:14