## Creating Fractals III: Making Your Own

Last week, we laid down some of the mathematical foundation needed to generate fractal images.  In this third and final post about creating fractals, we’ll discuss in some detail Python code you can adapt to making your own designs.  Follow along in this Sage notebook.

In order to produce fractal images iteratively, we need a function which returns the highest power of 2 within a positive integer (as discussed last week).  It is not difficult to write a recursive routine to do this, as is seen in the notebook.  This is really all we need to get started.  The rest involves creating the graphics.  I usually use PostScript for my images, like the one below discovered by Matthieu Pluntz.  There isn’t time to go into that level of detail here, though.

As far as the graphics are concerned, it would be nice to have an easily described color palette.  You might look here to find a wide range of predefined colors, which are available once we execute the “import mathplotlib” command (see Line 20).  These names are used in the “colors” variable.  Since each motif has four segments, I’ll color each one differently (though you may choose a different color scheme if you want to).

The loop is fairly straightforward.  On each iteration, first find the correct angle to turn using the highestpowerof2 function.  Then the segment to add on to the end of the path is

$({\rm len}\cdot\cos(\theta), {\rm len}\cdot\sin(\theta)),$

which represents converting from polar to rectangular coordinates.  This is standard fare in a typical high school precalculus course.  Note the color of the segment is determined by i % 4, since 0 is the index of the first element of any list in Python.

All there is left to do is output to the screen.  We’re done!  You can try it yourself.  But note that the way I defined the function, you have to make the second argument negative (compare the image in the notebook with last week’s post).  Be patient:  some of these images may take a few moments to generate.  It would definitely help the speed issue if you downloaded Sage on your own computer.

To create the image shown above, you need to use angles of 90 and -210 (I took the liberty of rotating mine 15 degrees to make it look more symmetrical).  To create the image below, angles of 90 and -250 are used.  However, 26,624 steps are needed to create the entire image!  It is not practical to create an image this complex in the online Sage environment.

How do you know what angles to use?  This is still an open question — there is no complete answer that I am aware of.  After my first post on October 4, Matthieu Pluntz commented that he found a way to create an infinite variety of fractal images which “close up.”  I asked him how he discovered these, and he responded that he used a recursive algorithm.  It would take an entire post just to discuss the mathematics of this in detail — so for now, we’ll limit our discussion to how to use this algorithm.  I’ve encoded it in the function “checkangles.”

To use this function, see the examples in the Sage notebook.  Be careful to enter angles as negative when appropriate!  Also, you need to enter a maximum depth to search, since perhaps the angles do not result in an image which “closes up,” such as with 11 and -169.  But here’s the difficult part mathematically — just because our algorithm doesn’t find where 11 and -169 closes up does not mean that the fractal doesn’t close.  And further, just because our algorithm produced a positive result does not mean the algorithm must close.  Sure, we’ve found something that produces many results with interesting images — which suggests we’re on the right track.  But corroboration by a computer program is not a proof.

At the end of the notebook, I wrote a simple loop illustrating how you can look for many possibilities to try at once.  The general rule of thumb is that the more levels required in the algorithm to produce a pair of angles (which is output to the screen), the more segments needed to draw it.  I just looked for an example which only required 5 levels, and it was fairly easy to produce.

So where do we go from here?  Personally, I’ve found this investigation fascinating — and all beginning from a question by a student who is interested in learning more about fractals.  I’ve tried to give you an idea of how mathematics is done in the “real world” — there is a lot of exploration involved.  Proofs will come later, but it is helpful to look at lots of examples first to figure out what to prove.  When I find out something significant, I’ll post about it.

And I will admit a recent encounter with the bane of a programmer’s existence — the dreaded sign error.  Yes, I had a minus sign where I should have had a plus sign.  This resulted in my looking at lots of images which did not close up (instead of closing up, as originally intended).  Some wonderful images resulted, though, like the one below with angles of 11 and -169.  Note that since the figure does not close up (as far as I know), I needed to stop the iteration when I found a sufficiently pleasing result.

