# Exploring Creativity through Computer Algebra

Adding a computer algebra component to a calculus or linear algebra course can provide the perfect opportunity for students to explore creativity and the connections found between mathematics and other arts and sciences. I will illustrate this here with examples from music, poetry, sculpture and puzzles. While many mathematicians perceive math as a part of art itself, the following stories illustrate how these connections can be enhanced with the help of a mathematical computer algebra system. We will see how we can generate musical canons, find poem prototypes, realize mathematical objects as three-dimensional sculptures and analyze puzzles to reach interesting conjectures.

### Linear Algebra and Music

For a while now, we at Harvard University have added some form of musical component to the final Mathematica project in our linear algebra classes. For example, here is an exhibit from 2008. It was also amazing to see the creativity of students this year, as with this exhibit. One can always learn from students.

In our Spring 2018 workshop (you can view the slides here), I gave the following template for a musical canon, a type of song where instruments play the same melody at slightly different times:

[MP3] This simple example illustrates how one can join several music “tracks.” After reading student submissions, I learned that the repetitive part can be avoided by putting “None”. Here is a variation, where the instruments have also been replaced:

[MP3] Is the use of computers in generating music defeating the process of creativity? While one could certainly argue that way, one can also see the computer as an additional musical instrument, and as a tool for creative thought.

Let’s try to be creative by applying small changes to the code shown previously. The assignment for the constant n, for example, could be replaced by a function, which repeats after the period of the canon:

[MP3] A more sophisticated task would be to build three melodies A, B and C, which fit together, then build the canon with that structure (A, B, C).

By the way, also in single variable calculus, the connection between math and music is strong. Music can explain many calculus concepts, as seen in this PDF. As part of a Harvard Imitative for Learning and Teaching (HILT) project funded by a Hauser grant in 2013, we designed several interdisciplinary Math 1a lectures, which were then filmed by the BOK Center; these can be viewed here. Music compositions more closely related to calculus can be viewed on the Spring 2008 Mathematica music page. At that point in time, the music routines that export MIDI files were not yet developed in Mathematica.

### Markov Chains and Poetry

Music is not the only domain where one can experiment with art. In our explorations of math and creativity, we have also experimented with random poems. Nandy Millan from the University of Birmingham once wrote a poem generator in Java called A.D.A.M., which we translated a couple of years ago into the Wolfram Language for Mathematica. Here is a Mathematica version. We gave this file to students to modify in different ways (such as changing the vocabulary or the rules):

Here are some example poems that came about from this assignment. In the following poem, student Jorma Goerns used an adaptation of the Markov procedure shown in Mathematica to get ideas, then edited the poem so that it rhymes:

He rose passionately
To tackle today’s PSET
But then he thought eventually
“Oh, I should have stayed in bed!”
A golden sun was shining
His motivation dying
This function’s Fourier series
Remained oh so mysterious!
A deafening cry: Eureka!
Am I not a genius?
He opened Mathematica
And found the Fourier series.

There were many other creative approaches. Garrett Tanzer wrote a discrete Markov process that used a database of already existing poems to write a new one:

The wide world is wretched.
Speak thy dwelling-place.
Young winter by itself.
The fluttering storm is heaven’s hill.
Forgotten for his own element.
They brought her dreams.
In merriment upon the palmy beach.
Sing prison guards at dawn.
And watched the huddled and dolls.
And like ivy over the dawn.
Trembling with surprise. In air.
The sill of the day the present.
Moved in us, hatching marrow.

It is sometimes hard to see the difference between poems written by humans and text generated by a machine.

### Multivariable Calculus and Sculpture

In the multivariable calculus portion of classes, 3D printing has been a successful component for several years. I learned a lot from Elizabeth Slavkovsky, who wrote a thesis about the feasibility of 3D printing in the classroom. Read more about her ideas here.

In the fall of 2012, thanks to an Elson Family Arts Initiative grant, we were able to print some projects. For example, here is an example object made by Martin Reindl printed in steel. It cost about \$70 to print. In plastic, it would have cost \$11:

Here are some more galleries of student work:

### Computer Science and Puzzles

Computer algebra systems are great for attacking puzzles. It can feel a bit like cheating, but doing so still requires creativity; it is just creativity of a new kind. After all, one must be creative to write a program that solves a creative task.

Here is a puzzle posed by Anna Beliakova of the University of Zurich and Dmitrij Nikolenkov of Trogen, a high school in Switzerland:

Write down the numbers 1–16 in a row so that the sum of two arbitrary neighbors is a square number.

Using mindless force and writing all 20,922,789,888,000=16! cases to find the solution would be brutal. A more elegant way would be to define the graph where the numbers 1–16 are the vertices and where two vertices x,y are connected if x + y is a square. From there, we must find a Hamiltonian path. We can do that by hand, as 16 has been a boundary point, forcing the other numbers:

The solution is as follows:

We see that 16 + 9, 9 + 7, 7 + 2, 2 + 14, etc., are all squares. Assume now that you are a puzzle writer and want to determine for which size of puzzle this works:

After seeing the output, you might come up with the conjecture that {1,2,5,6,7,8,9,10,11,12,13,14,18,19,20,21,22,24} is the complete list of “square puzzles” that have no solution. I do not know whether this is true or not. But you can see that without the help of a computer, we could hardly have come up with a confident conjecture.

Here is a modification of that same puzzle:

Write down the numbers 1–32 in a circle so that the sum of two arbitrary neighbors is a square number.

This puzzle defines a graph in which for every edge (a,b), the sum a + b is a square. The task then becomes finding a Hamiltonian cycle in that graph:

Here is the solution:

After running the same experiment for arbitrary puzzles, we can ask that the smallest Hamiltonian cycle puzzle has a solution for n = 32 and that there is a solution for every n larger than or equal to 32. We are not aware of whether this question has been asked already, nor do we know how hard it would be to prove this.

Now, finding a solution to this particular puzzle for a larger value like n = 1,000 would be hard to do without a computer. The solution starts with 1 → 899 → 950 → 11 → 889 → 480…

By the way, William Rowan Hamilton came up with the idea of the Hamiltonian path when looking at the “Icosian game,” which asked puzzle-solvers to find a Hamiltonian cycle in edges of a dodecahedron. Hamilton’s puzzle was marketed but never became a commercial success. Even so, it became much more: the concept of the Hamiltonian path has enormous impact in mathematics.

### Be Creative

Creativity is a process that can be practiced. Everyone can be creative. Try it out for yourself and “write a little tune of music” or “create something that can be 3D printed” or “experiment with some mathematics to find an open problem that has not yet been asked.” You will find that these tasks become surprisingly doable with the help of a computer algebra system.