A Markdown Syllabus

Instead of maintaining my syllabus in HTML this semester, I decided to try Markdown, a “a text-to-HTML conversion tool for web writers.”1 Markdown provides simple, readable formatting syntax for plain text files which can then be converted to various other formats, in particular, HTML.

Markdown allowed me to keep my syllabus clean and readable while also having various formatting (italics, bold, links, etc). Take a look for yourself. I actually used an extension called Multimarkdown which permits, among other things, tables.

With a few keystrokes in Textmate, I can convert the Markdown file to an HTML file ready to be uploaded to the web. Notice the fourth line in the Markdown file says style: style.css. That tells the Markdown interpreter to add a line of HTML that calls the stylesheet style.css. You can see my simple CSS file here.

With Multimarkdown, you can also convert Markdown formatted files to PDF and LaTeX.

If you’re going to use tables in Multimarkdown, check out this Python script that automagically reformats the table to fit the contents. That’s how I got my table looking so pretty with a few keystokes in Textmate.

|:-----|:------|:----------------------------|:---------------------|
| Week | Class | Lecture Topic               | Book Sections        |
| 1    | 1     | Substitution Rule           | 5.5, 5.6             |
| -    | 2     | Partial Fractions           | 5.7, 5.8, Appendix G |
| 2    | 1     | Approximate Integration     | 5.9                  |
| -    | 2     | Improper Integrals          | 5.10                 |
| 3    | 1     | Areas, Volumes              | 6.1, 6.2             |
| -    | 2     | Volumes                     | 6.2, 6.3, 6.4        |
| 4    | 1     | Average Value of a Function | 6.5, Page 429-430    |
| -    | 2     | **Test 1**                  | 6.6                  |

I won’t be teaching again for a while, so it’s hard to say if I’d use Markdown again. If I do, I need to figure out how to streamline my upload process. I’d like to be able to save, convert to HTML, and upload with a single command.

Laura McLay just posted about using Google Docs in teaching. A Google Doc shared with the whole class might be an even easier way to maintain a syllabus.

  1. http://daringfireball.net/projects/markdown/ []

Calculus Haikus and Limericks

I offered my calculus students bonus points to write a limerick or haiku on their final exam. I got some great answers! And the students seem to enjoy it.

My favorite limerick (on improper integrals):

An integral has bounds from zero to one
You finish the problem and think you are done
Then your mind double checks
The equation is one over x
And the improper integral has a different sum

My favorite haiku gives the formula for integration by parts:

Int of mu dv:
Equal to mu v minus
Int of v d mu

Here are some other good ones:

Doing Integrals…
Oh How I shall miss thee, Calc!
Goodbye, It’s been real?

Calculus is hard
Derivative and limit
¡Yo no se hombre!

MacLaurin Series
is an infinite series
Centered at zero

Calculus is great
I’m sure I’ll use this in life
Or maybe I won’t

Studying ’til 5
And almost sleeping thru test
Was a real bad call

Finding integrals
Is used to find area
Underneath the curve

Calc is fun to do
If you like to integrate
x from a to b

Calculus two, sigh
Why must you torment me so?
I thought we were friends

F of e to x
Derived is e to the x
Lone function like it

I like calculus
The feeling is mutual
But not all the time

Integrals are fun
u-sub can be tricky… yes!
Don’t forget plus C

Calculus is hard
Eight A.M. is too early
Had a good time though

The ratio test:
If the limit equals one
Use another test