If I hadn’t made this mistake, I might have never looked at this pair of angles, and never created this image.  So in my mind, this wasn’t really a “mistake,” but rather a temporary diversion along an equally interesting path.

I’ve been posting images regularly to my Twitter feed, @cre8math.  I haven’t even touched on the aesthetic qualities of these images — but suffice it to say that it has been a wonderful challenge to create interesting textures and color effects for a particular pair of angles.  Frankly, I am still amazed that such a simple algorithm — changing the two angle parameters used to create the Koch snowflake — produces such a wide range of intriguing mathematical and artistic objects.  You can be sure that I’m not finished exploring this amazing fractal world quite yet….

## Creating Fractals II: Recursion vs. Iteration

There was such a positive response to last week’s post, I thought I’d write more about creating fractal images.  In the spirit of this blog, what follows is a mathematical “stream of consciousness” — that is, my thoughts as they occurred to me and I pursued them.  Or at least a close approximation — thoughts tend to jump very nonlinearly, and I do want the reader to be able to follow along….

Let’s begin at the beginning, with one of my first experiments.  Here, the counterclockwise turns are 80 degrees, and the clockwise turns are 140 degrees.

One observation I had made in watching PostScript generate such images was that there was “overlap”:  the recursive algorithm kept going even if the image was completely generated.  Now the number of segments drawn by the recursive algorithm is a power of 4, since each segment is replaced by 4 others in the recursive process.  So if the number of segments needed to complete a figure is not a power of 4, the image generation has to be stopped in the middle of a recursive call.

This reminded me of something I had investigated years ago — the Tower of Hanoi problem.  This is a well-known example of a problem which can be solved recursively, but there is also an iterative solution.  So I was confident there had to be an iterative way to generate these fractal images as well.

I needed to know — at any step along the iteration — whether to turn counterclockwise or clockwise.  If I could figure this out, the rest would be easy.  So I wrote a snippet of code which implemented the recursive routine, and output a 0 if there was a counterclockwise turn, and a 1 if there was a clockwise turn.  For 2 levels of recursion, this sequence is

0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0.

The ones occur in positions 2, 6, 8, 10, and 14.

I actually looked at 1024 steps in the iteration, and noticed that the ones occur in exactly those positions whose largest power of 2 is odd.  Each of 2, 6, 10, and 14 has one power of 2, and 8 has three.

You might be wondering, “How did you notice that?”  Well, the iterative solution of the Tower of Hanoi does involve looking at the powers of 2 within numbers, so past experience suggested looking along those lines.  This is a nice example of how learning neat math can enlarge your mathematical “toolbox.”  You never know when something might come in handy….

There was other interesting behavior as well — but it’s simpler if you just watch the video to see what’s happening.

First, you probably noticed that each of the 18 star arms takes 32 steps to create.  And that some of the star arms — eight of them — were traversed twice.  This means that 18 + 8 = 26 arms were drawn before the figure was complete, for a total of 832 steps.  Note that the recursive algorithm would need 1024 steps to make sure that all 832 steps were traversed — but that means an overlap of 192 steps.

Now let’s see why some of the arms were traversed twice.  The 32nd step of the first arm is produced after 31 turns, and so the 32nd turn dictates what happens here.  Now the highest power of 2 in 32 is 5, which is odd – so a clockwise turn of 140 degrees is made.  You can see by looking at the first 33 steps that this is exactly what happens.  The 32nd step takes you back to the center, and then a 140 degree clockwise turn is made.

Now after the next arm is drawn, the turn is determined by the 64th angle.  But 6 is the highest power of two here, and so an 80 degree counterclockwise turn is made — but this takes you over the same arm again!

Note that we can’t keep traversing the same arm over and over.  If we add 32 to a number whose highest power of 2 is 6:

$2^6m+2^5=2^5(2m+1),$

we get a number whose highest power of 2 is 5 again (since 2m + 1 must be odd).  Since this power is odd, a clockwise turn will be made.

