So in this final post for Fall 2017, I’d like to share some examples of student work. In particular, I’ll look at some examples from the Fractal Movie Project, as well as examples of Final Projects.

Recall that the Fractal Movie Project involves using linear interpolation on the parameters in affine transformations in order to make an animated series of fractal images. One student experimented with a bright color palette against a black background. As the fractal morphed, it actually looked like the red part of the image rotated in three dimensions, even though the affine transformations were only two-dimensional.

Cissy wanted to explore the motion of rain in her movie. Although she began with bright colors on a black background, once she saw her fractal in motion, she decided that more subtle colors on a white background would be better suited to suggest falling raindrops being blown about by the wind.

Sepid also incorporated movement in her movie — she created a rotating galaxy with a color palette inspired by the colors of the Aurora Borealis. In addition, she learned how to use the Minim library so she could incorporate sound into her movie as well. Here is a screen shot from her movie.

Now let’s take a look at a few Final Projects. Recall that these projects were very open-ended so that students could go in a direction of their choice. Some really got into their work, with truly inspirational results. The presentation that Sepid gave at a recent meeting of the Bay Area Mathematical Artists was actually work she was doing on her Final Project (read about it here).

Terry took on an ambitious project. She based her work on a Bridges paper by Adam Colestock, *Let the Numbers Do the Walking: Generating Turtle Dances on the Plane from Integer Sequences* (read the paper here). Terry did have some programming experience coming into the course, and so she decided to code all of Adam’s turtle graphics algorithms from scratch! This was no simple task, but she worked hard and eventually accomplished her goal.

Here is a screen shot from one of her movies; Terry wanted to create an interesting visual effect by overlaying multiple copies of the same turtle path. Since this particular path was not too dense in the plane, she was able to work with thicker lines.

Tera created a movie which involved rotating triangles and moving dots. Her movie had a strong sense of motion, and incorporated a vibrant color palette. She remarked that working with color in this project was both fun and quite challenging. In her words, “Playing nicely with hot pink is not an easy feat.”

I would also like to share the fact that Professor Roza Aceska of Ball State University (Muncie, Indiana) will be teaching a course about digital art next semester using Processing which will be incorporating a lot of my course materials. I am very excited about this! Many faculty who come to my talks say they are interested in teaching such a course, but getting Department Chairs and Deans to approve such courses is sometimes an uphill battle.

Professor Aceska’s course will be a bit different from mine — her course is in the Honors Program, and as such, does not count as a mathematics credit. So she will not have most of the mathematics assignments and quizzes that I had in my course. But she will still be emphasizing the fascinating relationship between mathematics, programming, and art. I hope to write more about her course sometime during the next semester.

One final remark — I am helping to organize a Mathematical Art Exhibition at the Golden Section Meeting of the Mathematical Association of America on February 24, 2018 at the California State University, East Bay. So if you’re reading this and are in the Bay Area and would like to submit some mathematical art for inclusion in our exhibit, please let me know!

]]>

They were dark times in the Kingdom of Verdoon. A band of fierce Rogues was terrorizing the local hamlets. King Buford was very displeased — he had no other option but to send out a legion of Brave Knights and Loyal Knights to round up the Rogues and deliver them to the castle dungeons.

So he chose seven of his bravest Brave Knights, and seven of his most loyal Loyal Knights, and dispatched them across Mount Kerchoo to the hamlet of Dunken, where the Rogues were last reported to have been wreaking havoc.

The Knights were capable Knights, and soon rounded up seven of the fiercest Rogues, including their leader, Thorn Yackley. Now they had the difficult task of escorting the Rogues back through the narrow, winding path over Mount Kerchoo.

The Rogues were so fierce, no single sword could subdue any of them, nor could a single mace. But they were no match for both a sword

anda mace.Now the Brave Knights carried a single sword, and the Loyal Knights a single mace. So on the trek back to the castle — where they had to walk single file, the path was so narrow — it was vital that each Rogue be flanked by both a Brave Knight and a Loyal Knight in the event the Rogue tried to escape.

The question: In how many ways could the Brave Knights, Loyal Knights, and the Rogues be lined up so that on the treacherous way back, each Rogue was flanked by both a Brave Knight and a Loyal Knight?

(For this problem, consider the Brave Knights indistinguishable from each other; similarly for the Loyal Knights and Rogues.)

Recently, I had been challenged to create a lesson which involved problem-solving with binomial coefficients. But I didn’t want to create just *any* lesson — I wanted something interesting and novel.

Now if you’ve ever taught combinatorics and counting, you know that there is a deluge of problems about binomial coefficients — from choosing committee members, sitting people around a circular table, lining up books on shelves, etc. So it’s not an easy task to come up with something you think might be new.

That was the genesis of *Knights and Rogues.* Of course it may very likely *not* be new, since it really is difficult to come up with a combinatorics problem no one has thought about before. But I did ask a colleague who knows a *lot* about problem solving, and he hadn’t seen it before.

The story is just to get students interested. Combinatorially, we could state the problem as follows:

Given

p0’s,q1’s, andr2’s, in how many ways can you line them up so that each 2 is surrounded by both a 0 and a 1?

