Exploring patterns of nature through mathematics and programming
06/03/26
Exploring patterns of nature through mathematics and programming
Author: Sanja Pavlović Šijanović, Leading Teacher, Croatia and Davor Šijanović, Gymnasium Vukovar, Croatia
As part of the activities marking EU Code Week, students of the Vukovar Gymnasium explored the fascinating world of fractals – mathematical shapes that repeat at different scales and can often be observed in nature. The aim of the activity was to connect mathematics, nature, and programming, and to demonstrate how complex natural patterns can be described through simple rules and algorithms.
The activity began with the study of fractal shapes in nature. Students analyzed examples such as the branching of trees, the structure of broccoli, river networks, and seashells. They noticed that the same patterns repeat at different levels, from large structures down to very small details. Through this process, they realized that such patterns are not random and can therefore be described using mathematical rules.

Students further explored these ideas using interactive digital simulations. By using the Visnos Interactive Fractal Tree tool, they experimented with parameters such as branching angle, branch length, and the number of iterations. Observing how small changes in these rules create completely different shapes, they saw how simple mathematical relationships can generate structures resembling tree crowns or fern leaves.

Next, using the Sierpinski Carpet generator, students investigated the process in which smaller parts are removed from a square, and the same procedure is repeated on the remaining sections. By observing the emergence of a complex structure through a sequence of simple steps, they understood the fundamental idea of fractals – that complexity arises from the repetition of simple rules.
Students then applied their newly acquired knowledge and experience with interactive tools to programming. Using the Python programming language and the Turtle module, they designed their own codes to generate fractal shapes. By writing programmes, they were able to observe how mathematical rules transform into visual structures, where each new line of code influences the shape that appears on the screen.
They successfully generated several classic fractal models. A fractal tree was created using recursive branches that imitate the natural branching of plants, where each branch splits into two smaller ones at a certain angle, forming a structure that realistically resembles the growth of a real tree. The Koch snowflake begins with a simple triangle, and by adding new segments to each side gradually transforms into a complex and detailed pattern similar to a snowflake. Students also experimented with geometric star-shaped fractals, where stars repeat and build upon one another, creating complex and symmetrical structures on a dark background. Particularly interesting were the abstract shapes created through combinations of rotations, colours, and circular repetitions. These student projects demonstrated that programming can also serve as a form of creative expression.

By observing natural patterns and creating their own models, students concluded that fractals represent a kind of “fingerprint of nature,” present in plants, landscapes, and many other structures around us. At the same time, they realised that mathematics and programming are not merely abstract concepts, but dynamic systems that help us understand and decode the world around us while revealing the strong connection between science, art, and modern technology.


