Fractals with R

by Allan Roberts

Many biological objects have structure that, at least at a glance, may appear rather fractal-like. A brief discussion of the applicability of fractals and fractal dimension to biology can be found in Vogel’s ‘Comparative Biomechanics‘ (2003, pp. 84–86). While noting that there seem to be few truly fractal objects in biology, Vogel speculates, “I think, […], that sponges may be fractal, with large ones organized mainly as foldings and refoldings of proliferated small ones, thereby making transitions between the organizational grades we learned as ascons, sycons, and leucons” (p. 86).

Sierpinski triangles

Figure 1. Four iterations in the construction of a Sierpinski triangle-like object. I produced these graphics using the statistical programming language R (R Development Core Team, 2011).

I’ve included an image, representing the construction of a fractal largely similar to a famous fractal, the Sierpiński triangle. A mathematical description of the Sierpiński triangle can be found in Vejnar (2012). (In contrast to the actual Sierpiński triangle, my example is based on right-angled triangles, rather than on equilateral ones.) These images were produced using the statistics application and programming language R (R Development Core Team, 2011). I’ve also included the R script that I used to produce the graphics. For more, see Fractals with R, Part 2.

R Script
IterateTriangle <- function(A){
    B <- cbind(A,0*A);
    C <- cbind(A,A);
    D <- rbind(B,C);
return(D);
}

par(mfrow=c(2,2))
for (i in 1:4){
    T <- matrix(1,1,1)
    for (i in 1:i) T <- IterateTriangle(T);
    image(T,col=c("white","black"),axes=FALSE);
    text(0,1,i,col="black") 
}

References

R Development Core Team, 2011. R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria.

Vejnar, Benjamin. 2012. A topological characterization of the Sierpiński triangle.       Topology and its Applications, 159 (5), 1404-1408.

Vogel, Steven. 2003. Comparative Biomechanics: Life’s Physical World. Princeton University Press: Princeton, New Jersey.

Advertisements

2 thoughts on “Fractals with R

  1. Pingback: Fractal Graphics with R: Part 2 | BMSC Student Blog

  2. Pingback: Fractals with R, Part 3: The Hilbert Curve | The Madreporite

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s