It turns out that there is a *lot* going on in this problem. With three parameters, the analysis is far from straightforward.

There are a few restrictions on the parameters. For example, we need or there are not enough Knights to flank the Rogues. We also need

or else there wouldn’t be enough Brave Knights *and* Loyal Knights to flank the Rogues. For example, if *p* = 2, *q* = 1, and *r* = 3 (so that *q* just falls short of the above inequality), you can see the problem — the one 1 can flank *at most* two 2’s, and so there is one 2 without an adjacent 1. But if increase *q* to 2, we can have either the sequence 0212021 or 1202120.

Of course it is possible to consider specific examples, but it is *also* possible to consider infinite families of parameters — we’ll look at the case *p* = 2, *q* = *n*, and *r* = 2 to give you an idea of the reasoning involved.

Now when *n* = 1, there is only one possibility: 02120. But when *n* is larger than 1, we need to look at two separate cases: when the 2’s are separated by more than one 0/1, so that we are looking at two blocks of 021 or 120. When the 2’s are separated by *exactly* one 0/1, we only have the options 02120 or 12021. We need to count each case separately.

Let’s look at the first case. We have two blocks of either 021 or 120. This uses up the two 1’s but there are *n* – 2 1’s left over. So we have *n* things to arrange: two blocks, and *n* – 2 1’s. This may done in

ways, since we first choose the 2 places for the blocks, but then multiply by 4 since each block has two possibilities: 021 or 120.

In the second case, if the 2’s are only separated by one number, we may have a block of 02120 and *n* – 1 1’s to place, giving *n* possibilities. With a block of 12021, we have the block, one 0, and *n* – 2’s to place, which can be done in

ways (since the order of the block and the one 0 matters). Adding these three cases together results in

possible lineups for the Knights and Rogues.

Interestingly, these are the octagonal numbers (A000567 in the OEIS). I have no idea why, though….

What I like about this problem is that parameterizing *p,* *q,* and *r* in different ways produces seemingly very different results. One interesting parameterization is *p = **q* = *r* = *n.* It turns out that this sequence — at least the first several values, which I used the computer to generate and didn’t work out by hand — is also in the OEIS (A141147), and the description is the

number of linear arrangements of

nblue,nred andngreen items such that the first item is blue and there are no adjacent items of the same color (first and last elements considered as adjacent).

I find this particularly intriguing since in *Knights and Rogues,* 0’s and 1’s *can* be adjacent — but even though 2’s are not adjacent, it is not possible to have any block be 020 or 121, although these are counted in A141147. Finding a bijection between the two linear arrangements would be a very interesting problem.

I hope you enjoyed reading about *Knights and Rogues!* Again, this is another example of mathematics as it happens — I came up with this problem within the past few weeks, and I’ve just scratched the surface of this interesting puzzle. I hope it’s *actually* a new problem, but I won’t be surprised if I get a comment like, “Oh, I saw that problem in…..” Generating new, novel mathematics problems is not an easy task…..

And incidentally, the answer to the initial problem is 80,096. Did you get it?

]]>

But there are some loose ends I’d like to tie up. I’ve had brief forays into other languages — too brief to devote an entire post to any one of them. I’ve mentioned a few of them here and there, but I’d like to take the opportunity to include them all in one post.

Before doing so, I should mention that Processing is my most recent programming adventure. But I have written *so* much about using Processing in the context of my digital art course, I don’t feel the need to devote a separate post to it. And I feel I might bore you, dear reader….

The first is PASCAL, which I first learned while taking an undergraduate programming class. Other than the course, I only did a few other things with PASCAL. I did write a routine that printed out 4 x 4 magic squares — I was really into magic squares back in college. I also dabbled with computer graphics and geometrical inversion — I recall giving a talk where I discussed geometrical inversion, and I split the screen so on one side you saw lines tangent to a conic section, while on the other side, you saw inverse circles tangent to the inverse limaçon.

While in graduate school, I had a one-year stint filling in for a faculty member at a nearby college, and I taught a data structures course using PASCAL. Now, I would never think of PASCAL as a go-to language for any particular purpose. It’s still around, but not nearly as popular as it was then.

The next is LISP*, which I used while teaching at a summer program during graduate school. This was a parallel version of LISP written for the Connection Machine, a state-of-the-art supercomputer in its day. It had literally thousands of different processors, each very simple. But because of the sheer number of processors, the speed of the Connection Machine merited it the designation “supercomputer.”

The language was quite similar to LISP, except that many functions had parallel versions which could be executed on each processor. I can’t recall much of what I did on the Connection Machine, but I do remember programming Conway’s *Game of Life* on a 1000 x 1000 torus. Of course I can do that on my laptop right now in *Mathematica,* but at the time, it was a real feat! Remember, that was back in the day when Mandelbrot sets were calculated pixel by pixel and computers were so slow you could actually see the pixels march right on by….

Chronologically, Maple — a direct competitor of *Mathematica* — comes next, sort of…I used Maple around the same time as LISP*. I seem to recall the only reason I played around with it was that I had a house-sitting job for a few summers, and there was a computer I could use which had Maple on it.