Does this series telescope?
For my sake, I truly hope
Comparisons are icky,
Integrals make me sickly,
Turns out the answer is nope. :-(

Here are a few from when I taught at UVA:

An integral is
A derivative reversed
Don’t forget constants!

Thanks to L’Hopital
We can use derivatives
to find a limit!

Find the area,
Between the two stated curves,
Using integrals.

Natural log of
Zero, does not exist, but
Ln of 1 doesn’t

Calculus is great
But only if taught by Tim
At U of V.A.

Teaching Students to Fail

I am teaching the dreaded calculus II this semester. I’ve known many students who flew through calc I in college (having taken calculus in high school) only to receive a reality check from calc II the next semester.

In the US, calc II often involves a significant section on “techniques of integration” where students learn techniques such as partial fractions, trig substitutions, integration by parts. Unlike much of differential calculus, which is taught in calc I, and unlike much of the math taught before college, integration is harder to do algorithmically. That is, a calc II professor cannot simply outline surefire steps guaranteed to give an antiderivative for any function.

The inimitable Robert Ghrist explains it this way in his “funny little calculus text“:

Of course, algorithms for computing many antiderivatives do exist (and are used in Maple, Mathematica, and Wolfram Alpha), but I’d be fired if I tried to take my undergrads through Symbolic Integration I: Transcendental Functions.

Instead, calculus II teachers teach a handful of methods and attempt to teach students intuition for where to use what technique. Even more important, I try to teach my students the skill of trying a method, seeing that the method does not work, then trying something else. Try-fail-try-fail-try again.

I do not think that high school students learn that skill—a skill vital to success not just in calc II, but in every discipline requiring analytical problem solving. Yesterday, my adviser and I were discussing the first big research problem that I’ll be tackling this summer. He noted that our first attempt at solving a massive problem would probably fail; they usually do. Fortunately, I’ve been failing at solving problems at least since taking number theory with Dan Krider in 2003. I know what Edison meant by, “I have not failed. I’ve just found 10,000 ways that won’t work.”

I hope my students are learning how to fail and how to try again. However, I think that kids need to learn earlier. High school assignments should not be set up for students to succeed the first time, every time. Somehow, teachers need to allow students to take risks, learn from their mistakes, and rebound.

I’d love to hear feedback from students who are learning these lessons and teachers trying to teach them.

Animating Plots in Mathematica

A friend asked me how to animate a polar plot graphing in Mathematica. It’s really easy. The Animate and Manipulate commands added in version 6 are a huge step in interactive mathematical visualizations.

The easiest way to visualize it is to have the upper plot range vary from a 0+ϵ to 2π.

Animate[
  PolarPlot[2 Cos[4 x], {x, 0, y},
    PlotRange -> {{-2, 2}, {-2, 2}}],
  {y, 0.001, 2}
]

But, I thought this would be a good opportunity to try out Wolfram’s recently introduced Computable Document Format which makes Mathematica files interactive in the web browser. Instead of having to buy an expensive Mathematica license to play with interactive Mathematica tools, CDFs are accessible right from the browser.

If you haven’t already, you’ll have to install the CDF Player (free from Wolfram) to view my animation.1 Try clicking the different functions to see their polar plots drawn.

Here’s code which you should be able to copy and paste right into Mathematica.

Manipulate[
  PolarPlot[f[\[Theta]], {\[Theta], 0, \[Mu]},
    PlotRange -> {{-2, 2}, {-2, 2}}
  ],
    {{f, 2 Cos[4 #] &, "Function"},
    {
      Sin -> "r=Sin[\[Theta]]",
      2 Cos[4 #] & -> "r=2 Cos[4\[Theta]]",
      2 Cos[16 #] & -> "r=2 Cos[16\[Theta]]"
    }, ControlType -> SetterBar},
  {\[Mu], 0.001, 2 \[Pi]},
  ControlType -> Animator,
  AppearanceElements -> None
]
  1. Wolfram has recently made their massive collection of Demonstrations interactive through the CDF format. This is a great feature for math teacher and students. []

My Email Analytics

Last month, Stephen Wolfram did a blog post on the Personal Analytics of his life. For years, he’s recorded every phone call, keyboard stroke, email, and step. He made beautiful graphs to show his activity over the years.

A Wolfram Alpha developer just posted a Mathematica notebook on the Wolfram blog allowing anyone to do the same email analysis that Wolfram did with any IMAP email account. Of course, I dropped what I was doing to try it out with my Gmail account.

At first, it failed to finish processing my incoming email because the JVM ran out of memory. It took me a while to figure out how to tell JLink to let Java have more memory.1

Here’s a plot of emails sent by from Gmail me over the last six years:

I started using Gmail regularly after I graduated from college in 2008 (once my college Exchange-based email account was gone).

My emailing was noticeably sparse from May 2008-May 2009. During that time I was a teacher, and I didn’t spend nearly as much time on a computer as I do now. You can also see a gap during the summer of 2011. I was working at Kiva Systems at the time and primarily used my company email.

On the horizontal axis, you notice I’m pretty silent between 11 PM and 7 AM. I need my sleep, and I never work at night! My emailing is light from 6-9 PM too.

Here’s a graph of my email received over the past six years. It comes in pretty heavy from 8 AM to midnight!

The thick line just under 6 AM is the Google Calendar email updates I used to get every morning. I stopped getting those once I got an iPod Touch this past Christmas. I can’t remember what email used to come at 3 AM for a few years.

This next graphic shows the average number of emails I receive per day for each month. My amount emailing  ramped up once I started using email. Notice the downward trend on incoming emails recently: I’ve been unsubscribing from unnecessary mailing lists and circulars. My emailing had pretty serious peak last May right before I moved to Boston. Not sure why.

Here we have a histogram of the time at which I send emails. Apparently I’m most likely to send an email just after 10 PM. I wouldn’t have guess that. Don’t expect to hear from me after midnight!

As a good operations researcher, I wondered if I received email according to a Poisson process. I pulled the email time stamp data into R. I get email pretty steadily between 8 AM and 10 PM. I looked at the emails that arrived in that interval since September 2011. The mean interarrival time is 0.53 hours. The standard deviation is 0.92. If it were a poisson process, interarrival times would be exponentially distributed, and the mean and standard deviation would be equal.

Below is a histogram of the interarrival times of my emails. The red line is an exponential distribution with the rate set to 1 over the mean interarrival time of my emails. It’s not a terrible fit!2 One reason the email arrival rate might not be exponential is that I frequently have back-and-forth email conversations with people, which skews the distribution towards short interarrival times. I might do some more statistics later, but I have homework to do.

  1. ReinstallJava[CommandLine -> "java", JVMArguments -> "-Xmx4024m"] []
  2. That’s not a official statistical statement! []

Average Area of a Random Hull

Yesterday, someone on MathOverflow asked

Consider n points generated randomly and uniformly on a unit square. What is the expected value of the area (as a function of n) enclosed by the convex hull of the set of points?

Someone quickly cited 2004 paper provides an analytical result for the cases where n=3 and n=4:

For n=3 the expected value is 11/144 and for n=4 it is 11/72.

This is certainly a nontrivial result. However, the value can be approximated by generating a large number of random points, finding the area of the convex hull, and averaging the areas. Of course, finding the convex hull and the area of the convex hull of a set of points requires a little work.

Mathematica provides functions for generating random points and finding the area of the convex hull of a set of points quickly. As a result, I was able to perform a Monte Carlo simulation for the n=3 and n=4 case in a couple of lines of Mathematica code:

Sampling 5000 cases for each returned results fairly close to the predicted average.

 

 

Operations Research, Machine Learning, and Optimization

Over the past 18 months, I’ve been slowly learning some machine learning. One thing I’ve noticed is that most of the math in machine learning is optimization. Regression is typically minimization of some error term. Support vector machines are a quadratic optimization problem with linear constraints. Learning a neural network is simply solving a nonconvex optimization problem. Clustering often takes the form of expectation-maximization. I’m currently learning Bayesian network structure learning which is an extremely difficult combinatorial optimization problem.

Yesterday on Twitter, I commented that I am surprised at how little operations research people and machine learning people talk. Most of the math of OR is, like machine learning, optimization. All the same theorems apply, and we use many of the same algorithms; we just apply them in different ways.

I got helpful feedback from the nerds that follow me. Jeff Linderoth pointed to the recent book Optimization for Machine Learning by his colleague (et al) Stephen J. Wright at University of Wisconsin, Madison. From what I can tell, Wright is an OR guy in a computer scientists clothing. There’s a two-hour lecture by Wright on the same topic that I look forward to watching.

Jeff also pointed to the work of his colleague Ben Recht who’s looking at the optimization problems in ML from a theoretical standpoint. Paul Kerl linked to Jorge Nocedal‘s work at Northwestern. Nocedal and Recht seem to have feet in both worlds. John Myles White noted that the legendary optimizer Stephen Boyd came to the New York Academy of Science’s Machine Learning event last year.

I also came across a 2006 paper on The Interplay of Optimization and Machine Learning Research. The authors note some difference between an OR and ML perspective on optimization:

We observe that the qualities of good optimization algorithms from the machine learning and optimization perspectives can be quite different. Mathematical programming puts a premium on accuracy, speed, and robustness. Since generalization is the bottom line in machine learning and training is normally done off-line, accuracy and small speed improvements are of little concern in machine learning. Machine learning prefers simpler algorithms that work in reasonable computational time for specific classes of problems.1

A bigger question might be where optimization lies as a discipline. Since I’ve been in OR, I’ve always considered optimization as a subfield of OR. But as I read applied OR literature, I find it jarring to see the details of solving a difficult optimization problem mixed with the application of the solution to a real world problem.

Of course, both ML and OR require practitioners to understand how the algorithms work. Optimization problems are hard, and a black box solution rarely works for any of us. But perhaps optimization will become a field of its own that OR and ML can both feed from instead of the two working independently.

  1. I haven’t read the whole paper (that’s from the abstract), but I’m not entirely convinced that is true. Modern machine learning often requires large scale problems to be solved quickly on-line, while optimizers often solve a problem  offline and speed is negotiable. []

Stephen Wolfram’s AMA

Stephen Wolfram, of Wolfram Research and Mathematica fame, did a Q&A (i.e. AMA) on Reddit today. I just enjoyed reading through his answers. A few interesting answers stood out to me.

Someone ask Wolfram’s opinion on P=NP. He thinks it’s undecidable.1

Some smart aleck threw the Riemann hypothesis at him. Interestingly, Wolfram also suspects this is undecidable.2

One questioner asked about open sourcing old versions of Mathematica. Wolfram responded very winsomely, in my view. I didn’t know that they’ve thought about making the core language more freely available. I’d like to see that.

His most interesting answer is his opinion on Matlab. He argues that Matlab has remained matrix-centric when so much of contemporary mathematics goes beyond that. “In the complete web of algorithms in Mathematica, things that can reasonably be represented as numerical matrices are perhaps 5 or 10% of the total.” However, Wolfram believes that Mathematica isn’t outdone by Maple in the realm of matrices.

Wolfram relays that a major goal of Mathematica is “to make a single coherent system in which one can work, and in which everything fits nicely together.” I argued that that’s one thing they’ve done quite well.

I appreciate Wolfram doing this. I continue to be optimistic about Mathematica as a product, and I hope they have a bright future ahead of them.

  1. See the Wikipedia page on undecidability for more. []
  2. Both the Riemann hypothesis and P=NP have been around for many years and have a big bounty on solving them: http://www.claymath.org/millennium/. []

The Spelling Corrector that Got Me Interested in Machine Learning

Although I was a computer science minor, I’d never heard of statistical machine learning until after college. Now I dabble in machine learning on the side. In the long run, I’m interested in studying the intersection of operations research and learning, i.e. intelligent optimization systems.

Two years ago, I stumbled across Peter Norvig’s essay How to Write a Spelling Corrector. Google is a notoriously good spelling corrector; just try googling “spellign.” I find that Google knows what word I’m trying to spell even when an application’s built-in spell check fail. Norvig explains how to use Bayes theorem to write a pretty-good spelling corrector in 21 lines of Python.

In college, I had good grounding in probability and computing, but I don’t recall having seen the two mixed so elegantly. I’m pleased to now know that Norvig was only scratching the surface! This week, I’ve been watching Sebastian Thurn’s lectures on Kalman Filters for AI. Probabilistic techniques for filtering noisy data can be used, for example, in a robot keeping track of objects moving around it.

Mathematica: A Love Story

As an undergraduate, our math department used Wolfram Research’s Mathematica heavily for instruction in a number of classes. Initially, I found it perplexing and frustrating. While most of my peers remained in that state (and never used it again after those classes), I soon found myself ordering and reading An Introduction to Programming with Mathematica.

Seven years later, I find myself using Mathematica almost daily. As a student, it is one of the most helpful tools at my disposal, and it has saved me countless hours of tedious computation by hand. I’m not sure I can express all the ways in which I appreciate it, but I hope to share some.

I admit that I primarily use Mathematica as a glorified calculator. Most of my code is single use code to help me with a homework assignment. I have written some longer code for class projects, but rarely more than a few hundred lines. However, for the work that I have had over the past seven years, it is exactly the right tool, and I don’t know of any other language which comprehensively offers all the features I need within its core language.

One other note to the Redditors and cynics (but I repeat myself): I’m not recommending or encouraging programmers to jump ship from their main languages to Mathematica. I’m not suggesting that Mathematica doesn’t have any shortcomings. I’m not arguing that Mathematica is good for everything. I’m well aware that Mathematica is an expensive, closed platform. I’m well aware that Mathematic has the worst undo ever. I’m not writing an advertisement or getting paid by Wolfram. I’m simply shared the story of a program that has become an invaluable part of my schooling.

1. Powerful Symbolic Computations

Perhaps the thing Mathematica is most well-known for is symbolic computations. The oldest Mathematica file I have on my computer is a single line of code that I apparently used on a differential equations quiz in 2005. In it, I did a partial fraction decomposition: the bane of calculus 2 students, but easy for a computer.

alovestory_1.gif

alovestory_2.gif

One of the benefits of Mathematica, is the elegance of typesetting in both the input and the output. Wolfram has taken great care to make Mathematica an aesthetically excellent experience, and I’m grateful for that.

These days, I avoid doing algebraic manipulations by hand at all costs. It’s not worth it to me to risk making errors that might trickle down into my work. I let computers handle such things for me. Thus, when I’m doing homework, I usually have a notebook open filled with one-off expressions like

alovestory_3.gif

alovestory_4.gif

Of course, it can solve much harder problems too. Integration is no problem. Here’s a triple integral I solved in my electricity and magnetism class sophomore year. (I wish I remembered what it all means.)

alovestory_5.gif

alovestory_6.gif

The output is messy because Mathematica tried to solve the integral as generally as possible. We can get a more clear answer by clarifying some assumptions we’re making about the parameters.

alovestory_7.gif

alovestory_8.gif

2. Functional Programming

Like R, Mathematica allows procedural programming.

alovestory_9.gif

alovestory_10.gif

alovestory_11.gif

However, again like R, Mathematica is really built for functional programming. Wolfram has a great tutorial on the topic, but let me share a brief example from my own use.

On a homework assignment this week, I wanted to measure the total tardiness for various schedules in a single machine problem. Each of the four jobs had a total processing time, given by {2,4,6,8}, and a due date {4,14,10,16}. The tardiness of a job for a given schedule (i.e. ordering of the jobs) is 0 if the job is completed on time and how late it is otherwise. First I set processing time and due dates for the four jobs:

alovestory_12.gif

Any permutation of the job indices {1,2,3,4} gives a valid schedule. Suppose we want to know the total lateness of the schedule x={1,4,3,2}. The ordering of processing times is given by p[[x]] so the time when each job is completed is a running total of the processing times:

alovestory_13.gif

alovestory_14.gif

The lateness of each job is defined by the completion time minus the due date:

alovestory_15.gif

alovestory_16.gif

To get the tardiness, we want the max of the lateness and zero. There are a number of ways to do this, but one is to apply a max function to each element of the list:

alovestory_17.gif

alovestory_18.gif

(The # and & are part of Mathematica’s notation for pure functions.) Or, more succinctly,

alovestory_19.gif

alovestory_20.gif

In a non-functional language, this would have required a for-loop and several lines of code. In a functional language, it naturally fits into a single line. Getting the total tardiness adds no more complexity:

alovestory_21.gif

alovestory_22.gif

since % returns the last line evaluated.

This is only a simple example of a functional operation in Mathematica. Expressions can become much more complex. All my Mathematica code is littered with functional expressions, but rarely will you see a for-loop or a while-loop in my code. And I like it that way.

Oh, and if you want to parallelize these operations: not a problem.

3. Optimization

As a student of operations research, I spend a lot of time solving optimization problems. Solving optimization problems of many flavors is built right into Mathematica. Solving linear programs given the matrices is easy with the LinearProgramming function. Because most of the problems I’ve solved up to this point have been “toy” problems for class, I can’t attest to Mathematica’s ability to handle large-scale problems, but they claim to be able to handle large problems. Mathematica’s ExampleData function gives easy access to many data sets, including NetLib.org’s LP problems. Mathematica could solve this problem with 6072 rows and 12230 columns in 60 seconds on my 11-inch Macbook Air.

alovestory_23.gif

alovestory_24.gif

The built-in solver certainly isn’t as robust as CPLEX or other commercial solver, but it does, at least, provide several solution methods.

I most often find myself using the Minimize and Maximize functions with explicit constraints:

alovestory_25.gif

alovestory_26.gif

In the future, I hope to do a post on using Mathematica as a pseudo-modeling language. You can see the documentation for a number of other optimization related functions.

Recently, I’ve been working with stochastic dynamic programming problems (i.e. Markov decision processes). Mathematica offers the easiest memoization I’ve ever seen in any language. Combined with functional aspects, I can solve dynamic programs with relatively little code.

4. Graphics

When I am doing school work, I want to be able to do complicated computations and then visualize the results quickly. Because of how tightly knit the native Mathematica graphics are built into the core language, I don’t have to go out of my way to do this.

Last semester, I wanted to demonstrate a Monte Carlo algorithm for navigating a maze. Over 200 iterations, a relatively simple solver (built, of course, in Mathematica) could find an optimal path through a 4 by 3 maze. for a report I was writing.

Working straight from the output of the solver, in about twenty lines of code, I output a grid showing candidate solution every other iteration (the green cells indicate cells where the action is optimal). Followed by an Export function, the graphic was ready to be included in my alovestory_27.gif file. All of this without having to open another program or import any graphics packages.

5. Documentation

Wolfram has been careful to write readable and thorough documentation for Mathematica. Though Mathematica is not free software, its 10,000+ pages of documentation are available online. Not only does the documentation for every function (usually including bullet points with Basic Examples, Scope, Generalizations & Extensions, Applications, Properties & Relations, and Neat Examples), it’s full of tutorials on various aspects of the language. Of you read the help inside of Mathematica, the files are simply notebooks, so the code can be evaluated within the documentation. I think you’d be hard pressed to find a language with better documentation.

6. Naming Conventions

If Mathematica wins one debate hands down, its naming conventions. By their own standards, “As with most Mathematica functions, the names are usually complete English words, fully spelled out.” If you know the mathematical name for something, you can probably guess the Mathematica form.

Stephen Wolfram wrote a blog post a few years ago on his personal role in naming Mathematica functions. Perhaps not too different from his late friend Steve Jobs, Wolfram desires intense control of the finest details of his products.

I just realized that over the course of the decade during which were developing Mathematica 6—and accelerating greatly towards the end—I spent altogether about 10,000 hours doing what we call “design reviews” for Mathematica 6, trying to make all those new functions and pieces of functionality in Mathematica 6 be as clean and simple as possible, and all fit together.

I think this has paid off.

Some people would complain about a language such an enormous number of named expressions, but Wolfram (the man and the company) have been so careful in constructing it that it doesn’t feel bloated.

7. Interactivity

In version 7, Wolfram introduced interactivity into Mathematica. The Manipulate function is one I have found extremely valuable. It allows you to parametrize an expression and adjust the parameters while seeing results in real-time. For example, you could use Manipulate to adjust the region over which a function is plotted:

alovestory_28.gif

alovestory_29.gif

A side benefit to the careful construction of the language is that functions with related behavior often have interchangeable expression lists. Manipulate can be replaced with Animate with no other changes.

alovestory_30.gif

alovestory_29.gif

Or Table for that matter:

alovestory_32.gif

alovestory_33.gif

8. Continual Development

Thankfully, Wolfram hasn’t given up on Mathematica. It’s been in development now for nearly 24 years. Mathematica 7 (released in November 2008) introduced interactivity features, access to many data sets, and built-in parallel computing, among other things.

Mathematica 8, released in November 2010, brought integration with Wolfram Alpha and free form input. I find myself using this frequently when I’m teaching calculus. For example:

alovestory_34.gif

alovestory_35.gif

Mathematica 8 also brought incredible probability computations. What’s the probability that a standard normal random variable is less than a Uniform(0,1) random variable? No problem.

alovestory_36.gif

alovestory_37.gif

The list of things new in version 8 goes on.

9. Comprehensiveness

A feature of Mathematica that is hard to articulate is the comprehensiveness of the features I’ve already mentioned plus many more. It’s a full featured programming language, but the core language also extends to the depths of applied and pure mathematics. Symbolic manipulation? Check. Numerical methods? Check. Abstract algebra? Check. Graph theory? Statistics? Visualization? Optimization? String Processing? Differential equations? Computational chemistry? Calculus? Check. Check. Check.

The comprehensiveness of Mathematica‘s functionality along with dynamic typing and functional programming allows me to write code to do complicated tasks very quickly. I love it.

Conclusion

No doubt, Mathematica has its limitations1: Worlds worst undo. Not object-oriented. Closed platform. Expensive. No autosave. No data frame structure.

However, for me, it’s an invaluable tool. Last semester, I saw a less computer savvy fellow graduate student writing out a huge table by hand. I don’t recall the name of what he was doing, but it was something to do with measuring the distance between permutations. I told him I could do it for him in a single line of Mathematica.

In just a few minutes I wrote him the following code. It ended up taking me more than one line, but I wrote the code much faster than he was generating it by hand. (His table was actually for the 4-permutation case, so it was 24×24 instead of 6×6.)

alovestory_38.gif

alovestory_35.gif

Using Mathematica for little things like this. It allows me to spend my time and brain power on the things that computers can’t handle.

I love Mathematica. And maybe you will too.

(I wrote this post in Mathematica. You can check out the notebook here.)

  1. I might follow with a post on that very point []
Page 1 of 212»