Tag Archives: fractal

Neko Time!!! =^_^= matthen

Last week I spend some days in Cambridge performing some experiments at the university,l and as always happens when I go to Cambridge, I learn something new.

This time I came across Matt Henderson blog.


Matt has a mathematics degree by Cambridge University, and he is now working on his PhD on statistical dialogue systems.

He is an unstoppable explorer. His blog is full of experiments and nice mathematical simulations. And here I want to show you which are the ones I like the most. Who knows, maybe a collaboration between us could be possible in the future.

So, here they are.



Basically, if you have particles moving randomly and they are able to become added to a seed, then these random patterns appear. They are close related to chemical reactions and electrical transport. Nice post, with code, and a link to.. Agregation images by Andy Lomas.



Gingerbreadman is a chaotic map. Basically, you select random points in the plane and using very simple equations, you transform the points into new ones. If you repeat it enough times, a figure appears that looks like a Gingerbreadman. And I like this one because I also explore it myself. Remember this?

Iterated Function Systems.


Iterated function systems is a technique to build fractals using transformations of points. It’s similar to the Gingerbreadman map, but with a set of equations that alternate randomly. And I also explore it! Remember the 100 posts post?


Double pendulum.


This was the post that bring me to the blog. The double pendulum is an example of a quite simple chaotic system, it’s only two pendulums linked. In the image on top we can see 2 double pendulums, what the animation want to show is that quite similar initial conditions can evolve into very different evolutions. (I’m working in a nice post about this, but I’m not telling anything more now).



This is an applet to play with iterated functions systems. This one uses the geometrical approach for defining the functions used for performing the iteration. I like it, is quite good. Unfortunately, it’s difficult to repeat successfully patterns.

Create GIF animations with Mathematica.

I don’t like Mathematica, I prefer Matlab or Python, but… who knows, this could be useful.

Animated Optical Illusions.


I saw this effect long ago in a book. I like it. I never had enough time to make anything. But here you can see how it works.

Designing Galleries.


In this post what he wants to show is the importance of designing of buildings. Basically, a good design can help to build a museum where you can visit exactly once each room without crossing with other visitors. Or… if it is a mall, how to design it to make people walk several times into the same point (increasing the showing of that particular shop).

Soap film holes.

The film doesn’t belongs to the blog, but is so amazing…

Shepard scale.

I like this one, is my first sound illusion. Basically, you feel like the scale is getting higher, but it is not.

A Tautochrone (or Brachistochrone if you focus on other property) is a curve where no matter you put a ball on it, it always takes the same time to get to the botom point. I saw many times the Brachistochrone and never realize that it also has this property. I can think of quite funny experiments now for it.


f[x_] := Print[StringJoin[x, FromCharacterCode[{91, 34}],x,FromCharacterCode[{34, 93}]]];
f[“f[x_]:=Print[StringJoin[x,FromCharacterCode[{91, 34}],x,FromCharacterCode[{34, 93}]]];f”]

A quine is a piece of code which is able to print itself. I heard about it before, but it’s the first time I saw one for Mathematica.

And thats all. If you want more, visit his blog. Hope you like it!

NetLogo 01

To be prepared for a post about the Santa -Fe institute, I need to introduce you to this program.

is a program to simulate agent-based models using object-oriented programming. What that mean?

A model based on agents is a model of a system where you suppose the system formed by different entities called agents. A model of a solid made by atoms si an example where the agents are the atoms. Is that all? No. An agent-based model must include agents and rules to interact between them. And mos important, the properties of the system must arise as a collective property of the agents. For example, in the solid, the net magnetization must arise as the interaction between the spins of the individual atoms.

Ok, seems like agent oriented models is more or lees what we have been doing for a long time in some simulations. Why so much noise about this program? Because the object-oriented programming is the way of programming agent-based simulations. What do I mean with that? You can program anything with any language (there is a theorem that grants that), but depending on the task and the language used, the problem became easy or a complete hell. So using object-oriented programming is the easy way of dealing with agent-oriented models.


Go to the webpage, hit download, fill the questionnaire (if you wish you don’t need to fill it), and download and install the program.

Now that you did that, run the program for first time,k it will look something like this.

From here, you are only interested in “Interface” and “code”. Interface is where things happen and where you put buttons and sliders to control your simulation. And also, where the graphics and plots will appear. The code view is where you actually write the code for your simulation.