I recall finding Maple really useful, but there was a bit more syntax than with *Mathematica.* I really like *Mathematica*‘s fundamental data type — the* list*, just like LISP. But I think part of the reason I’ve stuck with *Mathematica* through the years is that most places I’ve been have supported it — and being *free* is a big advantage. I know Maple has changed a *lot* since I last used it, so I don’t feel I’m able to say more about a comparison with *Mathematica* than what I’ve already said.

Jump ahead a few years to C++. I can’t remember exactly when I started learning it, but I was teaching at a small liberal arts college, and a colleague who usually taught an algorithms course was going on sabbatical. I was really the only other faculty member at the university qualified to teach it, and so there it was! The students in the course knew C++, so I needed to learn it, too….

Well, I should say I learned enough to write code for an introductory algorithms course, which means I didn’t have to dive too deeply in. I can’t say I used C++ for much after I taught the course, except I remember writing some routines to do financial planning. You know, like if you have different investments at different interest rates for different numbers of years, etc., how much will you have when you retire? (Being a mathematician, I thought it insane that I should pay someone else to do my financial planning, so I read everything I could on the topic and did it myself.) But I haven’t used C++ since.

Last — and perhaps least — there’s Java. I learned Java was when I was applying for a job teaching mathematics and computer science, and the language taught was Java. I had never written a line in Java before, and there was some concern that I wasn’t qualified.

So I wrote a little interactive game based on some puzzles I created, which was really quite nice, if I must say. The only way to show you know how to code in a language is to code, so I did it.

It was rather unpleasant, though. What I needed to do was really just algorithmic, and the object-orientedness of Java and the need to precisely define data structures really got in the way. I hope never to write another line of Java again. (Incidentally — long story — I was offered the job but turned it down. Saved me from teaching Java….)

And I think that’s about it! If I can leave you with anything after this series, it’s GO CODE! Learn as many *different* types of languages as you can. The best way to learn is to find something you really want to do, and then go for it.

Remember, my first programming language was Fortran — using *punch cards.* Running batch jobs. Today, you’ve got laptops and the internet. The only limit is your imagination….

]]>

Like last time, we began with a social half hour from 3:00–3:30. This gave people plenty of time to make their way to campus. I didn’t have the pleasure of participating, since the campus buildings require a card swipe on the weekends; I waited by the front door to let people in. But I did get to chat with everyone as they arrived.

We had a full agenda — four presenters took us right up to 5:00. The first speaker was Frank A. Farris of Santa Clara University, who gave a talk entitled *Fibonacci Wallpaper Spirals.*

He took inspiration from John Edmark’s talk on spirals at Bridges 2017 in Waterloo, which I wrote about in my blog last August (click here to read more). But Frank’s approach is rather different, since he works with functions in the complex plane.

He didn’t dive deeply into the mathematics in his talk, but he did want to let us know that he worked with students at Bowdoin College to create open-source software which will allow anyone to create amazing wallpaper patterns. You can download the software here.

Where do the Fibonacci numbers come in? Frank used the usual definition for the Fibonacci numbers, but used initial values which involved complex numbers instead of integers. This allowed him to create some unusually striking images. For more details, feel free to contact him at ffarris@scu.edu.

Next was our first student talk of the series, *My Experience of Learning Math & Digital Art*, given by Sepid Ebrahimi. Sepid is a student in my Mathematics and Digital Art course; she is a computer science major and is really enjoying learning to code in Processing.

First, Sepid mentioned wanting to incorporate elements into her work beyond simple points, circles, and rectangles. Her first project was to recreate an image of Rick and Morty, the two main characters in the eponymous cartoon series. She talked about moving from simple blocks to bezier curves in order to create smooth outlines.

Sepid then discussed her second project, which she is using for her Final Project in Mathematics and Digital Art. In order to incorporate sound into her work, she learned to program in Java to take advantage of already-existing libraries. She is creating a “live audio” program which takes sound input in real time, and based on the frequencies of the sound, changes the features of various geometrical objects in the video. Her demo was very fascinating, and all the more remarkable since she just started learning Processing a few months ago. For more information, you can contact Sepid at sepiiid.ebra@gmail.com.

The third talk, *Conics from Polygons: the Chord Ratio Construction*, was given by Scott Vorthmann. He is spreading the word about vZome, an open-source virtual environment where you can play with Zometools.

The basis of Scott’s talk was a simple chord ratio construction, which he is working on with David Hall. (Here is the GeoGebra worksheet if you would like to play with it.) The essential idea is illustrated below.

Begin with two segments, the red and green ones along the coordinate axes. Choose a ratio *r.* Now add a chord parallel to the second segment and *r* times as long — this gives the thick green segment at *y* = 1. Connect the dots to create the third segment, the thin green segment sloping up to the right at *x* = 1. Now iterate — take the second and third segments, draw a chord parallel to the second segment and *r* times as long (which is not shown in the figure), and connect the dots to form the fourth segment (the thin green segment sloping to the left).

Scott then proceeded to show us how this very simple construction, when iterated over and over with multiple starting segments, can produce some remarkable images.

Even though this is created using a two-dimensional algorithm, it really does look three-dimensional! Conic sections play a fundamental role in the geometry of the points generated at various iterations. Quadric surfaces in three dimensions also come into play as the two-dimensional images look like projections of quadric surfaces on the plane. Here is the GeoGebra worksheet which produced the graphic above. For more information, you can contact Scott at scott@vorthmann.org.

