Mathcad Solution To XKCD Problem

Quote of the Day

I don't need time – I need a deadline.

— Duke Ellington, describing how he is motivated to get something done. I must admit that I need deadlines for writing, otherwise I would never get anything written.

Introduction

XKCD is a great comic strip by Randall Munroe that takes a quirky look at the world of science. Randall recently posted a set of questions for a substitute teacher to pose to a math class that were interesting and attracted the attention of some problem-solving enthusiasts.

I thought I would jump into the fray by solving the problem using Mathcad and also taking my first dive into Python.

Background

While this is a simple problem, it is interesting to see how different people approach it. Here are two other solutions that I recommend you read:

• Jon Peltier's Excel Solution

Jon is a world-class Excel expert (e.g. MVP) with a real gift for Excel charting. He attacks the problem using a standard spreadsheet approach and a Visual Basic for Applications (VBA) approach.

• Rhett Allain's Python Solution

Rhett wrote a Python-based solution that I used as the basis for my first Python program. I modified his routine to use trapezoidal integration instead of Euler, and I implemented a different scheme for the clipping the velocities.

Analysis

Figure 2 shows how I used Mathcad to solve the substitute teacher problem.

Figure 3 shows my graphical view of the solution.

Python Solution

I have never written a Python program before and this seemed like a great opportunity to learn. When I looked at Rhett's program, it reminded me a simplified form of Java – my usual programming language choice. So I quick ran through the Python course on Code Academy and loaded Python onto my Eclipse install.

Figure 4 shows my Python routine, which gave me the same results as Mathcad. Python seems a lot less wordy than Java – what were the Java folks thinking?

Figure 4: My Python Solution for the Substitute Teacher Problem.

Python Graphic Output

Figure 5 shows the output from my Python program. The results are the same as given by Mathcad.

Conclusion

This problem nicely illustrates how different tools can be used to solve a problem. In my case, I tend to use computer-algebra systems, like Mathcad and Mathematica, to experiment with different approaches to solve a problem. I only commit to software when I need more speed or the ability to handle large scale.

This entry was posted in General Mathematics. Bookmark the permalink.

2 Responses to Mathcad Solution To XKCD Problem

1. T says:

I may be missing something: In Figure 3, why doesn't the raptor's speed max out at 25 m/s?

• JammySquirrel says:

Simple: the raptor doesn't need to reach his top speed to catch such slow prey. He'll reach his top speed at t= 6.25. He'll have grabbed lunch before then.