Saturday, December 18, 2010

Mumbai rising

Mumbai is massive. That's really the best way to describe it. Its spans endlessly in seemingly all directions. Getting your bearings seems impossible. The scale of the place compounded with the traffic mean that getting from one side of town to the other can easily take 2 or 3 hours. And the traffic, it almost defies description. I know that the traffic in India is renowned, but it really lives up to its reputation. A South African driving here would break down crying in about the first city block, thank fully I had a driver (thank you Paramin) and so had the luxury of being a fairly passive observer. The roads are a constant melee. It does not matter the time of day or night, there is a gridlock. Trucks and Buses vie for position with auto-rickshaws and scooters. The auto-rickshaws flock down the roads like huge beetles, they are really something to see.

What appeared to me at first to be complete chaos I later realised was the only workable system for traffic of this nature. The rule seems to be, take any opportunity you have (no matter how slight), but be constantly conscious that everyone else is trying to do the same. Thus if some one else has gotten there first you give up and let them through, its kind of like having right of way being set as whoever has there nose in front first. The maneuvers are death defying. Three lane roads can easily have five lanes of vehicles on them, all of different and varying size. To make a three point turn in the middle of this traffic is a completely valid maneuver. If construction barriers are too close to your car its fine to stick your hand out and push them away. But its strangely nonthreatening, perhaps I don't so easily, but the system just seems to flow. This stop start bump and bash seems to have a logic and life of its own.

The motorbikes are incredible. Families of three (or even four) jet down the road, all on a little Hero Honda 125cc. They weave through traffic with a reckless abandon, deftly avoiding certain collisions with buses and cars. The roads are full of pretty young women straddling the back of a bike holding onto their boyfriends or husbands in front, and older women behind there husbands. These women sit side saddle because they are wearing Saree's, and modesty (I think) stops them from holding onto the rider in front, so instead they just hold onto the seat they are on. No matter how sharp the turn or sudden a maneuver they never seem to to be anything but perfectly upright on the bike. It is like there is some invisible gravity that makes sure they just float along in perfect unison with the bike beneath then. It is an almost eerie sight.

The skyline is impressive. In all directions there are towering constructions of new residential towers or massive office blocks, all 50+ stories high. From my previous apartments (I am now in New Delhi) window I could see 10 of these huge towers within a few blocks, some are still being built but none of them are more than 3 years old. It is as if the city can no longer grow out (since it is on a peninsula) and the continual massive growth of the Indian economy is driving it up out of the ground.

The most striking thing about Mumbai though is the is the tangible sense of ambition. It electrifies the air, along with the scramble to survive. All the young men walk around in collared shirts, good pants and (ironically) leather shoes. They look like fields or accountants (though most of them I think work in call centers). It is so important to them to look successful and to constantly work to improve their position in life. Where western advertisers try to sell the idea of "cool", here they try to sell the idea of "success". You can see it on TV, on billboards and in the shops. The driving ambition permeates everything. Perhaps this is what America used to feel like when everyone started striving towards the American dream? In any case it is a monumentally powerful force, with a huge, young, educated workforce this ambitious it is no wonder that India grows year on year. It is an almost humbling realisation.

I wonder what Mumbai will look like in 20 years? it has the potential to become a beautiful city, right now the private spaces are exquisitely maintained but almost all the public spaces a dirty and broken. The obvious wealth of the city juxtaposed against the dirt and poverty is not strange for a person coming from South Africa, but is far more immediate a contrast. But perhaps the rising wealth will uplift the public areas, clean the streets, repaint the disastrously dirty old walls of old apartments (which are very nice inside). Right now Mumbai needs a bit of photo-shopping, but its electric will to succeed is irrepressible. This cannot but be one of the cities of the future.

Monday, November 15, 2010

Why I hate C++

I was doing some C++ work today, as I do. Everything was going fine, I was making good progress. I had just recompiled, but when I ran this is the error message I got.