So when do we repeat an arm?  This will happen when we have a counterclockwise turn of 80 degrees, which will happen when the highest power of 2 is even (since an odd power takes you clockwise) — when looking at every 32nd turn, that is.  So, we need to look at turns

32, 64, 96, 128, 160, 192, 224, etc.

But observe that this is just

32 x (1, 2, 3, 4, 5, 6, 7, etc.).

Since 32 is an odd power of two, the even powers of two must occur when there is an odd power of 2 in 1, 2, 3, 4, 5, 6, 7, etc.  In other words, in positions 2, 6, 8, 10, 14, etc.

To summarize this behavior, we can state the following simple rule:  arms move seven points counterclockwise around the circle, except in the case of the 2nd, 6th, 8th, 10th, 14th, etc., arms, which repeat before moving seven points around.  Might be worth taking a minute to watch the video again….

We can use this rule to recreate the order in which the star arms are traversed.  Start with 1.  The next arm is 1 + 7 = 8.  But 8 is the 2nd arm, so it is repeated — and so 8 is also the third arm.  The fourth arm is 8 + 7 = 15, and the fifth is seven positions past 15, which is 4.  Mathematically, we say 15 + 7 = 4 modulo 18, meaning we add 15 and 7, and then take the remainder upon dividing by 18.  This is know as modular arithmetic, and is one of the first things you learn when studying a branch of mathematics called number theory.

The sixth arm is 4 + 7 = 11, which is repeated as the seventh arm.  You can go on from here….

There are still some questions which remain.  Why 32 steps to complete an arm?  Why skip every seventh arm?  Why are the arms 20 degrees apart?  These questions remain to be investigated more thoroughly.  But I can’t stress what we’re doing strongly enough — using the computer to make observations which can be stated mathematically very precisely, and then looking at a well-defined algorithm to (hopefully!) prove that our observations are accurate.  More and more — with the advent of technology — mathematics is becoming an experimental science.

I’ll leave you with one more video, which shows PostScript creating a fractal image.  But laying a mathematical foundation was important — so next week, we can look at how you can make your own fractals in Python using an iterative procedure.  This way, you can explore this fascinating world all on your own….

There are 10 levels of recursion here, and so 1,048,576 segments to draw.  To see the final image, visit my Twitter feed for October 9.  Enjoy!

## Creating Fractals

Recently, I’ve been working with a psychology student interested in how our brains perceive fractal images in nature (trees, clouds, landscapes, etc.). I dug up some old PostScript programs which reproduced images from The Algorithmic Beauty of Plants, which describes L-systems and how they are used to model images of plants. (Don’t worry if you don’t have the book or aren’t familiar with L-systems — I’ll tell you everything you need to know.)

To make matters concrete, I changed a few parameters in my program to produce part of a Koch snowflake.

The classical way of creating a Koch snowflake is to begin with the four-segment path at the top, and then replace each of the four segments with a smaller copy of this path. Now replace each of the segments with an even smaller copy, and recurse until the copies are so small, no new detail is added.

Algorithmically, we might represent this as

F  +60  F  -120  F  +60  F,

where “F” represents moving forward, and the numbers represent how much we turn left or right (with the usual convention that positive angles move counter-clockwise). If you start off moving to the right from the red dot, you should be able to follow these instructions and see how the initial iteration is produced.

The recursion comes in as follows: now replace each occurrence of F with a copy of these instructions, yielding

F  +60  F  -120  F  +60  F  +60

F  +60  F  -120  F  +60  F  -120

F  +60  F  -120  F  +60  F  +60

F  +60  F  -120  F  +60  F

If you look carefully, you’ll see four copies of the initial algorithm separated by turning instructions. If F now represents moving forward by 1/3 of the original segment length, when you execute these instructions, you’ll get the second image from the top. Try it! Recursing again gives the third image, and one more level of recursion results in the last image.