To start with something easy, go to File>Models Library and we are going to choose….  Chemistry and Physics>Ising.

The Ising model is a classical model for magnetism. In this case, each agent is going to behave like a magnet which can be pointing up or down (dark or bright). The agents randomly will be allowed to change their orientation if that minimises their potential energy respects it’s neighbours. And sometimes, randomly also, they will go into a bad configuration. The principal parameter on this model is temperature. Temperature determines the amount of bad random changes. And the interesting result is that below a certain temperature, the system evolves towards all the agents in the same state, while over that temperature the agents in one state equal the agents in the other state. And that is a good example about magnetic domain formation and Curie temperature.
To run the simulation, push setup-random to initialise  the variables and then go to run it.

Hmmm but this representation of the results is not funny. To make it more funny, we are going to plot the average spin versus temperature. To do it, right click on the plot and hit edit. And now we only need to remove the pen that draws the horizontal line and change ticks for temperature. So now, each time the plot updates with a new point, the new point is going to have temperature as x and average spin as y. You can also change the axis limits to fit better the new data.

logo2And now, just change the plotting-interval to maximum, hit setup-random, go…. and ramp up and down the temperature several times slowly (there is a slider on top to accelerate the simulation).


That process is the equivalent to have a magnetic material and cool it down and heat it up several times. You are going to see that sometimes, when you cool it down, you end with a magnetization different from zero, maybe 1. But above some temperature, the magnetization it’s always zero. Something like this.


That transition temperature is what we call Curie temperature.

Ok, so now with a first example.

Step 1: Help>Look up dictionary This will help you quite a lot.

Step 2: File>New.

Step 3: Create a SETUP button. Right click on a white area and add a button. On the window that appears, writet in the commands area SETUP. And hit ok.

Setp 4 Create a GO button. Rigth click on a white area and add a button. On the window that appears, writet in the commands area GO, select forever. And hit ok.

It will look something like this.


This buttons will execute the scripts located in the CODE area with the names SETUP and GO.

Setp 5 Switch to code area and write the commands to SETUP and GO

Setp 6 We write for setup these lines to create 160 turtles (turtle is the generic name for the agents).

  ;; create 160 turtles at the center pointing at diferent random angles and positions
  ;; with different colors
  create-turtles 160 
  ask turtles [
    setxy random-xcor random-ycor]    
  ;; ticks are used to measure time, how many interactions has pased

Setp 7 In each iteration step we ask turtles with same colors to move closer together.

