# How to Graph Any Picture

If ever you have a bored minute, I'd recommend an unusual form of entertainment. It resides on an otherwise academic, mathematics-laden website known as Wolfram Alpha.

Type “Banana curve” into the search bar.

For those with more demanding artistic sensibilities, you might want to try “Severus Snape-like curve.” Or there's always the "first" and "second" "Albert Einstein curves." And hey, if you aren’t inclined to put in the extra seven seconds of work to satisfy your curiosity, here’s a picture of the “Simba-like curve”:

###### (http://m.wolframalpha.com/input/?i=simba+curve&x=0&y=0)

Math doesn’t seem so unartistic after all, now, does it? But how, exactly, does one pull off these visual feats with only graphing software and the human brain?

At its core, a coordinate graph is a visual representation of the relationship between numbers or variables. But this works the other way around, too: The formulas are a mathematical representation of the images they produce when graphed. This perspective suddenly offers a whole new slew of possibilities, as images can now be produced with only numbers, symbols, and graphing software.

At this point, this might sound vaguely familiar to a designer or digital artist. Doesn’t vector illustration software, like Adobe Illustrator, use math? Yes, and in many ways, it’s a similar idea. The user inputs an image, be it a simple line, some typography, or a complex sketch, and the program stores this image as mathematical equations and geometric shapes (called geometric "primitives," because they are the most basic components the program can handle).^{[1]} This reliance on mathematics is what makes vector illustrations infinitely scalable.

This brings us to a basic example of generating an image with a graph: the batman curve. This image was popular on the internet in the good ole’ days, way back in 2011. But despite its outdated nature as a meme, it serves as a timeless example for how combining mathematical functions can create an aesthetically recognizable and even attractive image. The original creator of the graph was a math teacher, J. Matthew Register, who aimed to inspire his students about math.

###### (http://santacruzmathguy.tumblr.com/image/8270375482)

When breaking down the equation, essentially, each of the terms in parentheses represents a different set of lines in the batman graph. For example, the very first term (the variables in the first set of parentheses) is the bat’s outer wings, based on the general formula for an oval. Unlike graphs that you study in Algebra in high school, which extend forever, these lines are manipulated using mathematical concepts such as imaginary numbers. This batman equation, however, cannot be graphed on a run-of-the-mill graphing calculator. It was designed for a more robust graphing software, called Mathematica, although the TI-89 can still draw some pretty robust pictures (see related links below).

In theory, this graphing method can be used to generate any significantly simplified image on a coordinate grid. However, it’s time consuming and subjective—Mr. Register cites a five or six hour time frame for creating his original equation.

But there is another way, one that makes the complex Wolfram Alpha illustration curves, such as the “Simba-like” curve above, possible. It’s based on something called a Fourier Transform, which is used to write any function as a sum of sine and cosine functions. I was originally introduced to the Wolfram Alpha graphs and the basics of the math behind them by my AP Physics professor, another teacher who, like Mr. Register, cared deeply about the educational experience and fundamental understanding of his students.

The Fourier Transform is an extension of the Fourier Series, a calculus concept that explains how any periodic (AKA repeating) function can be written as a sum of sines and cosines (sometimes an infinite number of sines and cosines). The study of Fourier Series and ways of manipulating them is an entire field of mathematics, known as harmonic analysis, because it turns out that sines and cosines can be useful beyond just exasperating trigonometry students. The Fourier Transform was discovered by none other than one Jean Baptiste Joseph Fourier, who in 1822, after a series of papers, published a book on the mathematics of heat. He was the first person to mathematically represent heat diffusion; he was also the inventor of the notation for definite integrals.^{[2]}

Fourier Series approximate a function, and each "step" in the process—each additional sine or cosine function—brings the approximation closer to whatever function is being replicated. This is why the series can be infinite; the approximation gets better and better without ever *trul**y *becoming accurate. The whole process looks something like this:

###### (https://giphy.com/search/fourier)