Thomas thought this pretty interesting, and proceed to ask what would happen if we changed the angles. This wasn’t hard to do, naturally, since the program was already written. He suggested a steeper climb of about 80 degrees, so I changed the angles to +80 and -140.

Surprise! You’ll easily recognize the first two iterations above, but after five iterations, the image closes up on itself and creates an elegant star-shaped pattern.

I was so intrigued by stumbling upon this symmetry, I decided to explore further over the upcoming weekend. My next experiment was to try +80 and -150.

The results weren’t as symmetrical, but after six levels of recursion, an interesting figure with bilateral symmetry emerged. You can see how close the end point is to the starting point — curious. The figure is oriented so that the starting points (red dots) line up, and the first step is directly to the right.

Another question Thomas posed was what would happen if the lengths of the segments weren’t all the same. This was a natural next step, and so I created an image using angles of +72 and -152 (staying relatively close to what I’d tried before), and using 1 and 0.618 for side lengths, since the pentagonal motifs suggested the golden ratio. Seven iterations produced the following remarkable image.

I did rotate this for aesthetic reasons (-24.7 degrees, to be precise). There is just so much to look at — and all produced by changing a few parameters in a straightforward recursive routine.

My purpose in writing about these “fractal” images this week is to illustrate the creative process in doing mathematicsThis just happened a few days ago (as I am writing this), and so the process is quite fresh in my mind — a question by a student, some explorations, further experimentation, small steps taken one at a time until something truly wonderful emerges.  The purist will note that the star-shaped images are not truly fractals, but since they’re created with an algortihm designed to produce a fractal (the Koch snowflake), I’m taking a liberty here….

This is just a beginning! Why do some parameters result in symmetry? How can you tell? When there is bilateral symmetry, what is the “tilt” angle? Where did the -24.7 come from? Each new image raises new questions — and not always easy to answer.

Two weeks ago, this algorithm was collecting digital dust in a subdirectory on my hard drive. A simple question resurrected it — and resulted in a living, breathing mathematical exploration into an intensely intriguing fractal world. This is how mathematics happens.

## The Problem with Calculus Textbooks

Simply put, most calculus textbooks are written in the wrong order.

Unfortunately, this includes the most popular textbooks used in colleges and universities today.

This problem has a long history, and will not be quickly solved for a variety of reasons. I think the solution lies ultimately with high quality, open source e-modules (that is, stand-alone tutorials on all calculus-related topics), but that discussion is for another time. Today, I want to address a more pressing issue: since many of us (including myself) must teach from such textbooks — now, long before the publishing revolution — how might we provide students a more engaging, productive calculus experience?

To be specific, I’ll describe some strategies I’ve used in calculus over the past several years. Once you get the idea, you’ll be able to look through your syllabus and find ways to make similar adaptations. There are so many different versions of calculus taught, there is no “one size fits all” solution. So here goes.

1. I now teach differentiation before limits. The reason is that very little intuition about limits is needed to differentiate quadratics, for example — but the idea of limits is naturally introduced in terms of slopes of secant lines. Once students have the general idea, I give them a list of the usual functions to differentiate. Now they generate the limits we need to study — completely opposite of introducing various limits out of context that “they will need later.”

Students routinely ask, “When am I ever going to use this?” At one time, I dismissed the question as irrelevant — surely students should know that the learning process is not one of immediate gratification. But when I really understood what they were asking — “How do I make sense of what you’re telling me when I have nothing to relate it to except the promise of some unknown future problem?” — I started to rethink how I presented concepts in calculus.

I also didn’t want to write my own calculus textbook from scratch — so I looked for ways to use the resources I already had. Simply doing the introductory section on differentiation before the chapter on limits takes no additional time in the classroom, and not much preparation on the part of the teacher. This point is crucial for the typical teacher — time is precious. What I’m advocating is just a reshuffling of the topics we (have to) teach anyway.

2. I no longer teach the chapter on techniques of integration as a “chapter.” In the typical textbook, nothing in this chapter is sufficiently motivated. So here’s what I do.