The final presenter was Stacy Speyer, who is currently an artist-in-residence at Planet Labs. (Click here to read more about art at Planet Labs.) She didn’t give a slideshow presentation, but rather brought with her several models she was working on as examples of *Infinite Polyhedra Experiments with Planet’s Satellite Imagery.*

One ongoing project at Planet Labs is planetary imaging. So Stacy is taking high-resolution topographical images and using them to create nets for polyhedra. She is particularly interested in “infinite polyhedra” (just google it!). As you can see in the image above, six squares meet at each vertex, and the polyhedron can be extended arbitrarily far in all directions.

One interesting feature of infinite polyhedra (as you will notice above) is that since you cannot actually create the *entire* polyhedron, you’ve got to stop somewhere. This means that you can actually see *both* sides of all the faces in this particular model. This adds a further dimension to artistic creativity. Feel free to contact Stacy at cubesandthings@gmail.com for more information!

We’ll have one more meeting this year. I am excited to see that we’re making so much progress in relatively little time. Presentations next time will include talks being prepared for the Joint Mathematics Meetings in San Diego this coming January, so stay tuned!

]]>

But first, I’ll start off by giving you the solution to the last puzzle I presented in the last installment. The statement of the puzzle is too long to repeat, so you can refresh your memory at Beguiling Games II.

First, it is important to note that Lucas’s statement actually provides *no* information! Suppose Ophelia’s card was *Truthteller.* Then she would have told the truth in Round 1, passed her card to Lucas, and he would truthfully have stated that she told the truth in Round 1.

But what if Ophelia’s card was *Liar?* Then her statement “I am a Truthteller” in Round 1 would in fact have been a lie. Now she passes her card to Lucas. He lies and says she told the truth in Round 1! What this means is Lucas could have made his statement in Round 2 regardless of what card Ophelia passed him.

Note that the same logic applies to Mordecai’s statement. He could have said “Lucas also told the truth in the first round” regardless of whether Lucas passed him a *Truthteller* or a *Liar* card.

Now let’s examine Nancy’s statement in some detail. She said that there is at least one liar at the table. Could she have lied?

Well, if the fact that the there is at least one liar at the table is *false,* that means *everyone* is a *Truthteller.* But there is no way Nancy could have known this, since the only two cards she saw were hers and the card passed to her by Mordecai.

That means Nancy *must* have told the truth in Round 2, and Mordecai must have passed her a *Truthteller* card. But in order for her to have sufficient information to say there is at least one *Liar* at the table, she must have been holding a *Liar* card in Round 1.

Now this information could be deduced by *anyone* at the table. In other words, anyone would know that Nancy held a *Liar* card in Round 1, and Mordecai held a *Truthteller* card. That leaves Lucas’s and Ophelia’s cards in Round 1.

The only person who could know *both* these cards would be Lucas — he knew his own card in Round 1, and he knew Ophelia’s card because she passed it to him in Round 2. So he had enough information to declare after Nancy’s statement.

It is important to point out that there is no way to know what Lucas’s and Ophelia’s cards actually were. All we need to know is that Lucas knew what both of them were.

Did you figure it out? It takes a little bit of reasoning, but all the facts were there.

Now as I mentioned in the last installment, this time I’d give you a geometrical two-player game to work out. I call it *Splotch!*

In the game of *Splotch!*, players alternate coloring in squares on a 4 x 4 grid. The goal is to create a target shape, called a *splotch.* A player wins when he or she colors in a square which completes a splotch, and then announces the win.

So if a player completes a splotch but doesn’t notice it and doesn’t announce the win, then play continues until someone completes *another* splotch. You can only call *Splotch!* on your turn, so you cannot win by calling it if your opponent fails to. It is also important to remember that the square you color in on your turn *must* be part of a splotch you announce.

In the version of *Splotch!* I’m sharing with you this week, the target splotch is:

Just so you know how it works, let’s look at a sample game, shown below.

There are two players, A and B. A goes first, and plays in the lower left corner (labelled with A1). B colors in a square in the top row (B1). Then A’s second move is in the second row. B wins on the next play by completing — and announcing! — a splotch. The splotch may be rotated (as in this example), reflected, or even both! So you’ve got to watch carefully.

Now admittedly, A was not a very clever player in this round of *Splotch!* In fact, B could also have won by playing as follows:

But here is the question: In this version of *Splotch!*, which player can force a win *every* time? Remember: you must be able to provide a response to *every* move by your opponent! I’ll reveal which player can force a win in my next installment of Beguiling Games, and I’ll share my particular strategy for winning.

One final remark — a bit of a tangent, but related to puzzles and games. If you’ve been following my blog for a long while, you might remember my (fiendishly diabolical) number searches. (These were posted well over a year ago.)

Here, the numbers in the right are in base 10, but you have to convert them to *another* base to find them in the grid! You can read more about these puzzles here and here.

I submitted these puzzles to *MAA Focus*, the newsmagazine of the Mathematical Association of America. I am happy to report that they will be featured on the Puzzle Page in the December 2017/January 2018 issue!

Now I will admit that this doesn’t exactly make me famous, given the number of people who subscribe to *MAA Focus.* But I composed these puzzles specifically for my blog — so if I hadn’t decided to write a blog, these puzzles might never have been created. Perhaps another reason to write a blog!

Stay tuned for the next round of Beguiling Games, where you’ll learn (if you didn’t already figure it out for yourself) who has a winning strategy in the game of *Splotch!*

]]>

But recently my interest has been rekindled — to the point that I started writing a paper a few weeks ago! I often like to share mathematics I’m working on as it’s happening to give you some idea of the process of doing mathematics. The paper has quite a bit more mathematics in it than I’ll include in this post, but I’ll try to give you the gist of what’s involved.

Recall (again, see my first post for a more thorough discussion) that I’m interested in finding dissections that you can draw on graph paper — I find these more enjoyable as well as being accessible to a wider audience. So all the dissections I’ll talk about will be based on a grid.

The first example is a dissection of two octagons to one, such as shown below.

In other words, you can take the pieces from the two smaller octagons, move them around, and build the larger octagon. If you look carefully, you’ll notice that the larger octagon is rotated 45° relative to the smaller octagons. Geometrically, this is because to get an octagon twice the area of a given octagon, you scale the side lengths by Imagine a square — a square with side length has area while a square with side length has area — which is double the area.

Now think of a segment of unit length. To get a segment of length you need to take a diagonal of a unit square, which rotates the segment by 45° as well as scales it by a factor of This is why the larger octagon is rotated with respect to the smaller ones.

But what makes this dissection interesting is that there is an *infinite* family of very similar dissections. By slightly varying the parameters, you get a dissection which looks like this:

Here, you can clearly see the 45° rotation of the larger octagon. I always enjoy finding infinite families of dissections — it is very satisfying to discover that once you’ve found one dissection, you get *infinitely many* more for free!

The proof that this always works (which I will omit here!) involves using a geometrical argument — using arbitrary parameters — to show that the green triangles *always* have to be right isosceles triangles. This is the essential feature of the dissection which makes it “work” all the time.

The second example I’m including in the paper is a dissection on a triangular grid, like the one below.

Note that the figure on the left is an irregular dodecagon; that is, it has twelve sides. Recall that the interior angles of a *regular* dodecagon have measure 150° — but so do the angles of this irregular dodecagon as it is drawn on a triangular grid.

If you look carefully, you’ll see how the sides in the pieces of the dissection on the right match up with sides of the same length from the other pieces. Also, looking at the dissection on the right, you’ll see that around all the interior vertices, there are two angles with measure 150° and one with measure 60°, adding up to 360° — as we would expect if the pieces fit exactly together.

And — as you might have guessed from the first example — this is *also* one of an infinite family of dissections. As long as the sides of the irregular dodecagon alternate and the vertices stay on the triangular lattice, there is a dissection to a rhombus. Below is another example, and there are infinitely many more….

My third and final example involves irregular dodecagons, but this time on a square grid. And while I found the previous two dissections several years ago, I found this example just last week! What inspired me was one of my favorite dissections — from an irregular dodecagon to a square — also found many years ago.

In the spirit of the first two examples, I asked myself if *this* dissection could be one of an infinite family. The difficulty here was that there were three parameters determining an irregular dodecagon, as shown below.

We do need so that the dodecagon is convex and actually has 12 sides; if four pairs of sides are in perfect alignment and the figure becomes an octagon.

There is an additional constraint, however, which complicates things a bit. The area of this dodecagon must *also* be the area of some tilted square with vertices on the grid, as illustrated below. Note that the area of this square is just

It is not a difficult geometry exercise to show that the area of the dodecagon is So in order to create a dissection, we must find a solution to the equation

Again, here is not the place to go into details. But it is possible to find an infinite family of solutions when You get a dissection which looks like this:

I was particularly pleased to have found this eight-piece dissection since most of my attempts until this point had ten pieces or more. And to give you a sense of this family of dissections, here is an example with different parameters within this family.

You can definitely see the resemblance, but it is also clear that the dodecagon and square are not the same shape as those in the previous dissection.

So these are the three families of geometrical dissections I’ll be including in my paper. I hope these examples might inspire you to pick up a pencil and graph paper and try to find some infinite families of your own!

]]>

One of my colleagues introduced me to the Sage environment (now going by “CoCalc”) as a place to do Mathematica-like calculations, albeit at a smaller scale. Four features were worthy of note to me: 1) you could do graphics; 2) you could write code (in Python); 3) you could run the environment in your browser without downloading anything; and 4) it was open source.

For me, this was (at the time) the perfect environment to develop tools for creating digital art which I could freely share. Yes, I had thousands of lines of Mathematica code, but Mathematica is fairly expensive. I wanted an environment which would be easily accessible to students (and my blog followers!), and Sage fit the bill.

So that’s why I started learning Python — it was the language I needed to learn in order to use Sage.

For me, two things were a challenge. The first was how heavily typed Python is. In Mathematica, the essential data structure is a list, just like in LISP. For example,

{1, 2, 3}

is a list. But that list may *also* represent a vector in three-dimensional space — even though it would look exactly the same. It may *also* represent a set of numbers, so you could calculate

Intersection[{1, 2, 3}, {3, 4, 5}].

In Python you can create a list, tuple, or set, as follows:

list([1, 2, 3]), tuple([1, 2, 3]), set([1, 2, 3]).

And in Python, these are three different objects, none equal to any other. I don’t necessarily want to start a discussion of typed vs. untyped languages, but when you’re so used to using an untyped language, like Mathematica, you are constantly wondering if the argument to some random Python function is a list, tuple, or….

Second, Python has a “return” statement. In languages like LISP and Mathematica, the value of the last statement executed is *automatically* returned. In Python, you have to specify that you want a value returned by using a *return* statement. I forget this all the time.

And while not a huge obstacle, it does take a little while to get used to integer division. In Python, 3/4 = 0, since when you divide integers, the value of the fraction is the quotient when considered as integer division. But 3/4. = 0.75, since adding the decimal point after the 4 indicates the number is a floating point number, and so floating-point arithmetic is performed.

Of course, if you’ve been reading recent posts, you know I’ve moved from Sage entirely to Processing in my Mathematics and Digital Art course. You can read more about that decision here — but one key feature of Processing is that there’s a Python mode, so I was able to take work already done in Sage and adapt it for Processing.

It turns out that this was not as easy as I had hoped. The essential difficulty is that in Sage, the bounding box of your image is computed for you, and your image is appropriately scaled and displayed on the screen. In Processing, you’ve got to do that on your own, as well as work in a space where *x*– and *y*-coordinates are in units of pixels, which is definitely *not* how I am used to thinking about geometry.

I am finding out, however — much to my delight and surprise — that there are quite a few functional programming aspects built into Python. I suspect there are *many* more than I’m familiar with, but I’m learning them a little at a time.

For example, I am very fond of using maps and function application in Mathematica to do some calculations efficiently. Rather than use a loop to, say, add the squares of the numbers 1– 10, in Mathematica, you would say

Plus @@ (#^2& /@ Range[10])

The “#^2&” is a pure function, and the “/@” applies the function to the numbers 1–10 and puts them in a list. Then the function “Plus” is applied, which adds the numbers together.

There is a similar construct in Python. The same sum of 385 can be computed by using

sum([(n + 1)**2 for n in range(10)])

OK, this looks a little different, but it’s just the syntax. Rather than the “#” character for the variable in the pure function, you provide the variable name. The “for” here is called *list comprehension* in Python, though it is just a map. Of course you need “(n + 1),” since Python always starts at 0, so that “range(10)” actually refers to the numbers 0–9. And the “sum” function can take a list of numbers as well. But from a conceptual level, the same thing is going on.

The inherent “return” in any Mathematica function does find its way into Python as well. Let’s take a look at a simple example: we’ll write a function which computes the maximum of two numbers.

Now you’d probably think to write:

This is the usual way of defining “max.” But there’s another way do to this in Python.

If you ask Python to

print 3 > 2,

you’ll see “True.” But you can *also* tell Python to

print (3 > 2) + 7

and get “8.” What’s going on here is that depending on the context, “3 > 2” can take on the value “True” or “1.” Likewise, “3 < 2” can take on either the value “False” or the value “0.”

This allows you to completely sidestep making Boolean checks. Consider the following definition.

This also works! If in fact a >= b, you return the value 1 * a + 0 * b, which gives you a — the maximum value when a >= b. And when a < b, you return b. Note that when a = b, *both* are the maximum, so we could just as well have written

I think this is a neat feature of Python, which does not have a direct analogue in Mathematica. I am hoping to learn many other intriguing features like this as I dive deeper into Python.

Python is my newest language, and I have yet to become “fluent.” I still sometimes ask the internet how to do simple things which would be at my fingertips in Mathematica. But I do love learning new languages! Maybe in a year or so I’ll update my *On Coding* entry on Python with a flurry of new and interesting things I’ve learned….

]]>

After the last meeting, I received a few emails offering suggestions about different ways to organize the gatherings. One suggestion was to have a social period for the first part of the meeting, where participants could meet those they didn’t already know, or perhaps bring artistic items for show-and-tell.

This seemed like a good idea, since in addition to letting participants get to know each other or just catch up on the previous month, it gave them a 30-minute buffer to arrive on campus. It turns out this part of the afternoon went very well, with just about everyone arriving by 3:30. Dan Bach was giving away old copies of mathematics journals he had collected over the years, while Colin Liotta was giving away laser-etched wooden pendants.

The only scheduled talk of the afternoon was given by Roger Antonsen, entitled *Mathematical explorations and visualizations.*

Roger talked about several of his extensive library of Processing animations. He takes his inspiration from many different places – but his Processing mantra is sometimes “make it move.” He takes an image which fascinates him, recreates it as best as he can, and then varies different parameters to make the image move.

Some of his most intriguing examples involved optical illusions, and are based on the work of Pinna; see his web page on Art to see some examples.

He also emphasized the need to create balance in his work – when you parameterize features of an image, you need to decide the range the parameter takes. Too much motion, and the animation looks too distorted, but too little, and the animation is too static. Of course the need to create balance in artwork is not restricted to creating animations, but it is constantly in Roger’s mind as he creates.

After Roger’s talk, we moved on to a discussion about the nature of mathematical and digital art. There are other similar terms in use, such as algorithmic art and generative art. Typically, generative art is described as art generated by some autonomous system. This means that algorithmic art — that is, art created by use of a computer program — is a subset of generative art. But what do all these terms mean to us, individually, as artists?

I had originally thought to break into smaller groups at first, but the group wanted to have just one, larger discussion.

There were many and varied opinions expressed — from commentary about the art community as a whole, to those who thought the question “What is mathematical art?” is nonsensical to ask because there is really no answer, and it doesn’t impact the creative process at all.

Two points I made relate to my teaching Mathematics and Digital Art. First, every time you settle on the value for a parameter in some work you’re doing, you are making an aesthetic choice. You can tweak all you like, but then all of a sudden you just say to yourself, “OK, that’s it!” Of course there are times you just stop because you can’t find precisely what you want and just need to move on, but I think you get the gist of what I’m saying. You’re making artistic choices all the time.

And second, I have students write short narratives about their work, describing the parameter choices they make. I want to them to think about when a digital *image* becomes a piece of digital *art.* Of course (as alluded to above) there really is no definitive answer to this question, but for students just beginning to dive into the world of digital and mathematical art, it is a useful question to consider.

This took us right to our designated ending time, 5:00. One of the participants suggested a Thai place nearby, and so eleven of us made the short trek just north of campus. It was actually quite good, according to all accounts. And as I mentioned earlier, two participants who couldn’t make it earlier in the day joined us at the restaurant. The discussions were lively, covering a broad range of mathematics, art, and other topics as well.

So again, a good time was had by all! To round out today’s post, I’d like to say a few words about the new Digital Art Club I’m advising at the University of San Francisco. It seems each week, one or two more students become interested, mostly by word of mouth. There are new faces all the time!

It turns out this is a *great* opportunity for mathematics or science majors to learn about digital art. The Mathematics and Digital Art course I’m teaching is not at a high enough level to count towards a mathematics major, and many students in the sciences (like computer science or physics) have required mathematics courses, also at a higher level.

We’re focusing on learning Processing at the moment, since not only are students very interested in learning the software, but I have written quite a bit about Processing on my blog. So I can easily get students started by pointing them to an appropriate post.

Not only that, we’ve got a few students willing to take leadership positions and secure status as an officially recognized student club. This means there are funds available for field trips and other activities. We’re hoping to make a trip to the Pace Gallery in Palo Alto. I’ll occasionally update on our progress in future posts. Stay tuned!

]]>

It turns out this is making a really big difference in the way the class is progressing. The first two times I taught the course, I had students work in the Sage environment for the first half of the semester. The second half of the semester was devoted to Processing and student projects.

Because students only started to learn Processing at the same time they were diving into their projects, they were not able to start off with a Processing-based project. As it happened, a few students actually incorporated Processing into their final projects as the second half of the semester progressed, but this was the exception, not the rule.

But last week, we already started making movies in Processing! Starting simply, of course, with the dot changing colors.

This was a bit easier to present this time around, since we already had a discussion of user space vs. screen space earlier in the semester. So this time, I could really focus on linear interpolation — the key mathematical concept behind making animations.

Next week will be a Processing-intense week. I’ll delay some topics — like geometric series — to a little later in the course so we can get more Processing in right now. The reason? I really think many students will involve Processing in their final projects in a significant way. I want to make sure they have enough exposure to feel confident about going in that direction for their final projects. I’ll let you know what happens in this regard in my next update of Mathematics and Digital Art.

Now for some examples of student work! For the assignment on iterated function systems, students had three different images to submit. The first was a Sierpinski triangle — I asked students to create an image simultaneously as close to *and* as far away from a Sierpinski triangle as possible. The idea was that a viewer should recognize the image as being based on a Sierpinksi triangle, but perhaps only after staring at it for thirty seconds or so.

This is Sepid’s take on the assignment. On many of her pieces, she experimented with different ways to crop the final image. This has a significant effect on the image’s final appearance.

This is Cissy’s submission for the Sierpinski triangle. In this piece (and the others submitted for this assignment), Cissy remarked that she really enjoyed experimenting with color. I commented that I thought color choices were among the most difficult decisions to make as far as elements of a work of digital art are concerned.

The second piece was to involve only two affine transformations. This is often a challenge for students, but there really is an enormous variety of images that may be created using just two transformations. In addition, one of the transformations needed to involve a rotation by a non-trivial angle (that is, not a multiple of 45°), and students needed to submit a picture of their calculations as well.

One student was trying to create an image that looked like an animal footprint. She remarked that she did consider a different color palette, but in the end, preferred to go with monochromaticity.

Interestingly, Terry also used a simple color palette. She remarked that it was challenge to use just two transformations — and because of this minimalist requirement, decided to go with a minimalist color palette. In addition, her resulting fractal reminded her of birds, so she set the fractal against a white moon and gray sky.

For the third submission, there were no constraints whatsoever — in fact, I encouraged students to be as creative as possible. There was a *very* wide range of submissions. One student was fairly minimalistic, using a highly contrasting color palette.

