Saturday, January 15, 2011

Mandelbrot? Mandelbrot!

I like that dude! Have you met him? He's a real charmer that Benoit... you better watch yourself. He's also as clever as clever gets. Not clever as us Canadians use the word, more "British" clever. Meaning he's just a really smart dude. After listening to the song Mandlebrot Set by Jonathon Coulton I thought I'd try and get my trusty Ti-83 Plus to draw me a pretty picture. Considering I'm not a math major and have a very limited knowledge of programming in general. I had to figure out first does the Mandlebrot Set have a describing equation? what the hell is it? and finally how to program a calculator to draw it. The Wikipedia page for the Mandelbrot Set was all I needed, it even gave me the psuedocode to get going. At the end of the day the Ti-basic code looked like this:

prgmMNDLBRT
1  :FnOff : ClrDraw
2  :PlotsOff
3  :AxesOff
4  :-2.5->Xmin:1->Xmax
5  :-1->Ymin:1->Ymax
6  :For(T,-1,1,2/64)
7  :For(S,-2.5,1,3.5/96)
8  :prgmMNDLBRT2
9  :If I=M
10 :Pt-On(S,T)
11 :End
12 :End
13 :StorePic 1

Basically all that is going on is the program goes through every pixel of the screen. There are 64x96 pixels on the screen so each point on a screen simply needs to be calibrated for the range of x and y values, hence the 2/64 and 3.5/96. It checks the program below and will only turn that pixel on if MNDLRBRT2 outputs I=M. I split this up into two programs for simplicity's sake but in reality you only need one. There is more background info on the wiki page, but that's the basics.

pgrmMNDLBRT2
1  :0->X:0->Y
2  :10->M:0->I
3  :While X*X+Y*Y<=4 and I<M
4  :2XY+T->Z
5  :X*X-Y*Y+S->X
6  :Z->Y
7  :I+1->I
8  :End
9  :Return

At first the calculator didn't seem to be doing anything, but it was running. So I decided to half the iterations by telling the for loops in prgmMNDLBRT to iterate by 4/64 and 7/96 respectively. This way only half the pixels on the screen would be tested. Again a few minutes passed and finally a little pixel went dark! Soon after there was another, and another! I hadn't been this excited since Christmas in 1994 when my grandparents gave me a turtle wheelbarrow. The final result look like this:
  Iterations per pixel (M) :10, Time to finish: 19 minutes. Good? I don't think so lets try 100 iterations per (every other) pixel:
 Iterations per pixel: 100, Time to finish: 70 minutes.This looked pretty neat, but I was not satisfied and decided to see what happened if I let my calculator take its sweet time with every pixel:

Iterations per pixel: 10, Time to finish: ~70minutes.

 Iterations per pixel: 100, Time to finish: ~180minutes.

 Iterations per pixel: 250, Time to finish: ~480minutes. For this one I started it before bed, checked it in the morning and still had to wait for another 2 hours. But the end result was pretty sweet. Too bad the Ti series calculators didn't have colour screens. That would be too much nerd to handle.

-Rois

Sunday, August 29, 2010

Right, you Left.














April 18 2006
(forgive me, I'm young)

I loved you and now
all I can say is
Rest in peace to you

Rest in peace dear anonymous
Rest in peace best friends
you were the only things
that I had left
and you left me

I'm not trying to tell you
that my life is shit
only that it's worse than
yours

three things that I held strong
I cried when you left
and I cried when he left
but I laughed when he left

it's not so hard to have things forced

I'm not sure whether to wave good-bye
or ask you back

but you left me
then he left me
then he left me

and you're all gone for good
and you're all gone for good

but I cried, yes I cried, and I cried
and you watched me
with nothing but a stare
you even kicked me
while I was
down

but he left me
because you left me
then he left me

A Poem for My Dearest

Armageddon is closing in,
maybe it won’t hurt so bad
yesterday the news said the situation was win-win
man this feels like a fad

I’m hearing it everywhere
tens of thousands all say the same
toonies, loonies to pay a cab fare
only the side affects are what we’re going to blame

nobody will have anything left
your money will be all gone
of course you’ll blame it on theft
unless of course you are a moron

more than likely you dumb-ass bitch
outgoing and pretty,
no you’re just a fucking witch
ever go to that restaurant owned by Smitty?

you would, cause you can, and you have the funds
harnessing the power of the dollar
uncle Sam has you thinking you’ll run
nationally for something that’ll make you much taller

growing, bigger and bigger your purse will grow
reproducing children, you pop out three
you can surely afford it
what can you do beside listen to me?

house made of clay, food made of scraps
outside burning to death in the land of no maps
really, this was mean … but true.
except for the part where I love you.

-Rois