I teach the section on integration by parts when I discuss volumes. Finding volumes using cylindrical shells naturally gives rise to using integration by parts, so why wait? Incidentally, I also bring center of mass and Pappus’ theorem into play, as they also fit naturally here. The one-variable formulation of the center of mass gives rise to squares of functions, so I introduce integrating powers of trigonometric functions here. (Though I omit topics such as using integration by parts to integrate unfriendly powers of tangent and secant — I do not feel this is necessary given any mathematician I know would jump to Mathematica or similar software to evaluate such integrals.)

I teach trigonometric substitution (hyperbolic as well — that for another blog post) when I cover arc length and surface area — again, since integrals involving square roots arise naturally here.

Partial fractions can either be introduced when covering telescoping series, or when solving the logistic equation. (A colleague recommended doing series in the middle of the course rather then the end (where it would have naturally have fallen given the order of chapters in our text), since she found that students’ minds were fresher then — so I introduced partial fractions when doing telescoping series. I found this rearrangement to be a good suggestion, by the way. Thanks, Cornelia!)

3. I no longer begin Taylor series by introducing sequences and series in the conventional way. First, I motivate the idea by considering limits like

$\displaystyle\lim_{x\to0}\dfrac{\sin x-x}{x^3}=-\dfrac16.$

This essentially means that near 0, we can approximate $\sin(x)$ by the cubic polynomial

$\sin(x)\approx x-\dfrac{x^3}6.$

In other words, the limits we often encounter while studying L’Hopital’s rule provide a good motivation for polynomial approximations. Once the idea is introduced, higher-order — eventually “infinite-order” — approximations can be brought in. Some algorithms approximate transcendental functions with polynomials — this provides food for thought as well. Natural questions arise: How far do we need to go to get a given desired accuracy? Will the process always work?

I won’t say more about this approach here, since I’ve written up a complete set of Taylor series notes.  They were written for an Honors-level class, so some sections won’t be appropriate for a typical calculus course. They were also intended for use in an inquiry-based learning environment, and so are not in the usual “text, examples, exercise” order. But I hope they at least convey an approach to the subject, which I have adapted to a more traditional university setting as well. For the interested instructor, I also have compiled a complete Solutions Manual.

I think this is enough to give you the idea of my approach to using a traditional textbook. Every calculus teacher has their own way of thinking about the subject — as it should be. There is no reason to think that every teacher should teach calculus in the same way — but there is every reason to think that calculus teachers should be contemplating how to make this beautiful subject more accessible to their students.

## Cryptarithms

One of the goals of creating this blog was to show you some cool math stuff you might not have seen before. So I thought I’d create a puzzle about this:

Just replace each letter with a digit from 0–9 so that the sum is correct. No number begins with a 0. One more thing: M + T = A. Good luck!

Perhaps you’ve never seen puzzles like this before — they’re called cryptarithms. At first they look impossible to solve — almost any assignment of numbers to letters seems possible. But not really. You’re welcome to try on your own first — but feel free to read on for some helpful advice.

Look at the last column (the units). If L + H + G ends in H, then L + G must end in a 0. Since L and G are digits, then L + G = 10. This doesn’t completely determine L or G, but once you know one of the numbers, you know the other.

As a result, you also know there’s a carry over to the third column (tens). What does this mean? That 1 + O + T + O ends in C. Since O + O is an even number, this means that if T is even, then C is odd, and if T is odd, then C is even. We even know a bit more about T from looking at the sum: T is either 1 or 2, since adding three numbers less than 10,000 gives a sum less than 30,000.

What about the second column? O + A + L ends in A. We might be tempted to think that O + L must end in a 0, but that would mean that O + L is 10. This can’t be, since that would mean that G = O (remember that L + G = 10). Therefore there has to be a carry from the third column over to the second column, meaning O + L = 9. So O is one less than G.

Get the idea? There’s a lot of information you can figure out by looking at the structure of the letters in the sum. But it turns out that without the condition M + T = A, there are 12 solutions to this puzzle! Multiple solutions must occur here, for if you can solve this puzzle, you can also solve