to GO
  ask turtles [
    ;; In order, each turtle is asked to do something
    ;; In this example we pick a random turtle and compare color with the actual turtle
    let a one-of turtles      
    ;; If the color is the same, as the current one, the current one moves towards that turtle.
  if   color =  [color ] of a [face a fd 1] 

All together will look like this.
Setp 8 With all the steps sccomplished, run the simulation.

Like it? Want more? Ok, one more. I show you how is going my random forest on NetLogo. (Remember my version on OpenProcessing?)


L-Systems and Penrose P3 in Inkscape

Remember the Post about Penrose designs? Funny? (Review it, if you didn’t watch it, because it was beautiful). So, today I’m going to show you how you can do some Penrose tilings and maybe one or 2 things about L-Systems (Lindenmayer system).

What a L-System is? Well… without words, these are examples of L-Systems.


With words… really you don’t want words… See wikipedia definition of L-System and come back after “words”.

The basic concept of an L-system is drawing a figure using a rule and repeat this rule in each part of the figure again and again.

For example, we can make the Koch curve in this way describing it as an L-System instead of a Fractal line.

Using common words, the way of doing the Koch curve as a L-System is this. My first draw, my Axiom will be a horizontal line. And my rules says that in each iteartion I will divide my line into 3 lines. The two on the edges will remain, while the one in the middle I use it to make an equilateral triangle. The new lines of the triangle remains, the middle line not.


Now that it is a L-System, there is a very compact way of describing this system using grammars.

Suppose we write F for a straight line, + to a 60º turn after a straight line, and – to a 60º turn after a strigh line. Then we say that for the Koch line we have

Axiom: F  (We initiate the System drwaing a straight line).

Constants: + , – (This are the operation we can apply over our line, basically, we can rotate it for example and then the constant are reffered as angles).

Rules: F->F+F–F+F (In each iteration we susbtitute the line F for other 4 straight lines, drwaing the first one along the original, the next one after turning 60º, the third after -120º turn and the last one turning 60º and liying again over the original one).

Very funny… let’s see if we get the idea trying to reproduce the Cesaro-Koch Fractal.

This is the process to do the fractal.


So, what is the grammar?

Angle+: 85
Angle-: 85

Basically it’s the same as Koch curve changing the angles!

Ok, let’s go for something a little bit more complex (I’m not expert in L-Systems, actually I´m learning at the same time i try to explain this).

For the next example I’m going to use “The Turtle”. The turtle method consists in viasualizing a small turtle following the rule and having a pencil attached at his back (the pencil can be lifted or down).

Suppose this system:


Which has.

Angle+: 90
Angle-: 90

The turtle method consists in (thank Marylin for the picture) visualizing the rules as:



And with the Turtle I can introduce something new. It’s called [ for “push” and ] for “pop”. Basically, this new symbol in the grammar what it does is to remenber a position and to recall it. See in this example how it works.


Can you see the difference? In the bottom example C is related to B, while in the first case C is related to A becase we push [ after A and we pop it again before C. This method works as a LIFO (Last In, First Out) what it means is that if you open several [ at the same time, the first time you close one of them with ] the one which is going to be used is the last one you open.

Ok ok, what else? Well, we can now try using several rules. Using several rules is very easy, you just substitute each rule on to the others until you get everything susbtituted.

For example if you go back to the Koch curve.

Angle+: 60
Angle-: 60

You can rewrite it using three rules as this:

Angle+: 60
Angle-: 60

The reason for using 3 rules is:


Suppouse we use 2 rules as this:

Angle+: 60
Angle-: 60

Then we will have:


And you can see the structure changes, because we have to susbstitute rules over what we have and it changes depending on the rules… So it’s a little bit tricky.

I suppose now you want to try some of these things yourself. So it’s InkScape time.


Basically, InkScape it’s superpowered Paint. With some advantages. It’s free and Open Source (you can download it use it and change code as you wish). Can do vector grpahics (when changing the size of things pixels don’t get bigger, it uses vectors to set the positions of things). Can link things and write scripts (if you move things inside a graph, labels and arrows will move to fit the new disposition). Uses a standard kind of files to save your drawings (you can easily import and export files). Can open pdf files and extract parts of them (depending on the pdf you will also be able to edit the pictures and it will recognize different parts on them allowing you to edit them as they were generated by you). It’s available for Windows, Mac and Linux (If you use diferent equips, you can have the same program in all of them). And at last… has an extention to work with L-Systems.

To get this program, just go to their download section and look for the one that fits your system.

Once you have it installed, it’s very easy to generate L-Systems (a few years ago they only way of doing them was to program it yourself, so this is a great tool).

To generate a L-System, inkscape has by default an extension. Extensions>Render>L-System.


A options window will apear allowing you to play with the Axioms and Rules we have discussed before. One extra thing is that Inkscape has two kinds of variables for rules, the ones that draw something and the ones that are only used for displacement. For example, this is the setup for the Koch Island.

Angle: 60


Hmmm very funny, but get into serious business… Want to impress someone? Try the Dragon curve! (Thanks Penguin Pete for the reference).

Angle: 90


And of course some clasical trees will look very nice. If you randomize step and angle, each iteration will be a small change in the angle and in the longitude of the step. In this case, that will give a more realistic appearance to trees.

Randomize Step (%):20
Angle: 20
Randomize Angle (%):20


That remembered me an applet I did last summer as a gift. You can check my random Forest in Openprocesing (click on canvas an a new one will appear).


Until now, we have deal with systems where there is no overlap, but if you allow it and actually, if you use it, things like this can emerge (Thanks to  J C Lawrence).

Angle: 30


Ok, so now we arrive to Penrose P3. (Thanks to the people in the Cornell college for a tutorial like this but maybe more complete and readable than this one).



For more about Fractals, L-Systems and Strange Attractors, an easy introduction (this time in Spanish):


Hope you enjoy it!!


L system definition.


Koch Snowflake.


Cesàro Fractal.


Turtle picture.




Dragon Curve


Penguin Pete. Dragon Curve and several L-Systems in Inkscape.


Some L-System Examples and a Penrose Tiling.


Penrose Tilling.


Cornell College.


Randomize Angle (%):20

Penrose Design for e-beam lithography

This week I was working with a magnetic force microscopy (MFM). It’s like an Atomic Force Microscopy (AFM), but can also see the magnetic domains of a sample… I suppose I also need to explain what an AFM is… an AFM is a type of Scanning Probe Microscopy (SPM). (I know, in this job abreviations are everywhere).

An SPM It’s a microscopy that takes pictures of samples aproaching a very small needle to the surface of the sample. Because the end of the needle has only one atom, It can sense the atomic force of the sample surface.


The next video is something just amazing. It’s a SPM working inside a Scanning Electron Microscopy. So you can use the electron microscopy to see how the SPM works!

Well, I was working with one of these when I found something in the sample I have been studying. A mark in one of the corners! This is the mark. In the left side is the surface and in the right side is the magnetic domains inside the mark.


One of the most beautiful things I have ever saw. And, probably there is not too many images of that around there (and probable any with the magnetic domains). Do you realize the size of the human hair in comparison? And want to know the most amazing thing? We made it, it’s something that was there intentionally.

I wasn’t aware of it because is a part of the design used by the people in charge of fabrication of the samples. It’s called Penrose-like design for alignement or electronic beam litography. This is another example of how they will look alike.


Ok ok, very funny. Cool and whatever you want. What is a Penrose design and why they need it?

Let’s start with Penrose Tiling design.

To keep it simple, a Penrose Tiling is an aperiodic tiling of the space. Just that. It’s more complex than that, but it’s just what we need now.


And why it’s usefull here?

Well, according to wikipedia it’s main properties are:

  • It is non-periodic, which means that it lacks any translational symmetry.
  • It is self-similar, so the same patterns occur at larger and larger scales. Thus, the tiling can be obtained through “inflation” (or “deflation”) and any finite patch from the tiling occurs infinitely many times.
  • It is a quasicrystal: implemented as a physical structure a Penrose tiling will produce Bragg diffraction and its diffractogram reveals both the fivefold symmetry and the underlying long range order.

Hmm that means two things. The first one is that if we use x-rays to watch this tilings, we will see a very precise pattern that will reveal us if the tiling is really a Penrose pattern or not. And the second thing has to be with the simetry. Being aperiodic means that there is no way of move or transform the pattern an actually make it look like himself.

And why these properties are good for making chips?

It has to be with the way we do chips. The way of doing chips implies preparing a pattern with the devices we want to impress into a silicon wafer. To do that, we use a electron beam to create a picture of the devices into a substrate by removing parts of it (e-beam  lithography).

This process is very complicated and requieres extreme precision. And that is where the Penrose designs are being used. The Patterns are added to the design of the chips to allow the calibration and allignement of the e-beam system. In the video they only show one process of lithography, but what happens when you have to repeat it? You need a way of knowing where exactly where you are. And the Penrose design is there for it. If you want to read more about it, here is a Thesis from the university of Glasgow 2009 about it.


Almost forgot. If you want to play with Penrose tilings, here there are two nice programs to use:



New Origami Era. Roman Díaz.

I love Origami for the same reason I love fractals. Because simple rules emerge into a fantastic and unbelievable world of things that we couldn’t imagine before. Nothing can be more simple than a sheet of paper and folding it, and folding it, and folding it…


The Origami master I bring today is called Roman Díaz. And It’s going to make real noise into the world of Origami. I’m almost sure that you have seen at least once the next figure.


The first thing about him you must notice is that he has a blog and an active flickr account, so you can actually track his creations and see in what he is working now.
The second thing is that he actually has a book with designs and he is getting more material for a new one (I found some references, but I’m not sure if it is published yet or not).


As you have notice he is an old school Origami folder. Just paper and folding. Not wet-folding or corrugations.


But despite the simplicity of his creations, they still have something that make them like sending a message.


Here is a sketch for a Neko. =^_^=

Hope you enjoy it. Before leaving, don’t forget to check out his profile and see another wonderful creatures he has made.


25 +1 Chrome Experiments

Today I want to point you towards a initiative leaded by Google which has some time but not enough publicity. Chrome Experiments.

Basically Chrome Experiments are small applets to show up the powerfull of Chrome web-browser against other browsers. (If we talk about running animations or programs inside the browser, Chrome is the fastest, but this doesn’t it is the best of the browsers).

So, after a survey over all the experiments I bring you my list of best 25. (Click on images to go to experiment description and launch experiment from there).

25. Growing flowers. It looks beautiful but a little annoying because you can’t stop the growing plant to take a picture of it.


24. A Calamar? Seems to be alive and can be controlled with mouse. Can get very nice configurations, but they are quite difficult to achieve.


23. This is a very good one. It’s a MIDI player with animation to see what is playing. And also has a wide list of MIDI files to play around.


22. Particles dancing around and making a heart. Sorry, but I respect love above all the things, and this one is perfect for making a smile on your loved ones.


21. This is actually very good idea. weather forecasting using tweets. (Inspired by xkcd idea maybe?).



20. This one reaches the computation limit of the browser, but it’s quite nice game.


19. A whole island! The technology to show this island in the browser is incredible. Read the info! It uses a dataset with 122880 x 122880 pixels. About 56GB of info. This technology allows to handle that big amount of data and show only the needed data each time.


18. This one uses a genetic algorithm technique to generate random faces from a set of faces. Each iteration the user picks the best face of all. In this way you can actually create or “grow up” a face.

chexp00817. Cellular designs. Make cellular-like designs and print them into 3D. (I can’t run it in this computer, but I can show you how it is).

16. This one is really funny, a lathe machine. You just pick material and start working with it. (I wonder if there is a game with different kinds of machines that actually simulates a workshop).


15. This one is very very good, but it doesn’t have good examples inside to test it. What it makes is, it takes a GIF (a colection of frames that show an animation) and plot’s them using z coordinate as time. Doing that allows us to actually see the whole evolution of the GIF. If the GIF represent a series of slides of an object, then this experiments allows us to actually reconstruct the object. As long as the examples provided are quite bad, I made this GIF.


Use it inside the experiment to get figures as this one.


I promise to create an amazing GIF for this one as soon as possible. Keep that in mind.

14. ChuClone. Another game. Quite nice, and remember that it is running inside your browser which is a real big challenge.

13. This one uses Turing Reaction-diffusion equations to create patterns in a fluid simulation. Remember that this equations are actually used to describe systems like the cheetah skin patterns or the propagation of spikes in the neural system.


Two years ago, I studied the Fitzhugh-Nagumo system for Neural Activity. Here are my videos… I think that now I should improve it. :/

Here a link to an applet for recreating the same experiment I did.

12. Recursion toy is another L-System. They are quite easy to build with object oriented programming, so that’s why there is so many of them, but even whith many of them around, not all are interesting at all. This one is cool because the number of parameters you can adjust. Check it out.


In this case I also have one myself, but you can’t adjust anything, sorry.


11. This one is just artistic, don’t allow any interaction, but it’s ambientation it’s great.


10. The next experiment creates networks of artists using last.fm API. I use to look for Freddie Mercury, and the result looks good. Maybe some connections should be stronger/weaker than the graph shows, but it is ok.


9. Another experiment about music. this time, you can draw a sound. It’s not big deal, but it’s an interesting idea.


8. Not sure what is this, but has very nice effects and also they interact into each other.


7. A multiuser sketchboard. Unfortunately It was disconnected when I tried to log, but you can see at the blog different creations made at the sketch.

6. This is one of the most beautiful games (and addictive) I have played. The objetive is to build the longest path. Try to complete the board, and then try to beat yourself. Also it’s one of the most refined experiments because it has no bugs.


5. The next one needs a good computer to run properly, but it’s amazing, and will make you stare at it for a long time. This kind of art is bringin new perspectives and I’m completely sure that in the next years we are going to see a really big revolution in the art and how we interact with it. It’s going to be more like a game or like a living and changin being than a static thing to look at.


4. I think that this bomb gaming experiment was very popular, so probably you already know about it, but just in case, I put it here.


3. We had drawing music and collaborative painting. Why not both at the same time? Plink. (not sure if it is still working).

2. It’s more difficult than you think, that’s all that I have to say. You have to create a chain reaction to destroy all the balls before your explosions fade away.


1. As I told you,  love is number one for me. This experiment will track the tweets in the selected country generating a Love/Hate tree. This is what i get.



0. 100,000 Stars. A visualization of the solar system neighbourhood. Enjoy all of them and keep searching for beauty and new experiences!