Note to the instructor
This is an “exploratory math” outreach activity, specifically aimed at dispelling the thrall of math phobia. There are two parts to that phobia - thinking that math is impossible to learn and that it is dull. Everybody agrees mathematics is useful, but less commonly appreciated, mathematics is something you can learn like anything else (nobody is “just bad at math”, but it seems a lot of people have wrongly internalized that rote memorization is all there is to math[1]). Moreover, something people miss when talking to kids is that mathematics is something that can be pretty. Here we use the prettiness to trick kids into playing with math. We avoid the “scary” algebra by using purely numerical work and a lot of guided exploration. To facilitate the exploration, we use a programming language as a calculating and plotting tool.
The final goal is to have the students be able to plot and explore natural fractals on their own. We will start by presenting a simple language for calculations and plotting (the Julia programming language). We learn the basics of manipulating lists of numbers, repeating operations until a condition is met, and plotting lines with given coordinates through the first hour or so. We introduce the notion of dynamical laws (using the example of population growth and avoiding any mathematical jargon) in the first half of the second hour. We introduce Mandelbrot’s “dynamical law” and then we let the students explore its convergence properties (by giving them the code to do that) for another half an hour. In the third hour we explain and rebuild that code from scratch.
From the very beginning be very clear with the students that this activity is exploring a very particular mathematical object that happens to be beautiful - we are not teaching general mathematical or computer science techniques and what we show them will _not_ be directly useful in class, _nor_ will it be particularly related to any mathematical techniques employed in computer generated art in general. We are exploring one pretty object in and endless see of mathematical beauty.
Directions to how to approach the students is left in similar panels.
[1] See “A Mathematician's Lament” by Paul Lockhart, freely available on the Internet.
The activity is designed at Yale for SWE's Engineering Day.
Today's project will require a lot of exploratory "numerical" math. In school, you are frequently presented a neatly packaged piece of math, without much discussion of where it comes from. In reality, before a useful mathematical object receives a nice pedagogical description in your text book, it takes a few decades (or centuries) for mathematicians to wrap their heads around it. During this time, an "exploratory" approach that simply "plays" with different properties of the object is very helpful and it results in quite a bit of unearthed beauty. We will try to explore the beauty of one particularly wondrous object today: a fractal, namely the "Mandelbrot Set".
However, given that the work will be both numerical and visual, we will go through an introductory "scientific programming" and "scientific visualizations" toolbox.
We will use this "notebook" interface for most of the work. This "notebook" interface is used by many scientist and engineers for numerical work (simulations, data analysis, etc) and documentation (like the text in this paragraph). The notebook is divided in "cells". By default the cells can be filled with computer code to be executed, or they can be changed to "markdown" cells, like this one, which are filled with text and description of the calculations.
Note: To enter a cell for editing just select it and press "enter". To evaluate a cell (or render the text you wrote in it) press "shift+enter" while in the cell. To add a new cell, above or below a currently selected cell, press "esc" to exit the current cell and then press "a" or "b" to add a new cell.
Below we have a "code" cell, which can be used to evaluate programming code expressions. The last line of the cell is also printed back to you with its result.
The programming language which we will use here is called "Julia" and it is particularly good at "scientific" programming that does a lot of numerical algebra.
First, let us show how this can be used like a calculator.
1+2
3
pi
π = 3.1415926535897...
You can use it to evaluate functions as well (entities that take one or more numbers and spill out another number).
abs(-5.65)
5.65
2^3
8
We can save expression results into variables for later use.
whatever_name_I_want_for_my_variable = 5
whatever_name_I_want_for_my_variable + 2
7
a_shorter_name = whatever_name_I_want_for_my_variable - 3
a_shorter_name
2
And if we want to evaluate the same expression many times, we can create a "function", that does something to the variables and returns the result.
function my_very_important_expression(my_first_parameter, my_second_parameter)
my_intermediary_result = my_first_parameter - my_second_parameter
return 2*my_intermediary_result
end
my_very_important_expression (generic function with 1 method)
my_very_important_expression(10,4)
12
In real code you probably will want shorter, easier to write names.
We will use a "plotting" library for our visualizations and we will introduce common ways to represent the information to be visualized on a computer.
using Plots