The M and B occur just once, and at the beginning of numbers. This means if M = 7 and B = 9 in a solution, then putting M = 9 and B = 7 — with all other letters staying the same — will also produce a solution. In looking at all the solutions, I found that giving M + T = A results in a unique solution without giving values for specific letters.

That’s all the help you get! Sometimes you might just guess well and stumble onto a solution — but take the additional challenge and prove you’ve got the only solution to the cryptarithm.

How do you create a cryptarithm? There was a time I did so by hand — but those days are gone. Read more if you’d like to see how you can use programming to help you create these neat puzzles.  (Of course there are online cryptarithm solvers, but that takes all the fun out of it!)

## Hexominoes and Cube Nets

I have always been fascinated by polyominoes — geometrical shapes made by connecting unit squares edge to edge. (There’s a lot about polyominoes online, so take a few moments to familiarize yourself with them if they’re new to you.)

Today I’ll talk about hexominoes (using six unit squares), since I use them in the design of my current website.  There are a total of 35 hexominoes — but I didn’t want all of them on my home page, since that seemed too cluttered. But there are just 11 hexominoes which can be folded into a cube — I did want my choice to have some geometrical significance! These are called nets for a cube, and formed a reasonable subset of the hexominoes to work with. Note that the count of 11 nets means that rotating or turning over a net counts as the same one. (And if you want an additional puzzle — show that aside from rotating or reflecting, there are just 11 nets for a cube.)

Now how should I arrange them? I also wanted to use the hexominoes for a background for other pages, so I thought that if I made a 6 by 11 rectangle with them, that would be ideal — I could just tile the background with rectangles.

This is not possible, however — I wrote a computer program to check (more later). But if you imagine shifting a row of the 6 by 11 rectangle one or two squares, or perhaps a column — you would still occupy 66 square units, and the resulting figure would still tile the plane. This would still be true if you made multiple row/column shifts.

So I wrote a program which did exactly that — made random row and column shifts of a 6 by 11 rectangle, and then checked if the 11 hexominoes tiled that figure. After several hours of running, I found one — the one you see on my home page. If you look carefully, you can see the row and column shifts for yourself.

Is this the only possibility? I’m not sure, but it’s the only one I found — and I liked the arrangement enough to use it on my website. If you look at some of the other pages — like one of my course websites — you’ll see a smaller version of this image tiling the background. However, to repeat the pattern in the background, I needed to make a “rectangular” version of the image:

The colors are muted since I didn’t want the background to stand out too much.  And you’ll notice that some of the hexominoes leave one edge of the rectangle and “wrap around” the opposite edge.  But if you look closely, you can definitely find all 11 hexominoes in this 6 by 11 rectangle.

This wasn’t my first adventure with hexominoes — a few years ago, I created a flag of Thailand since I was doing some workshops there. Flags are generally rectangular in shape.

But you can’t create a rectangle with the 35 hexominoes! Let’s see why not. Imagine a rectangle on a checkerboard or chessboard. When you place a hexomino, it will cover some black squares and some white squares.

Now some hexominoes will always cover an odd number of black and white squares — let’s call those odd hexominoes. The others — even hexominoes — cover an even number of black and white squares. As it turns out, there are 24 odd hexominoes and 11 even hexominoes. This means that any placement of all the hexominoes on a checkerboard will cover an even number of white squares and an even number of black squares.

However, any rectangle of 210 = 6 x 35 hexominoes must cover 105 white squares and 105 black squares — both odd numbers of squares. But we just saw that’s not possible — an even number of each must be covered. So no rectangles. This is an example of a parity argument, by the way, and is a standard tool when proving results about covering figures with polyominoes.

To overcome this difficulty, I threw in 6 additional unit squares so I could make a 12 x 18 rectangle — and to my surprise, I found out that the flag of Thailand has dimensions 2:3 as well. You can read more about this by clicking on “the flag of thailand” on the page referenced above — and see that the tiling problem can be solved with a little wiggle room. But no computer here — I cut out a set of paper hexominoes and designed the flag of Thailand by hand….

## CrossNumber Puzzles

This week, we’ll look at one of my favorite types of puzzles — CrossNumber Puzzles. These are like crossword puzzles, except that the clues describe numbers instead of words. The only rule is that no entry in a CrossNumber Puzzle can start with a “0.” You can try this one — but don’t worry if you get stuck. We’ll look at different ways you can go about solving it in just a moment.

How would you go about solving this puzzle? Try to look for the clues which give you the most information. For example, look at 1 Across and 3 Down. Now 1 Across is the cube of a two digit number, and its third digit is actually the first digit of the cube root. So we might want to print out a chart of all four-digit cubes of two-digit numbers:

 10 1000 16 4096 11 1331 17 4913 12 1728 18 5832 13 2197 19 6859 14 2744 20 8000 15 3375 21 9261

You can see that the only possibility is that 1 Across is 4913 and 3 Down is 17.

Looking at 5 Across doesn’t help much, since there are too many possibilities.

But looking at 5 Down is a good next choice. Note that 9 Across has to start with 1 or 3 in order to fit four odd digits in the grid, but no perfect squares end in 3, and so no perfect fourth powers end in 3, either.  This means that 9 Across has to start with 1 so that 5 Down ends in 1.  To help figure out 5 Down, below is a list of four-digit fourth powers:

 6 1296 8 4096 7 2401 9 6561

So 5 Down must be either 2401 or 6561. If it were 2401, then 6 Across would begin with a “0,” so that leaves 6561 as the only option for 5 Down.

I’ll leave it to you to complete the puzzle. I won’t post a solution so that you’re not tempted to peek — but if you add 2 Down and 6 Across when you’re done, you’ll get 157,991.

How can you make your own CrossNumber puzzle? Start by making a grid, and shade in some of the squares. Usually the pattern of shaded squares is symmetric, but it doesn’t have to be. Fill in some of the entries with numbers which have specific properties, like being a perfect square or cube. Or perhaps make one of the entries the product or sum of two others. The only limit is your imagination! It might help to continue reading below, since then you could print different charts and look at the numbers for something interesting. (And get another puzzle to solve, too.)

## Josef Albers and Interaction of Color

My first post on art is about Josef Albers and his use of color. An idea central to his work is that we do not see “individual” colors — but colors are always perceived in relationship to the surrounding colors.

Look at this image for a moment — what do you notice about the smaller rectangles? If you look carefully, you’ll notice that they are all the same color. It may look like some are darker than others — but that’s only because you’re seeing them against different background colors. Albers explored this idea in depth in his famous book, Interaction of Color.

So how can you create this image? Begin with a color specified as RGB — in this case, (0.7,0.6,0.3) — to use as the color of the smaller rectangles. Remember that (0,0,0) is black and (1,1,1) is white; using values for R, G, and B between 0 and 1 will allow you to produce millions of different color combinations.

Now use your computer’s random number generating ability to create three random numbers between -0.3 and 0.3. For this example, I’ll use -0.2, -0.1, and 0.3. Subtract these values from (0.7,0.6,0.3) to get the RGB values for the left larger rectangle — you get (0.9,0.7,0.0). Then add these random numbers to (0.7,0.6,0.3) to get (0.5,0.5,0.6) — these are the RGB values for the right larger rectangle. Notice that this procedure assigns RGB values to the smaller rectangles which are the numerical averages of the RGB values of the colors of the surrounding rectangles.

Keep in mind that this is an arithmetic mixing of colors. If you actually had paints which were the colors of the larger rectangles, mixing them would likely not give you the color of the smaller rectangles. Also keep in mind that Interaction of Color was published in 1963, so that Albers’ ideas were developed with paper and pigment. What I’ve done is adapted Albers’ ideas for use on a computer — and interpreted his ideas as you see here. Color theory is a very complex field, and is widely written about on the internet — so if these ideas intrigue you, start searching!

