I finally got the new version of Twitter yesterday, and it looks great. And that's no accident: according to the designer, the layout of the new Twitter interface is based on the Golden Spiral:
You can describe the Golden Spiral by laying consecutive squares in a spiral fashion, each square being smaller than the last by a factor of the Golden Ratio, (1+sqrt(5))/2 or approximately 1.618. As a ratio of a length to a width, the Golden Ratio has been known by artists for millenia as an aesthetically pleasing aspect ratio for rectangular features in works of art (such as the dimensions of a painting). It's also known to mathematicians and statisticians as the number to which ratios of successive members of the Fibonacci sequence converge.
In a classic case of using a sledgehammer to crack a walnut, I created a custom iterator in R to represent the Fibonacci sequence (code after the fold) and verified the ratio converges to the Golden Ratio at the R command line:
> fib1 <- iFib(); nextElem(fib1) [1] 1 > fib2 <- iFib() > nextElem(fib1)/nextElem(fib2) [1] 1 > nextElem(fib1)/nextElem(fib2) [1] 2 > nextElem(fib1)/nextElem(fib2) [1] 1.5 > nextElem(fib1)/nextElem(fib2) [1] 1.666667 > nextElem(fib1)/nextElem(fib2) [1] 1.6 > nextElem(fib1)/nextElem(fib2) [1] 1.625 > nextElem(fib1)/nextElem(fib2) [1] 1.615385 > nextElem(fib1)/nextElem(fib2) [1] 1.619048 > nextElem(fib1)/nextElem(fib2) [1] 1.617647 > nextElem(fib1)/nextElem(fib2) [1] 1.618182 > nextElem(fib1)/nextElem(fib2) [1] 1.617978 > nextElem(fib1)/nextElem(fib2) [1] 1.618056 > nextElem(fib1)/nextElem(fib2) [1] 1.618026
See? Golden ratio.
Update: See this followup post on calculating the Fibonacci sequence in R.
Twitter: @stop
Very cool.
Posted by: mondo print | September 30, 2010 at 14:40
Here's an easy 3-liner that I'm sure could simply be wrapped into a function.
fv<-c(0,1)
sapply(3:20, function(i) fv[i]<<-fv[i-1]+fv[i-2])
fv[-1]/fv[-length(fv)
Which, oh, that could be compressed into 2 lines (you have to initialize the vector)
fv<-c()
sapply(1:20, function(i) if(i<3){fv[i] <<- 1}else{fv[i]<<-fv[i-1]+fv[i-2]})[-1]/fv[-length(fv)]
Posted by: jebyrnes | October 01, 2010 at 09:08
Via John Myles White, here's an amazingly elegant way of deriving the Golden Mean from its continued fraction representation using R's Reduce function:
cfrac(rep(1,n)) better approximates the Golden Ratio as n gets larger.
Posted by: David Smith | October 01, 2010 at 10:24
It turns out that you can understand why the ratio is the golden mean if you cast the sequence in terms of iteration of a certain matrix:
http://blogs.sas.com/iml/index.php?/archives/22-Matrices,-Eigenvalues,-Fibonacci,-and-the-Golden-Ratio.html
Posted by: Rick Wicklin | October 05, 2010 at 02:48
This is very exciting and I like your template as well. Keep it up.
Posted by: Thomas | January 15, 2011 at 08:34