January 2018

S M T W T F S
  123456
78910111213
14151617181920
21222324252627
28293031   

Style Credit

Expand Cut Tags

No cut tags
pozorvlak: (pozorvlak)
Tuesday, June 26th, 2007 01:27 pm
I've fixed the J Mandelbrot set program. Needless to say, the fix took precisely three characters :-)

[By the way, did anyone read that post? Does anyone else think J is interesting? Or did you just see a wall of punctuation and get scared off?]

The gory details )

Now here's the interesting bit: the Haskell version seems only to work because of what I can only assume is a bug in GHC's handling of IEEE 754 special values. The Haskell version behaves exactly like the J version until it gets to the stage of taking the magnitude of NaN + i NaN, at which point (in Hugs) it dies with an "arithmetic overflow!" error (grrrr: that's what Infinity and NaN are for), or (in GHC) it returns Infinity (which is greater than 2, of course). G'huh? How does Infinity make sense here? It's not a number, it doesn't have a magnitude, much less an infinite one. Even more weirdly, sqrt (nan*nan + (nan*nan)) returns NaN as expected.

Yet again, I suffer pain because someone didn't read IEEE 754 properly. Which is the IEEE's fault for charging heavily for their standard documents, rather than making them freely available like they would have done if they actually cared about wide dissemination and interoperability. Grrrrr.
pozorvlak: (Default)
Saturday, June 9th, 2007 11:04 pm
I've been learning the programming language J recently, and in the course of my studies came across this example program by Ewart Shaw, to draw an ASCII-graphics Mandelbrot set:
{&'#.' @ (2:<|) @ ((+*:)^:400 0:) (18 %~ i:_20) j.~/ 28 %~ _59+i.75
It embodies so many J features and techniques that I'm going to analyse it here as an introduction to the language. )
pozorvlak: (babylon)
Wednesday, May 9th, 2007 12:27 pm
I've been reading Ian Stewart's book Does God Play Dice? The New Mathematics of Chaos, and I got inspired to play about with some of the stuff described therein. You've probably all seen this image before:



The formula that produces it is almost shockingly simple, and yet the behaviour it produces is really quite surprising: yet another reminder that "complicated" is not the same as "deep".

The maths behind the picture - generally accessible )

Cool, eh?
Tags: