Lesson goal: Golden Ratio by Radical Iteration

Previous: $\sqrt{n}-\sqrt{n-1}<0.01$ | Home | Next: Introduction

Consider the infinite nested radical expression: $$x = \sqrt{1 + \sqrt{1 + \sqrt{1 + \dots}}}$$ If we square both sides of this equation, we get: $$x^2 = 1 + \sqrt{1 + \sqrt{1 + \dots}} = 1 + x$$ $$x^2 - x - 1 = 0$$ Using the quadratic formula, the positive root is the famous Golden Ratio ($\phi$): $$\phi = \frac{1 + \sqrt{5}}{2} \approx 1.6180339887...$$ In the 1970 MAA High School Mathematics Contest (Problem #1), students evaluated powers of nested radicals. How do computers calculate such numbers? Instead of solving algebra on paper, computers can use fixed-point iteration with a while-loop. Starting from an initial guess $x = 1$, we repeatedly update: $$x_{\text{next}} = \sqrt{1 + x}$$ until the difference between consecutive values is smaller than a tiny tolerance (like $0.000001$).
x = 1.0
x_next = math.sqrt(1 + x)

while math.abs(x_next - x) > 0.000001 do

  x = x_next
  x_next = math.sqrt(1 + x)
end
Move the mouse over a dotted box for more information.

The while-loop terminates automatically once the digits stop changing. This numerical method is guaranteed to converge to the Golden Ratio regardless of any positive starting value!

Now you try. Complete the while-loop condition and update step. Run the code to watch the values converge to $1.618034$ and see how many steps it takes!

Type your code here:


See your results here: