October 5, 2012 — Vitaliy Kaurov, Technical Communication & Strategy

On early Monday morning I noticed an interesting question posted on *Mathematica* Stack Exchange titled quite innocently “xkcd-style graphs.” Due to the popularity of Randall Munroe’s xkcd web comic, I expected a bit more than average of about ten or so up-votes, a few bookmarks. Little did I know. Spontaneously emerging viral events are hard to predict, so if you are lucky to catch one, it is fascinating to watch its propagation across the web and the growth of its ranks. In a matter of two days, this post received more than 100,000 views, 200 up-votes, and 150 bookmarks; produced responses and similar posts across other Stack Exchange communities; triggered a small tornado on Twitter; and was discussed on *Hacker News* and *reddit*. For convenience, I repeat Amatya‘s original post and example xkcd image here:

“

I received an email to which I wanted to respond with a xkcd-style graph, but I couldn’t manage it. Everything I drew looked perfect, and I don’t have enough command over Plot Legends to have these pieces of text floating around. Any tips on how one can create xkcd-style graphs? Where things look hand-drawn and imprecise. I guess drawing weird curves must be especially hard inMathematica.”

June 28, 2012 — Vitaliy Kaurov, Technical Communication & Strategy

I was browsing *Mathematica* user communities for original projects and came by the following question: “How can I calculate a jigsaw puzzle cut path?” Such creative problems are in abundance at our user forums, the Wolfram Demonstrations Project, and *The Mathematica Journal*, which tells me that *Mathematica*, at its heart, is a conduit for creativity: it’s a programing language that likes the challenge of convoluted problems and inspires elegant, often unexpected solutions.

In its essence, a jigsaw puzzle is a tiling or tessellation, which means there are no gaps or overlaps between the pieces. Moreover, every piece is unique and has a definite place in the puzzle. Uniqueness is achieved by making a piece be a part of a large image, have a specific shape, or a combination of these. There are many approaches to producing such patterns. For instance, this single mathematical formula from our graphics examples produces a beautiful tessellation:

However, since this question was asked on *Mathematica* Stack Exchange, a young, modern technical Q&A site, it was very specific in accordance with the community rules. Here are the author’s requirements:

- All pieces must be unique to preclude placing a piece in the wrong spot.
- Pieces must be interlocking such that each piece is held by adjacent pieces.
- It must be possible to generate different paths (sets) for a specific shape that are not merely rotations or reflections of the first.

Additionally, the author of the question notes that he seeks original designs alternative to typical mass-produced shapes.

April 5, 2012 — Paul-Jean Letourneau, Senior Data Scientist, Wolfram Research

In Stephen Wolfram’s recent blog post about personal analytics, he showed a number of plots generated by analyzing his archive of personal data. One of the most common pieces of feedback we received was that people wanted to know how they could perform the same kind of analysis on their own data. So in this blog post I’m going to show you how to analyze your email the same way Stephen Wolfram did.

Naturally, we did all the data cleaning and analysis for Stephen’s data in *Mathematica*, so we’ll be using *Mathematica* for everything here as well. All the code can be downloaded here.

Let’s start with that really cool diurnal plot Stephen did of his outgoing email. This plot shows the date and time each email was sent, with years running along the *x* axis and times of day on the *y* axis:

January 11, 2012 — Jon McLoone, International Business & Strategic Development

*UPDATE: The solution to the puzzle and more comments from Jon have been added at the bottom of the post.*

On the long flight to the recent Wolfram Technology Conference, I ended up on the puzzle page of a newspaper. My attention was drawn to a word ladder puzzle, where you must fill in a sequence of words from clues, but each word differs from the previous by only a single letter. Here, for example, is a simple puzzle already solved:

best | from a position of superiority or authority |

bast | strong woody fibers obtained especially from the phloem of from various plants |

bash | a vigorous blow |

bath | a vessel containing liquid in which something is immersed (as to process it or to maintain it at a constant temperature or to lubricate it) |

math | a science (or group of related sciences) dealing with the logic of quantity and shape and arrangement |

I wasn’t going to do a blog entry on this, as it is a very similar task to my “Exploring Synonym Chains” post that I wrote some time ago, but that changed with a chance conversation at the (excellent) Technology Conference. Proving that one never stops learning, Charles Pooh, one of our graph theory developers, pointed out to me that my synonyms item could have been done much better. I had broken one of the very rules that I wrote about in my “10 Tips for Fast *Mathematica* Code” entry—”Use built-in functions.” I had effectively re-implemented the built-in *Mathematica* commands `GraphPeriphery` and `GraphDiameter`.

So, armed with these two new functions, let’s find the longest word ladder puzzle that can be made using *Mathematica*‘s English dictionary.

December 7, 2011 — Jon McLoone, International Business & Strategic Development