Jack’s piece was also fairly minimalistic. I should remark that we took part of a lab one day for students to do some online peer commenting; Jack (and others as well) remarked that he used the advice of another student to improve an earlier draft of his piece. In particular, he adjusted the stroke weight to increase the intensity of the colors.

Tera based her work on the Sierpinski triangle, but *also* included reflections of each of the three smaller components of her version of the Sierpinski triangle. She remarked that the final image reminded her of a snowflake, or perhaps a Christmas sweater.

Alex’s inspiration came from *The Great Wave off Kanagawa*, by Katsushika Hokusai.

First, he created the fractal image, experimenting with various color combinations. When he was satisfied with his palette, he added the boat and the white circle to suggest a black moon. A rather interesting approach!

As you can see, I’ve got quite a creative class of students who are willing to experiment in many different ways. It’s interesting for me, since there is no way to predict what they’ll create next! I look forward to seeing what they create when they really dive deeply into Processing and begin making animations.

In the next update, I’ll report on how students involve Processing in their project proposals. In addition, they will have submitted their fractal movie projects by then, so there will undoubtedly be many interesting examples of student work to exhibit. Stay tuned!

]]>

We’ll show that X has a winning strategy. As with usual Tic-Tac-Toe, X starts at the center. If O goes in any square which is *not* a corner, then X will win as a result of the winning strategy in Tic-Tac-Toe. So all that’s left to do is look at the case when O goes in a corner. Let’s suppose it’s the upper right corner.

Then X goes in the lower right corner. O must block, or else X will get three-in-a-row and win (since X wins if either player gets three-in-a-row). So now, the board looks like this:

Take a moment to see if you can figure out X’s winning strategy. Do you see it? All X needs to do is place in the center of the bottom row.

Look at the top row. *Someone* eventually has to place an X or O in this location. No matter which one, a three-in-a-row will be created, and X will win! So in this version of Tic-Tac-Toe, X has a winning strategy.

Today’s game will involve a different dynamic — cards and logic. But first, let me give a little bit of context. I have often used the book *Problem Solving in Recreational Mathematics* by Averbach and Chien when I’ve taught an introduction to proofs course. There are many interesting problems in this book, and the chapter on logic has several problems involving Truthtellers and Liars.

So you have to solve problems by figuring out who are the Truthtellers and who are the Liars. I like to use these problems to get students writing arguments in complete sentences since not only are they fun to work out, but they don’t involve notation. Using notation correctly is another issue entirely, and I prefer to deal with that later on in the course.

As before, there’s a story to go along with the game….

Lucas, Mordecai, Nancy, and Ophelia decided that enough was enough, and so ended their Saturday afternoon’s cramming for the National Spelling Bee. Wondering what they might do to pass the time, Lucas suggested, “Let’s play Nuh-Uh!” Everyone enthusiastically agreed.

And so a game of Nuh-Uh! — whose creators, incidentally claim that it is the *only* game on the market which “Tortures your Mind, Warps your Character, and Impoverishes your Soul — all at the Same Time!” — commenced.

So Lucas shuffled the deck of eight cards; four of the cards had the word *Truthteller* on them, and four had the word *Liar.* Dealing from the left, Lucas first dealt a card to Mordecai, then one to Nancy, one to Ophelia, and then finally one to himself. Cards are dealt face down so a player can only see his or her card.

Per the rules of Nuh-Uh!, Lucas, then Mordecai, Nancy, and finally Ophelia made the statement “I am a Truthteller.” Of course, such a statement was consistent with each player’s card, regardless of what was written on it. Thus ended the first round.

In subsequent rounds, each player passes his or her card to the player on the left, and makes a statement consistent with the new card. Thus, if Lucas passed Mordecai a card with *Liar* written on it, Mordecai would have to make a statement which is false. The statement a player makes is based on the knowledge of the cards he or she has seen, and any other information which may be deduced from the statements of the previous players.

The same player begins each round of making statements. So Lucas began each round in this game. Once the game is over, the deal passes to the left, so Mordecai would deal and begin each round with a statement.

After a player makes a statement, players may, beginning with the player on the left of the one who just spoke, “Declare” — that is, say what card each of the players held during the first round. The declaring player then looks at the cards held by the players to decide if he or she has won. If an error is made in declaring, the player drops out and play continues; otherwise the cards are turned over and the deal passes to the next player on the left.

So the players passed their cards to the left, and thus the second round of making statements began. Lucas started off with “Ophelia told the truth in the first round.” After a polite few seconds of pause to give someone a chance to declare, Mordecai said, “Lucas also told the truth in the first round.”

Another brief pause ensued before Nancy stated, “There is at least one liar at the table.” Note: there are four *Truthteller* and four *Liar* cards, so it is possible that all players were dealt a *Truthteller* card.

After Nancy made her statement, one of the players had enough information to declare and win the game. Which player declared?

Yes, there are enough clues to solve this! But a word of caution — the solution to the puzzle *only* involves answering the question, “Which player declared?” There may not be enough information to give a more complete answer….

Good luck! In the next installment of Beguiling Games, I’ll give the solution to this logic puzzle, and give a geometrical two-player game to analyze as well. Happy solving!

]]>