Why I use Mathcad

Flattr this!

A new blog member asked “Why do you use Mathcad?” in response to my most recent post about using some of the funds donated by visitors to the blog to help fund my research.

It’s a very good technical question, and one that deserves more than just a reply to the comment. So I’ll try to explain why here.

I build dynamic models of the economy using systems of ordinary differential equations. There are many programs that support this these days, from public domain programs like Scilab to commercial giants like Mathematica and Mathcad. I’ve tried most of them, and I’ve stuck with Mathcad for two reasons:

Its interface is very natural; and

Its error messages are easy to interpret.

I’ll try to illustrate this with simulations of the same system in both Mathcad and Mathematica. Firstly, here’s a successful output from Mathematica of my simplest endogenous money model with growth and a credit crunch:

And here’s the same model in Mathcad:

Though there’s much more that you can do with Mathematica graphs, I find the Mathcad display more intuitive–more like what a mathematician would write on a sheet of paper, which is precisely Mathcad’s design philosophy.

But the main difference comes with the next feature: the error messages the two programs generate when, as so often happens, you make a mistake in your early attempts to simulate a model. In this instance, I have typed “ss” where I meant to type “s” in a particular function. Here’s Mathematica’s reaction to that:

Huh? What does “NDSolve::ndinnt: Initial condition 400. ss is not a number or a rectangular array of numbers” mean? That’s a trivial example, and of course I already know, but when you’re crafting a complex model and make an accidental mistake, it can be non-trivial exercise to locate the error–even if it is in fact a trivial one like this.

Now here’s the same error in Mathcad, and the first stage of its reaction:

Ahah! I have an (as yet unidentified) undefined variable! I click on “trace error”, and get the next window. If there was a cascade of errors, the “Previous” button would be highlighted, but since there’s only one, when I shut this window down Mathcad puts the cursor right on the offending “ss” variable.

This makes developing and debugging a model in Mathcad an order of magnitude easier than in Mathematica. I know that Mathematica is the more powerful system, but that power comes at a cost of a much more opaque error correction interface.

If these errors were parsed by the program, so that it did what Mathcad did in identifying the source of the problem, then I could quite easily consider developing initially in Mathematica. There would be advantages here–notably the ability to export equations directly to TeX for journals that require that format, but many many others.

But until that happens, I make an engineer’s choice to choose the most effective tool rather than the most powerful or elegant one.

Bookmark the permalink.

32 Responses to Why I use Mathcad

  1. Steve Keen says:

    I’ll put a PDF of the Mathcad file up too for easier access.

    The model starts with a single sector and then expands to multiple, but looking at the paper I didn’t document all the steps to the latter as well as I might have (it’s more a book length thing in that case). So the PDF should help. I’ll amend the post and put a link on my research page.

  2. Arthur Dent says:

    Meanwhile I strongly recommend you checkout TexMacs and start using it for WYSIWYG and WYSIWYM preparations of elegantly typeset papers with mathematical formulae – both direct to .pdf and via LaTex. For Windows version I recommend the option to install the full Cygwin first so you can easily add other unixish software that it interfaces to and automatically typesets maths and graphical plots for.

    Here’s an example that includes TeXmacs display of “live” (algebraic) solutions of simple ODEs using Maxima (which is also available for Windows). It also interfaces direct to “R” which has comprehensive statistical stuff (free clone of “S”) highly relevant to economics and also to Matlab and Octave (free Matlab clone) with adequate numeric ODE solvers as well as to Sage (which itself interfaces to all 3 and SciPy numeric ODE solvers and matrix algebra etc and provides a superior combination environment).

    The TeXmacs/Maxima example in 4th screenshot above is pretty similar to what you could get directly with TeXmacs/Sage numeric solutions of ODEs and looks to me pretty clearly superior to your Mathcad example.

    Try TeXmacs first, simply as a general powerful scientific wordprocessor vastly superior to LyX et al and later add Sage. Even though Sage would be running on a virtual linux over windows it should still be just as easy and fast for it to communicate with Windows/Cygwin TexMacs as the interface is via network stack on “localhost” (and can also be made remotely accessible if you want).

    BTW QtOctave GUI interface for Octave similar to the Matlab desktop is also available for Windows.

    Likewise of course the normal “Notebook” browser interface to Sage is also via network to Firefox browser so despite the virtual linux for Sage itself you would be working entirely in your normal Windows environment apart from the initial hassles of setting it up.

  3. Steve Keen says:

    Thanks Arthur,

    I’ve had a quick look, and what I might do is try simple TexMacs under Windows first of all simply as a LyX alternate to get a feel for it, and then if it seems workable, use that when I start writing Finance and Economic Breakdown properly next year and then do a full installation. I have a spare PC right now so I might make that a full Linux base machine (next year) and try with that.

    For now I have to get this multi-sectoral stuff finished pronto, so working in what I know will be faster than learning a whole new system and restarting.

  4. Sam says:

    I used several math tools at work, and I use each one for the task it’s best suited for. Mathcad’s great for calculations like this, but where it falters is when you need to programmatically construct differential models (e.g. when you’re discretizing a PDE to a system of ODEs). In other tools you can construct the equations programatically, but in Mathcad you have to write them explicitly. But Mathcad’s better at the presentationn of technical applications. Check out http://mathcadworksheets.blogspot.com for some of my Mathcad applications.

  5. Steve Keen says:

    Hi Sam,

    Thanks for that link–you have some pretty impressive mathcad sheets there.

    I actually use the symbolic engine in Mathcad to construct my financial flows ODEs with a very simple piece of code; but then I have to cut and paste from the matrix it develops. I’ll email an example to you shortly. I agree that others are far better at programmatic expression, but the beauty of Mathcad for me is the manner in which it replicates paper in its interface, and how easy it is to remember its syntax.

  6. MySchizoBuddy says:

    Sage ins’t an alternative to Mathcad. it isn’t a WYSIWYG math package.
    SMath Studio however, is a free alternative to Mathcad. works just like Mathcad

  7. Steve Keen says:

    Hi MySchizoBuddy,

    Yes, I know. I’ve downloaded (and paid some money for) SMath Studio. It’s very good, but it lacks some key features of Mathcad that I use extensively (so it has RKAdapt routines for example, but not the Odesolve routine).

    However it does offer a lot, and it has a Linux version, so I do recommend it to those who don’t have Mathcad.

    Also, the developer could use some more funds! I think I donated about $20, which is a painfully significant fraction of the $830 he claims to have received from donors. Some more donations would definitely help him expand the feature list.

Leave a Reply