News for hackers. Stuff that matters.
Re:The Golden Ratio is Evil (and why, in Clojure) by gjm11 on Tuesday August 24, 2010 @10:04PM (#1631774)
Meh. It's "evil", supposedly, because if you add up the first N decimal digits of its fractional part then, for carefully chosen N, you get 666, the Number of the Beast.

I say we should be using binary rather than decimal -- ten is a terribly arbitrary number -- in which case, of course, all numbers are "evil" other than a few dyadic rationals.

Here's a better reason why the golden ratio is evil. As you know, Bob, in mediaeval times the musical interval of a tritone -- three tones, or six semitones -- was called "diabolus in musica", the devil in music. It was called that because it's a highly discordant interval; in equal temperament (which of course they didn't have back then, but hush) it corresponds to a frequency ratio of sqrt(2). And why does that sound highly discordant? Well, basically because there's no simple rational number that's a really good approximation to sqrt(2); for much much more about what's going on here, put "William Sethares" into Google and consider buying his book. In fact, in a certain sense sqrt(2) is the second-worst-approximable-by-rationals irrational number, which is related to the fact that its continued fraction is [1,2,2,2,2,2,2,...]. And what's the worst-approximable irrational number, which would produce an even more dissonant musical interval -- a maximally dissonant one -- something even worse than the devil himself in music?

Why, the golden ratio, of course. Continued fraction [1,1,1,1,...]. Evil incarnate.

(Note: there are a few half-truths in the above, but only for convenience of exposition.)

Re:The Golden Ratio is Evil (and why, in Clojure) by ihodes on Tuesday August 24, 2010 @10:49PM (#1631878)
Oh that's pretty neat! I didn't realize the connection it had to even temperament tuning.
Re:The Golden Ratio is Evil (and why, in Clojure) by cicada on Wednesday August 25, 2010 @12:39AM (#1632029)
The first 144 digits of the fractional part of pi sum to 666.
Re:The Golden Ratio is Evil (and why, in Clojure) by onoj on Tuesday August 24, 2010 @11:57PM (#1631970)
"golden ratio" nonsense. The words never link to the correct maths. It is evil, but not rational. http://www.lhup.edu/~dsimanek/pseudo/fibonacc.htm
Re:The Golden Ratio is Evil (and why, in Clojure) by japherwocky on Tuesday August 24, 2010 @10:32PM (#1631837)
I think there are about 666 parentheses in those code examples.. I don't get the appeal of Clojure?
Re:The Golden Ratio is Evil (and why, in Clojure) by ihodes on Tuesday August 24, 2010 @11:15PM (#1631918)
You don't really see the parens after a while. Clojure's appeal goes beyond its syntax, as I'm sure does whichever language you prefer.

Curiously, the equivalent code in most other languages has about the same number of parens.

Re:The Golden Ratio is Evil (and why, in Clojure) by substack on Wednesday August 25, 2010 @12:33AM (#1632019)
For fun I was whipping up some haskell one-liners as I read along.

You can just do:

    let fibs = 1 : 1 : [ fibs !! n + fibs !! (n - 1) | n <- [1..] ]
for the Fibonacci sequence and

    take 10 $ iterate (succ . recip) 1
for the first 10 iterations of the continued fraction.

To me these read much more clearly but then I haven't written anything big in a lispy language yet.

Re:The Golden Ratio is Evil (and why, in Clojure) by ihodes on Wednesday August 25, 2010 @12:49AM (#1632050)
There are all sorts of ways to do it; for instance, I really like the following:

    (def fibo (map second 
                   (iterate (fn [[x y]] [y (+ x y)]) [0 1])))
I just went with a different version for the article to show another way of doing it that might be clearer to someone new to Clojure. As for understanding/ease of reading, the Haskell version is a little more alien to me, but that's because I haven't spent much time in Haskell.

Once again, for your CF ex:

    (take 10 (iterate (comp inc /) 1))
Which gives ratios in Clojure, not doubles. Both elegant solutions, definitely. I just wanted to use my GCF, which could probably be made to look a little nicer as well. This post was more about playing around with the Golden Ratio than writing sexy code (though admittedly, I probably could have done better in many places!)

Haskell is a really cool language: I'm making my way through Real World Haskell right now!

Re:The Golden Ratio is Evil (and why, in Clojure) by hga on Wednesday August 25, 2010 @02:23PM (#1633681)
Lisp syntax is trivial for programs and if you use a proper and consistent indentation style ... I get the impression that it's somewhat akin to Python once "[y]ou don't really see the parens".

Which is indeed what happened with me, I saw indentation and would e.g. use that to get the right number of closing parens in a function and at the same time detect a certain class of mistakes.

Give a Lisp an honest try (Scheme is simpler than Clojure) and you might find it works for you.

Re:The Golden Ratio is Evil (and why, in Clojure) by Groxx on Wednesday August 25, 2010 @12:13AM (#1631990)
Just to be troublesome: Ruby has implicit parens where possible, and none for defining loops :) Even including {} where applicable (single-line loops / anonymous functions), we're still talking likely significantly below 1/2.
Re:The Golden Ratio is Evil (and why, in Clojure) by rickmode on Tuesday August 24, 2010 @11:12PM (#1631914)
It won't make sense until you make a concerted effort to learn lisp. Dig into "The Little Schemer". It's enlightening. And fun.