Yin Yang IV, 8” x 8”

As a final example, here is a piece incorporating these ideas about color with an abstract yin/yang motif. Visit my art website if you’d like to see some additional images with commentary.

Now we’ll get to the specifics of actually implementing the ideas mentioned above. I’ve decided to use Python for these examples since it is a language growing in popularity and is open source. Also, I’m using Python in a Sage environment because it’s open source, too — and you don’t need to download or install anything. You can just open a Sage worksheet in your browser. Sometimes it’s a little slow, so be patient. You can download Sage onto your own computer if you’d like to speed things up.

Here is the link to the interactive color demo. It’s fairly self-explanatory — and you don’t need to know any Python to use the sliders. Just hit shift+enter as explained in the instructions.

One thing to be careful about, though. If you choose a red value of 0.8, and then choose to vary this value by 0.4 — you’ll get red values of 0.4 and 1.2. But since RGB values are between 0 and 1, the 1.2 is “truncated” to 1.0, so you’re really working with 0.4 and 1.0. This means that 0.8 is no longer the average of the two red values — so the “Albers” effect won’t be so pronounced, and may be absent if your values are too far off. Select your values carefully!

I’ve tried to make the code fairly straightforward, so if you know a little about Python or programming in general, you should be able to make some of your own changes. You’ll have to make a Sage account and copy my code to one of your own projects in order to make changes.

This blog is designed to give you ideas to think about, not be a tutorial. So I won’t be teaching you Python. If you need to understand the basics of the RGB color space — well, just look it up. There’s also plenty online about Josef Albers. Go in any direction you like.

But if you are going to play with the Python code to make more complex images, here’s a suggestion. Whenever you are about to type in RGB values, pause for a moment and ask why you’re choosing those particular values. Use color deliberately. This will make all the difference in the world — and may well be the difference between making a digital image, and creating digital art.

## What Is Mathematics?

Mathematics is creative.

Unfortunately, this is lost upon many — if not most — students of mathematics, in large part because their teachers may not understand mathematical creativity, either.  One way to address this issue is to have students write and solve their own original mathematics problems.  This seems daunting at first, until students realize they are more creative than they were led to believe.  (I’ll discuss this more in a later post.)

The difficulty is that the creative dimension of mathematics is a bit elusive.  Give a child crayons and ask her to draw a picture, sure — but give a student some ideas and ask him to create a new one?  To appreciate mathematical creativity, you need some understanding of the abstract nature of mathematics itself.  To create mathematics, you need imagination much like you do in any of the arts — or other sciences, for that matter.

Over the years, I’ve created my fair share of mathematics.  How much of it is really new is hard to determine — how do you know if any of the billions of other people in the world already created something you did?  (Proof by internet search notwithstanding.)

This blog is about sharing some of my ideas, problems, and puzzles.  Some were created years ago, some are new — and I will consider myself lucky if some are entirely original.  I truly did have fun creating them, and I enjoy writing about them now.

I’m hoping to convey an enthusiasm for mathematics and its related fields — in other words, all human knowledge — and to share something of the creative process as well.  The creation of mathematics is not a mystical process, and needs no explanation to a mathematician.  But we can surely do more to make this enlivening process accessible to all in a time when it is certainly necessary.

As you follow, you’ll notice a heavy emphasis on programming.  Every student should learn to program — and in more than one language.  Perhaps this should be an axiom in the 21st century, but we’re not even close.  So many of the tools I use are virtual — the ability to write code to perform various tasks is essential to my creative process, as you’ll see.  In fact, many posts will have links to Python programs in the Sage platform (don’t worry if you don’t know what these are yet).  These tools are all open source, and available to anyone with internet access.

Finally, blog posts will usually have a “Continue reading…” section.  Some posts (like this one) will be essays on teaching, creativity, or a related topic.  Since not everyone may be so philosophically minded, the “Continue reading…” sections of these essays will be a puzzle or game.  Enjoy!