Returning to the Fourier Transform: Not to be confused with Fourier Series, the Fourier Transform is a mathematical tool which decomposes a function into a set of sinusoids, or periodic functions. This comes in handy because these periodic functions can then be written as sines and cosines using the Fourier Series. Yes, you read that right: Any mathematical function can be created by adding up variations of *sin(x)* and *cos(x)*.

The Fourier Transform is rife with practical applications in science and engineering, particularly because the real world has fewer problems of continuity and convergence than theoretical mathematics. And once you can use the Fourier Transform to turn any function into sines and cosines, well, infinity’s the limit (just kidding, the limit of *sin(x)* as x goes to infinity does not exist).

To take the bizarre ubiquity of sines and cosines even further, a graph is not the only thing that can be converted to sinusoids using the Fourier Transform. The mathematical tool is also used in processing images. To understand how this is possible, one must return to the basics of what a periodic function is. The generic form reads like *Asin(bx)+c*, where each coefficient (A, b, and c) describes a different characteristic of the graph. In this format, A is the amplitude, b tells you the period, and c is the phase shift. By using analogous information, the pixels in an image can be “encoded” into a sinusoidal function. For example, a pixel’s “intensity” corresponds to the amplitude (A) of a sine function, while the pixel’s “location” is the phase shift (c).^{[3] }In this manner, the Fourier Transform creates a unique representation of the whole image. There’s only one Fourier Transform for every image, and vice versa, only one image for every Fourier Transform. In essence, every digital image ever created corresponds to a string of sinusoids; this mathematical tool is just as rich and varied as digital photography and art.

If you look back at any of the Wolfram Alpha picture curves, you will see that the equations were dizzyingly long lines of—you guessed it—sines and cosines. The Fourier Transform makes all of those graph images possible. And the fascinating thing is that in the end, this particular branch of mathematics is after the same thing as many parts of design: finding the best representation of a visual phenomenon. The specifics differ wildly, but perspective tricks and line weights are tools in much the same way calculus and cosines are.

Beyond the novelty graphs on Wolfram Alpha, there have been a few attempts to harness the Fourier Transform for more artistic purposes. One of the more fascinating I found was an (apparently obsolete or never-released) how-to-draw app called “Draw Anything.” The app attempted to teach its users how to draw any uploaded image, using the Fourier Transform. Each "step" in the app's generated how-to-draw tutorial would be a step in the Fourier Transform approximation. The idea is a good one—marry math and drawing, go from simple to complex the same way one would draw anything. It is clear, however, that it was developed by someone more interested in Fourier Series than in drawing, because the simplest phase of a Fourier Series looks nothing like the way a drawing is typically constructed.

Sines and cosines are unlikely to magically turn any designer into a math nerd, just like a pretty graph is unlikely to magically turn any mathematician into a painter. But sinusoids are far more beautiful than one might expect. In essence, every painting, photograph, or scene that has inspired you is one Fourier Transform away from being an equation on a screen. They say a picture is worth a thousand words; I’m not sure who *they* are, although I’ll bet they’re paid to draw things. But if it is the case that a picture is worth a thousand words, then, well, so is a function. They match up, after all—line by line, pixel by pixel.

### Still curious?

*If you’re fascinated just by observing these Fourier Transform graphs, there’s a lot more where that came from. Try the Wolfram Alpha page about Popular Curves here, or see a complete list of the named curves on Wolfram Alpha here.*

*To see a full, detailed explanation of the Batman-curve development process, see Mr. Register’s original blog posts here, or another walkthrough of the process here.*

*For a batman equation that can be graphed on a standard TI-89 calculator, along with TI-89 equations for many other images, try here.*

*For a beautifully clear in-depth explanation of the Fourier Transform, and much of the related math, check out http://www.thefouriertransform.com/.*

*To stay up-to-date on M•A•D Symmetry and learn some weird facts to impress your friends with, use the sign-up form below!*