Golden ratio/Convergence

From Rosetta Code
Revision as of 01:33, 3 June 2023 by Chemoelectric (talk | contribs) (Created page with "{{task}} The golden ratio can be defined as the continued fraction :<math>\phi = 1 + {1\over{1+{1\over{1+{1\over{1 + \cdots}}}}}}</math> Thus <math>\phi = 1 + {1/\phi}</math>. Multiplying both sides by <math>\phi</math> and solving the resulting quadratic equation for its positive solution, one gets <math>\phi = (1 + \sqrt{5})/2 \approx 1.61803398875</math>. The golden ratio has the slowest convergence of any continued fraction, as one might guess b...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Golden ratio/Convergence
You are encouraged to solve this task according to the task description, using any language you may know.

The golden ratio can be defined as the continued fraction

Thus . Multiplying both sides by and solving the resulting quadratic equation for its positive solution, one gets .

The golden ratio has the slowest convergence of any continued fraction, as one might guess by noting that the denominators are made of the smallest positive integer. This task treats the problem of convergence in a somewhat backwards fashion: we are going to iterate the recursion , , and see how long it takes to get an answer.

Task

Iterate , until . Report the final value of , the number of iterations required, and the error with respect to .

See also