When people tell me that *Mathematica* isn’t fast enough, I usually ask to see the offending code and often find that the problem isn’t a lack in *Mathematica*‘s performance, but sub-optimal use of *Mathematica*. I thought I would share the list of things that I look for first when trying to optimize *Mathematica* code.

**1. Use floating-point numbers if you can, and use them early.**

Of the most common issues that I see when I review slow code is that the programmer has inadvertently asked *Mathematica* to do things more carefully than needed. Unnecessary use of exact arithmetic is the most common case.

In most numerical software, there is no such thing as exact arithmetic. 1/3 is the same thing as 0.33333333333333. That difference can be pretty important when you hit nasty, numerically unstable problems, but in the majority of tasks, floating-point numbers are good enough and, importantly, much faster. In *Mathematica* any number with a decimal point and less than 16 digits of input is automatically treated as a machine float, so always use the decimal point if you want speed ahead of accuracy (e.g. enter a third as 1./3.). Here is a simple example where working with floating-point numbers is nearly 50.6 times faster than doing the computation exactly and then converting the result to a decimal afterward. And in this case it gets the same result.

September 9, 2011 — Jon McLoone, International Business & Strategic Development

As a change from my usual recreational content, today I thought I would describe a real *Mathematica* application that I wrote. The project came from my most important *Mathematica* user—not because she spends a lot of money with Wolfram Research, but because I am married to her!

Her company, Particle Therapeutics, works on needle-free injection devices that fire powdered drug particles into the skin on a supersonic gas shock wave. She was trying to analyze the penetration characteristics on a test medium by photographing thin slices of a target under a microscope and measuring the locations of the particles.

The problem was that her expensive image processing software was doing a poor job of identifying overlapping particles and gave her no manual override for its mistakes.

Faced with the alternative of holding rulers up to her screen and recording each value by hand, I promised that I could do better in *Mathematica*, with the added advantage that now her image processing tool would be integrated into her analysis code to go from image file to report document in a single workflow.

July 28, 2011 — Christopher Carlson, Senior User Interface Developer, User Interfaces

Eons ago, plants worked out the secret of arranging equal-size seeds in an ever-expanding pattern around a central point so that regardless of the size of the arrangement, the seeds pack evenly. The sunflower is a well-known example of such a “spiral phyllotaxis” pattern:

It’s really magical that this works at all, since the spatial relationship of each seed to its neighbors is unique, changing constantly as the pattern expands outwardly—unlike, say, the cells in a honeycomb, which are all equivalent. I wondered if the same magic could be applied to surfaces that are not flat, like spheres, toruses, or wine glasses. It’s an interesting question from an aesthetic point of view, but also a practical one: the answer has applications in space exploration and modern architecture.

June 8, 2011 — Jon McLoone, International Business & Strategic Development

Back in 1988 when *Mathematica* was just a year old and no one in my university had heard of it, I was forced to learn Fortran.

My end-of-term project was this problem: “A drunken sailor returns to his ship via a plank 15 paces long and 7 paces wide. With each step he has an equal chance of stepping forward, left, right, or standing still. What is the probability that he returns safely to his ship?” I wrote a page or so of ugly code, passed the course, and never wrote Fortran again. Today I thought I would revisit the problem.

We can code the logic of the sailor’s walk quite easily using separate rules for each case. Firstly, if he is ever on the 16th step or already on the ship, then he is safely on the ship the next time.

June 1, 2011 — Andrew Moylan, Technical Communication & Strategy

Recently I found myself reading about “subitizing”, which is the process of instinctively counting small sets of items in a fraction of second. For example, try quickly counting a few of these:

The Wikipedia article indicates that you can nearly always correctly count four or fewer items in a small fraction of a second. Above four, you start to make mistakes. I wanted to test this claim in *Mathematica* (using myself as the test subject). I decided to create a simple game in which small groups of items are momentarily displayed on the screen, after which players estimate how many they saw.

December 9, 2010 — Jon McLoone, International Business & Strategic Development

I just published a *Mathematica* package that provides an alternative, richer implementation of units and dimensional analysis than the built-in units package. You can get it here. Aside from being a really nice extension to *Mathematica*, it is also an interesting case study in adding a custom data “type” to *Mathematica* and extending the knowledge of the built-in functions to handle the new “type”.

First I have to explain the point by answering the question, “What’s wrong with the built-in units package?” Well, there is nothing actually wrong with it, it just doesn’t apply *Mathematica*‘s automation principles. It can convert between several hundred units and warn if a requested conversion is dimensionally inconsistent. But give it an input like…

and it does nothing with it until you specify that you want the result in a specific unit. The core reason is that it doesn’t teach the system, as a whole, anything about units, or even that the symbol “`Meter`” is any different than the symbol “x”. All of the knowledge about units and `Meter` in particular is contained in the `Convert` command.