Teaching Kids Programming – Estimate the Golden Ratio via Fibonacci Numbers in Python


Teaching Kids Programming: Videos on Data Structures and Algorithms

The Golden Ratio, in mathematics, is often denoted using the symbol tex_05737271a52d92eb068dd7d462bc0e3a Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python. The approximate value of the Golden Ratio is often known as 1.618, which can be obtained by solving the following equation.

tex_32f53a7aefd994df67fec738e0b29aab Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python which gives two roots.

tex_e4e2ec4ce12970a9f4cfb0ee216e50f5 Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python or

tex_3b1be89582c8d2edf05b21b10ece1ac9 Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python

Two line segments (lengths are a and b, respectively) are said to be in golden ratio if the lengths satisfy the following.

tex_1619b434dd692aa802b915169fc768ad Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python

gr1 Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python

Similarly, the golden rectangle should meet the following:

gr2 Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python

tex_1619b434dd692aa802b915169fc768ad Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python

We all know that the Fibonacci numbers are defined as:

tex_367bb12897de9550294f1ebbb515bd85 Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python

for tex_bad6e070ef84bb84c8c2f95ff0c5c85f Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python

and tex_35c3bc5b8b6857826aabe2df22b1e50f Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python

The ratio between the number in the series and its successor tends to converge to tex_05737271a52d92eb068dd7d462bc0e3a Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python

For example, any three continuous numbers in the series can be defined as b, a, b + a.

Therefore, we find that, the ratio between the first two and the last two numbers are

tex_3166c86f565dc22d61438211c746259d Teaching Kids Programming - Estimate the Golden Ratio via Fibonacci Numbers in Python

Let’s verify this in a small Python code via computing the first 20 numbers of the Fibonacci Sequences.

#!/usr/bin/env python

a = 1
b = 1
N = 20

for i in range(N):
    a, b = b, a + b
    print(b * 1.0 / a)

Let’s observe the output and we can see the Estimation of the Golden Ratio converges pretty fast.

2.0
1.5
1.66666666667
1.6
1.625
1.61538461538
1.61904761905
1.61764705882
1.61818181818
1.61797752809
1.61805555556
1.61802575107
1.61803713528
1.61803278689
1.61803444782
1.6180338134
1.61803405573
1.61803396317
1.61803399852
1.61803398502

References:

http://en.wikipedia.org/wiki/Golden_ratio

–EOF (The Ultimate Computing & Technology Blog) —

801 words
Last Post: How to use align-data-move SSE in Delphi XE3 ?
Next Post: GetThreadID and GetProcessID from TIB

The Permanent URL is: Teaching Kids Programming – Estimate the Golden Ratio via Fibonacci Numbers in Python (AMP Version)

Leave a Reply