Sunday, June 12, 2011

Very simple formula for fractal patterns

I found an intriguing post on the web with a very simple formula to create fractals that I would like to share with you. The text and pictures are quotes from http://www.fractalforums.com/new-theories-and-research/very-simple-formula-for-fractal-patterns/

The formula is:
x=abs(x)
y=abs(y)
m=x*x+y*y
x=x/m+cx
y=y/m+cy


In "Mandelbrot" mode (cx and cy equal to the point coordinates), this is the result:

A close up of the border:
 The outside looks interesting, but insides looks like random noise, wich with lower iterations turned to be just curved lines with irregular spacing. So this noise is caused by aliasing.

The good stuff comes when picking some "julia" values (cx and cy being a constant value for all points)

This is cx=-0.5, cy=-0.5 :





cx=-0.2, cy=-0.1 : 





Let's do a zoom on the last one, because I think I've seen this "entangled trees" before..


More examples, always just changing cx and cy only, and choosing some colors:










Amazing isn't it? Happy coding :)

Tuesday, May 17, 2011

Self reference

Self reference is something very peculiar. A sentence that refers to itself, says something about itself in a same way we humans are able to talk about ourself. In coding self reference is called recursion. Recursion is a function that calls itself and can create beautiful structures


A nice sketch that will hopefully get you interested in recursion is available on form and code

Recursion
If you don't get it, see "Recursion".

Monday, May 16, 2011

Column about chaos and control

A short column I wrote that will hopefully get you interested into chaos theory called "The infinite history of everyday things"

As humans we are always longing to be in control. In order to stay in control we have developed an impressive amount of controlling devices. Weather stations to give us a sneak preview into future weather. Social networks on the internet and mobile phones to keep connected to friends, even if they are on the other side of the earth. And of course television and radio to get constant updates from important events happing in the world. We surround ourselves with all these media to give us the feeling that we are control. What sometimes can be hard to realize is that most events in natural systems have an infinite amount of precise parameters to let them be able to occur. The infinite amount of parameters makes us have to accept that even how hard we try, we are unable to predict certain things. We call this inability to predict because of the nature of the system, chaos.

What I find particularly interesting about chaos theory is that we as humans regard ourselves as intelligent creatures, because we are able to predict and rely that certain things will happen, while in fact we are unable to fully do so. If you want to know all the actions necessary to happen before you perceive everyday things in life, you’ll be overwhelmed and undoubtedly unable to retrieve all information. Every action in time is linked to each other. If action A happens on the other side of the world, this could set a chain reaction letting you get run over by a car 2 years later. It also means that is gives you the possibility to think about how your life would have evolved differently if you decided not to quit your supermarket job or started doing aerobics dancing classes.

Generally speaking most humans don’t like the feeling of not being in total control. I, unlike those humans, find a feeling of comfort in chaos. I like not being in control, unknowing of what will happen next and where I stand in 2 years. This is what for me makes life special, the ability for extraordinary things to happen. Meeting a random stranger in the train, and maybe this person changes your life in a way you never could have imagined. So instead of trying to be in control, accept uncertainty and enjoy life were chaos may take you.

Evolution theory and computational practice

Evolution is the process of change in all forms of life over generations. The biodiversity of life evolves by mutations, genetic drift and natural selection. In Evolutionary Algorithms(EA) you can find mechanisms inspired by biological evolution, such as reproduction, mutation, recombination, and selection. An organism that adapted the best to their environment have a advantage over the other 'competing' organisms in surviving. For a EA to work such a mechanism needs to be programmed. This is called the fitness function. A nice project that uses a EV for generating a bio diverse model of the world is done by Daniel Shiffman > Evolution EcoSystem

Or check out this cool project called BoxCar2D



A nice movie made by Karl Sims showing his evolutionary algorithm that created creatures that were able to move on land and sea surfaces. 

Chaos theory and fractals

"Chaos occurs when a system is very sensitive to initial conditions. Initial conditions are the values of measurements at a given starting time. Chaotic systems, in this case a fractal, can appear to be smooth and ordered. Fractals are geometric shapes that are very complex and infinitely detailed. You can zoom in on a section and it will have just as much detail as the whole fractal. Fractals are related to chaos because they are complex systems that have definite properties"



Remember the first time you saw fractals? I sure do. It's happened when I got connection to the internet as a kid. I downloaded Winamp 1.6x and in some way I found out that there was a visualization studio. I was completely blown away by the zooming into infinity. At that time I did not have the knowledge to understand how it works, but it sure was pretty. Later this inspired me to start programming, I wanted to understand how these cool visualizations worked.

Video showing zooming in on a Mandelbrot:

For inspiration on how to write your own fractal code visit Processing code for fractal tree

Further reading on: Chaos and Fractal

Why code is art

You can have endless debates about what art is, or what isn't. To prevent this debate you have to deal with my personal opinion that art is something esthetically pleasing. Art should excite and intrigue the viewer and I've been intrigued by technology all my life. The discovery on how to control fire increased the availability of food sources. The wheel increased the distance or load we can carry. Recent communication developments made it more easy to be in contact with someone on the other side of the world, than to talk to your neighbor. If it wasn't for technology, there wouldn't be a difference between humans and Bonobos.
Now try to envision a world were all technological artifacts are pure practical and optimal economic constructed without any attention for design. That world will most likely be a grey dull variant of what we have today. So if technology is not just pure technology, it´s also art!* Coding is generally seen as problem solving, in a same way technology is usually defined. For me technology can be something that's completely useless in a problem solving matter, but is esthetically pleasing. Some very basic lines of code or programming rules can create beautiful emergent structures. Conway showed this in a very nice way with his game of life:

Mathematical ideas about fractals have been around since the 17th century, but it took till the computer era before it could reach a larger audience:

Coding can produce beautiful results and new ways of understanding popular scientific topics such as evolution, self-reference, chaos, emergence, etcetera etcetera.

*according to my personal definition of art.