ideaengine: /usr/include/boost/variant/detail/visitation_impl.hpp:203: typename Visitor::result_type boost::detail::variant::visitation_impl(int, int, Visitor&, VPCV, mpl_::true_, NBF, W*, S*) [with W = boost::detail::variant::visitation_impl(int, int, Visitor&, VoidPtrCV, mpl_::false_, NoBackupFlag, Which*, step0*) [with Which = boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::internal_apply_visitor_impl(int, int, Visitor&, VoidPtrCV) [with Visitor = boost::detail::variant::copy_into, VoidPtrCV = const void*, T0_ = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, T1 = boost::recursive_wrapper<std::vector<json_spirit::Pair_impl<json_spirit::Config_vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<json_spirit::Pair_impl<json_spirit::Config_vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > >, T2 = boost::recursive_wrapper<std::vector<json_spirit::Value_impl<json_spirit::Config_vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<json_spirit::Value_impl<json_spirit::Config_vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > >, T3 = bool, T4 = long long int, T5 = double, T6 = boost::detail::variant::void_, T7 = boost::detail::variant::void_, T8 = boost::detail::variant::void_, T9 = boost::detail::variant::void_, T10 = boost::detail::variant::void_, T11 = boost::detail::variant::void_, T12 = boost::detail::variant::void_, T13 = boost::detail::variant::void_, T14 = boost::detail::variant::void_, T15 = boost::detail::variant::void_, T16 = boost::detail::variant::void_, T17 = boost::detail::variant::void_, T18 = boost::detail::variant::void_, T19 = boost::detail::variant::void_]::first_which, step0 = boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::internal_apply_visitor_impl(int, int, Visitor&, VoidPtrCV) [with Visitor = ....
Now what the hell are you meant to do with that. Its ridiculous.

Its wiki-charity time again.

Support Wikipedia Its that time of the year the again. By which I mean its Wikipedia donation time again. I doubt anyone reading this doesn't frequently use Wikipedia. I know its made an enormous contribution to my life (and help me pass a maths degree). So I've donated a little, you should to.

Wednesday, September 22, 2010

The Splitting Spira Mirablis

Here is another spiral tree related post. This time I have used a logarithmic spiral, also known as the Spira Mirablis (Latin for the Miraculous Spiral).

This spiral appears in many places in nature and has a variety of interesting geometric properties. It was deeply studied by Jacob Bernoulli. He was infatuated with it to the point that he wanted it engraved on his tombstone along with the phrase "Eadem mutata resurgo" ("Although changed, I shall arise the same."). Unfortunately, the engraver put the wrong type of spiral on his tombstone.

Monday, September 20, 2010

South Park me

I stumbled upon this awesome little flash widget at Its a south park character creator. So I decided to make a south park me. I present south park James.

South Park James

Friday, September 10, 2010

Spiral Trees and Tim Burton's Forest

A friend sent me the link to the MIT OpenCourseWare site for a 2007 summer school session on Gödel, Escher, Bach: A Mental Space Odyssey. I looked at the images section and saw these cool pictures (obviously from somewhere in the book that I haven't gotten to yet). So I decided to recreate them (though using a different type of spiral).

Below you will see the animation. I have made it in 2 modes, one that creates the hypnotic spiral trees and an altered form that creates haunting trees that remind me of Tim Burton's Nightmare Before Christmas. Check it out and if you are interested I will explain the mathematics below.

Normal Mode
Tim Burton Mode

So the basic spiral tree works recursively in the following manner: It starts tracing out a spiral starting from the outside going to the center. At each point it has a random chance of splitting. When a split occurs a new spiral with the same radius is created, the center of this spiral is the reflection of the previous center through the point where the split occurs and the spiral is made to rotate in the opposite direction. This continues with each new spiral, in a process that is reminiscent of the L-Systems I have blogged about before.

The normal spiral I have used is a quadratic spiral, in that if the angle of rotation of a point in the spiral is θ then the radius is r=θ2. I believe the spirals used in the original text are logarithmic spirals (r=eθ), which are mathematically more interesting but visually took up too much of the limited space available.

For the Tim Burton style trees I generalized the notion of a spiral and allowed a non-monotonic relationship between angle and radius. I instead made the relationship proportional to sin(5θ)*θ2. which gives it the distinctive kinks but still retains a smooth profile (since the function is differentiable).

Wednesday, September 1, 2010

Exploring L-Systems

Another day, another dog. Another month, another piece of dangerous productivity avoided. This month I am avoided furthering my life goals by starting to read Godel, Escher, Bach", which is an awesome book. It deals with a remarkable amount of things, including formal logical systems. This got me delving into string manipulation systems again and somehow got me onto L-Systems.

L-Systems were developed by this theoretical botanist (yes such a thing exists) to codify plant growth. Later they were taken up by mathematicians to visualise and generate a variety of interesting recursive geometric patterns. Lately they have been used extensively to generate artificial life in computer science, especially tree like entities.

L-Systems are a string rewriting system. basically they take a string of characters, and then create a new string by replacing each old character with a new string, according to some rules. This continues and iterates creating increasingly more complicated and intricate strings of characters. These characters can then be interpreted by drawing program to make beautiful patterns. You can read more about L-Systems at the Wikipedia Article, I don't want to get bogged down in the details, I want to look at some cool patterns.

Below is an L-System generator I built. You can explore the different possibilities of L Systems. The string grammar is as follows:

  • Capital Letter: Draw a line forward
  • Small Letter: Do nothing
  • +: Turn right
  • -: Turn left
  • [:Save position to stack
  • ]:load previously saved position from stack
The rules are defined in a simple way, for example "x->y" means replace every "x" with a "y". You can change a whole bunch of settings about how the drawing system interprets the strings in the settings below. This is a bit of a rushed explanation, but you can find lots of info online that should help you out. There is also a list of interesting presets at the bottom of this post, check them out, play around, leave any interesting rules you find in the comments.

Number of Generations:
Starting Point: (, )
Starting Angle:
Turn Angle:
Movement Size:

Interesting Examples

Friday, August 20, 2010

Fractals folding out new lands

In keeping with my apparent intense dislike of doing anything constructive (like say my work or my masters), here is another fractal image. This one a bit different from the others in that it is mathematically much simpler and its construction is animated. This is called (at least by me) a divided line fractal (not to be confused with a cantor set). It is very similar to the Koch Curve but with an element of randomness that creates intricate and varied shapes that come to resemble islands or coastlines. This similarity between coast lines and fractals was one of the earliest observations by Benoît Mandelbrot, resulting in his well known paper "How Long Is the Coast of Britain?". Similar techniques are used for artificial world creation in computer simulations and games.

The fractal itself is simple to construct. Start with an initial state of two vertical lines, one from the top to the bottom and the other from the bottom to the top of the frame. The for each line take the mid point and move it to a random location around where it was, creating two new line segments. Repeat this step until all the line segments are really small.

In this implementation every time a line segment is broken up the triangle that is created is filled with a translucent yellow. The resulting shape is then filled black. I like to think of the effect as looking like the world is slowly being unfolded, or fanned out from a really simple shape to complete outline

To draw a new shape hit the "Redraw" button. Once again this is done using the HTML5 canvas so you will need a decent browser (Chrome,Safari,Firefox,Opera) to get it to work. It also probably work work through an aggregator like Google reader or buzz since I think they disable scripting, so you will have to visit my original blog page to see it work.

Saturday, June 5, 2010

Julia sets and more fractals

Following on from my last post on the Mandelbrot set I've created a Julia set generator. Julia sets are a similar sort of fractal to the Mandelbrot set. The Julia sets I am showing are all generated using the function zn+1 = zn2+c. Thus for every possible value of c we get a different Julia set. In this viewer the Julia sets are shown in red. There are many other types, but these are the classic Julia sets that led to the development of the Mandelbrot set.

The Julia sets come in two varieties; connected and disconnected sets. Either all the points in the Julia set are connected to each other (forming a single central entity) or all the points are disconnected (forming a Cauchy set, also called Fatou dust). The Mandelbrot set is generated from this fact, basically the Mandelbrot set is all the values of c such that the generated Julia set. In fact the Mandelbrot set forms a pictographic index of all the connected Julia sets. If you zoom in enough into the Mandelbrot set you will eventually find a copy of every conceivable Julia set. Which is pretty cool.

Some of the Julia sets form incredibly beautiful shapes, while others can be pretty mundane, I have put a list of some interesting sets below the viewer, just click on the links and the values will load into the viewer. Otherwise please explore the space and try your own values. If you find a combination of values that looks particularly impressive please leave the values as a comment for other people to try. The instruction for use are the same as the previous Mandelbrot viewer with the addition of being able to change the values for c by giving the real and the imaginary parts.


Some interesting sets

Click links to load:

Thursday, June 3, 2010

The Mandlebrot Set

So I have been reading allot about fractals lately (you should start with this cool book), and of course the Everest of fractals is the Mandelbrot set. The Mandelbrot set is (for those of your who don't know) an intriguing mathematical object, but I won't go into the math of it. Just take my word for it that this set is one of the coolest things ever discovered) Visually though it has boundary that is infinitely complicated, containing myriads of twisting patterns and curves (in fact in a sense it contains every possible curve somewhere on it boundary. You can zoom in on the curve and it will remain detailed at any level of zoom, never becoming a simple shape.

I've also been wanting to try out the HTML5 canvas for a while, so I decided to make a Mandelbrot set viewer with javascript. doing something like this in a browser would have been impossible a few years ago, but now with modern browsers (this excludes Internet Explorer, sorry this wont work for you but I don't care) even computationally difficult tasks are becoming feasible using javascript.

Anyway,play around with it, maybe you get a little interested, maybe you check out some of the ideas. Maybe not.


  • Below is the Viewer (If you don't see a cool shape it probably doesn't work on your browser, you should upgrade).
  • You are going to want to zoom in on a specific spot on the boundary of the black object in the middle (which is the Mandelbrot set), to do this click and drag around the place you want to zoom in on.
  • Eventually when you zoom in too far the shape will get boring, this is simply because the computer only renders an approximation. You can increase the precision by increasing the precision value in the text box and pressing the reset button. The higher the precision the longer in takes to render the picture.
  • Pressing the reset button will also let you zoom all the way out and start exploring and new part of the set.

Friday, May 14, 2010

A Masters Topic Finally

So as some of you probably know I have finished my masters proposal and finally have a real topic. Basically I am taking a certain type of social-ecological model used in decision making and policy planning and trying to hook them up to real time data. I'm doing this to check:

  1. That the models are correct
  2. That the decisions made based on the models still make sense.
I have a project page available here, which has a longer description and various useful links (like my actual proposal) for people who are more interested. I am also releasing all my source code as open-source, and releasing all my articles/thesis material under a creative commons license (more details at the project site). So go have a look, it will help you understand what I'm saying when I am ignoring you and talking to myself (come on, we all do it sometimes).

Friday, March 5, 2010

Bring back the Airships

Today I want to talk about a topic that is very close to my heart. Long ago in a far more civilized time, before twitter feeds and the blogosphere, yes before cellphones and even the internet, people were happy to do things slowly. And when these fine people needed to locomote their favored form of transport was the Airship.

Airships, also known as Zeppelins or Dirigibles (From the French "diriger" to direct plus -ible, meaning "directable" or steerable) once ruled the skies. These graceful giants floated across and between continents, ferrying the most important people to there most important business with a level of  luxuriating comfort unseen in modern air travel. At their height the transatlantic route between Germany and Brazil took a leisurely 68 hours, much like a weekend in a luxury hotel.

USS Los Angeles (ZR-3) flying over southern Manhattan Island, New York City

Sadly, despite the elegance of these mighty beasts, the unquenchable desire of man for speed and stress coupled with the Armageddon of the world wars led to their eventual retirement from use.

But I feel this is a tragedy. How can we have discarded the fair Dirigibles for such filthy a replacement as the jumbo jet? In light of this, and in the same spirit as the conservation of the Panda Bear, I propose to start a political party with the sole and express purpose of bringing back the Airship. It is my firm belief that this step will start us on an unstoppable road to a more civilized and sophisticated society.

Please join me, by spreading the virtues of airships, and remember: Airships! Awesome!

Thursday, February 25, 2010

Reveling in the awesomeness of technology.

Below are two maps of down town New York. The one is an antique map (in French I think), the other is a Google earth image. I think sometimes we forget how awesome technology is. I thought we needed a reminder. I'm sure you can figure out which is which.