## Fractals

### Mathematics in Nature

200 pixels
100 pixels
50 pixels
25 pixels
12.5 pixels
6.25 pixels
too small to draw!

## Info for Grown Ups

Math is all around us in nature, and this lesson presents some new and unexpected places where we can find it. But we're just scratching the surface. Let's help our young students continue the discussion from here!

Where else might math and nature cross paths? Look for places or objects where different geometries are revealed. Compare the usual Euclidean geometries in structures such as squares & cubes, circles & speheres, etc. against the more fractal based geometries we often find in nature.

We talked about a fractal tree, but what are some other examples of fractals in nature? Remember to look for the telltale properties of self-similarity – objects where the details look just like reduced copies of their bigger selves.

How about the patterns in a leaf? They almost look like a tree too! Coincidence? hmmm. Seashells, broccoli, water bubbles, pine cones — yikes, patterns are everywhere! Many things in nature reveal their fractal origins when you look more closely.

Aside from the fractal discussion, we learned a few other big words in this lesson. What's a function again? Oh yeah, it's just a recipe, and it's how computer programmers input their specific sets of instructions. Computer scientists try to define problems algorithmically. With an algorithm – or clear set of instructions – defined, a programmer can quickly code up a function in their computer.

How about recursion? That's the repeated use of the same instructions, called from within the instructions themselves! This can be a VERY confusing topic to understand for beginning computer science students, but it's what allowed us to build the tree by making the same branch instructions again and again. Pictures can help visualize recursion better than words alone.

What's the difference between a deterministic and a stochastic function? Remember that deterministic functions always give the same results each time you provide the same information. Stochastic functions will use some randomness and probability to provide different (predictive) answers given the same input information. When allowed to randomize like this, the results are often similar to what we might see in nature.

Finally, here's the most important takeaway for young learners. Math is for everyone, and is used in both science and art in all sorts of ways! How might an artist, designer, doctor, engineer, or scientist use this type of fractal math? A computer game designer might use fractals to draw a moonscape for a new planet. An interior designer might use fractal math to create a cool new wallpaper design. A biologist might use fractals to predict the growth of a new type of plant. A doctor might use it to model the paths of blood vessels. With a little curiosity about math, all of these folks can add great new tools to their creative kit.

The following links provide some more great information related to our lesson:

## About "Fractals" on STEAM Cooker

This interactive lesson was created using several different pieces of video and web software.

The video was filmed in front of a green screen, which allows the use of a trick called 'chroma key compositing' to subtract the green background and replace it with other images or videos.

In this lesson, the compositing is being done directly in the web browser in real time using the chromakey tools in Seriously.js. It's JavaScript software that allows for really cool video experiments on the web.

From there, the chromakeyed video is being composited (blended) together with code running behind it in an HTML5 <canvas> element. The interactive snowflakes and trees were created in the canvas using the wonderful P5.JS library.

The P5 team also created a wonderful demo called hello.p5js.org, which served as inspiration and guidance for creatively combining video and code together in the web browser.

Timing the video with the code animations required yet another JavaScript tool called Popcorn.JS This software allows timing cues in the video to trigger other stuff to happen in the web browser at the same time.

The material and examples in this lesson were inspired by the book The Nature of Code, by Daniel Shiffman.

Dan's a professor at the Interactive Technology Program (ITP) at NYU/Tisch. His enthusiastic and creative approach to writing, coding, and teaching is contagious. His countless online code snippets and video tutorials provided an entertaining and enlightening example from which to learn and follow.

Thanks, Dan!