Why I use Mathcad

flattr this!

A new blog mem­ber asked “Why do you use Math­cad?” in response to my most recent post about using some of the funds donated by vis­i­tors to the blog to help fund my research.

It’s a very good tech­ni­cal ques­tion, and one that deserves more than just a reply to the com­ment. So I’ll try to explain why here.

I build dynamic mod­els of the econ­omy using sys­tems of ordi­nary dif­fer­en­tial equa­tions. There are many pro­grams that sup­port this these days, from pub­lic domain pro­grams like Scilab to com­mer­cial giants like Math­e­mat­ica and Math­cad. I’ve tried most of them, and I’ve stuck with Math­cad for two reasons:

Its inter­face is very nat­ural; and

Its error mes­sages are easy to interpret.

I’ll try to illus­trate this with sim­u­la­tions of the same sys­tem in both Math­cad and Math­e­mat­ica. Firstly, here’s a suc­cess­ful out­put from Math­e­mat­ica of my sim­plest endoge­nous 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 Math­e­mat­ica graphs, I find the Math­cad dis­play more intuitive–more like what a math­e­mati­cian would write on a sheet of paper, which is pre­cisely Mathcad’s design philosophy.

But the main dif­fer­ence comes with the next fea­ture: the error mes­sages the two pro­grams gen­er­ate when, as so often hap­pens, you make a mis­take in your early attempts to sim­u­late a model. In this instance, I have typed “ss” where I meant to type “s” in a par­tic­u­lar func­tion. Here’s Mathematica’s reac­tion to that:

Huh? What does “NDSolve::ndinnt: Ini­tial con­di­tion 400. ss is not a num­ber or a rec­tan­gu­lar array of num­bers” mean? That’s a triv­ial exam­ple, and of course I already know, but when you’re craft­ing a com­plex model and make an acci­den­tal mis­take, it can be non-trivial exer­cise to locate the error–even if it is in fact a triv­ial one like this.

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

Ahah! I have an (as yet uniden­ti­fied) unde­fined vari­able! I click on “trace error”, and get the next win­dow. If there was a cas­cade of errors, the “Pre­vi­ous” but­ton would be high­lighted, but since there’s only one, when I shut this win­dow down Math­cad puts the cur­sor right on the offend­ing “ss” variable.

This makes devel­op­ing and debug­ging a model in Math­cad an order of mag­ni­tude eas­ier than in Math­e­mat­ica. I know that Math­e­mat­ica is the more pow­er­ful sys­tem, but that power comes at a cost of a much more opaque error cor­rec­tion interface.

If these errors were parsed by the pro­gram, so that it did what Math­cad did in iden­ti­fy­ing the source of the prob­lem, then I could quite eas­ily con­sider devel­op­ing ini­tially in Math­e­mat­ica. There would be advan­tages here–notably the abil­ity to export equa­tions directly to TeX for jour­nals that require that for­mat, but many many others.

But until that hap­pens, I make an engineer’s choice to choose the most effec­tive tool rather than the most pow­er­ful or ele­gant one.

Bookmark the permalink.

32 Responses to Why I use Mathcad

  1. Steve Keen says:

    I’ll put a PDF of the Math­cad file up too for eas­ier access.

    The model starts with a sin­gle sec­tor and then expands to mul­ti­ple, but look­ing at the paper I didn’t doc­u­ment all the steps to the lat­ter 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:

    Mean­while I strongly rec­om­mend you check­out Tex­Macs and start using it for WYSIWYG and WYSIWYM prepa­ra­tions of ele­gantly type­set papers with math­e­mat­i­cal for­mu­lae — both direct to .pdf and via LaTex. For Win­dows ver­sion I rec­om­mend the option to install the full Cyg­win first so you can eas­ily add other unix­ish soft­ware that it inter­faces to and auto­mat­i­cally type­sets maths and graph­i­cal plots for.

    Here’s an exam­ple that includes TeX­macs dis­play of “live” (alge­braic) solu­tions of sim­ple ODEs using Max­ima (which is also avail­able for Win­dows). It also inter­faces direct to “R” which has com­pre­hen­sive sta­tis­ti­cal stuff (free clone of “S”) highly rel­e­vant to eco­nom­ics and also to Mat­lab and Octave (free Mat­lab clone) with ade­quate numeric ODE solvers as well as to Sage (which itself inter­faces to all 3 and SciPy numeric ODE solvers and matrix alge­bra etc and pro­vides a supe­rior com­bi­na­tion environment).

    The TeXmacs/Maxima exam­ple in 4th screen­shot above is pretty sim­i­lar to what you could get directly with TeXmacs/Sage numeric solu­tions of ODEs and looks to me pretty clearly supe­rior to your Math­cad example.

    Try TeX­macs first, sim­ply as a gen­eral pow­er­ful sci­en­tific word­proces­sor vastly supe­rior to LyX et al and later add Sage. Even though Sage would be run­ning on a vir­tual linux over win­dows it should still be just as easy and fast for it to com­mu­ni­cate with Windows/Cygwin Tex­Macs as the inter­face is via net­work stack on “local­host” (and can also be made remotely acces­si­ble if you want).

    BTW QtOc­tave GUI inter­face for Octave sim­i­lar to the Mat­lab desk­top is also avail­able for Windows.

    Like­wise of course the nor­mal “Note­book” browser inter­face to Sage is also via net­work to Fire­fox browser so despite the vir­tual linux for Sage itself you would be work­ing entirely in your nor­mal Win­dows envi­ron­ment apart from the ini­tial has­sles of set­ting it up.

  3. Steve Keen says:

    Thanks Arthur,

    I’ve had a quick look, and what I might do is try sim­ple Tex­Macs under Win­dows first of all sim­ply as a LyX alter­nate to get a feel for it, and then if it seems work­able, use that when I start writ­ing Finance and Eco­nomic Break­down prop­erly next year and then do a full instal­la­tion. 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 fin­ished pronto, so work­ing in what I know will be faster than learn­ing a whole new sys­tem and restarting.

  4. Sam says:

    I used sev­eral math tools at work, and I use each one for the task it’s best suited for. Mathcad’s great for cal­cu­la­tions like this, but where it fal­ters is when you need to pro­gram­mat­i­cally con­struct dif­fer­en­tial mod­els (e.g. when you’re dis­cretiz­ing a PDE to a sys­tem of ODEs). In other tools you can con­struct the equa­tions pro­gra­mat­i­cally, but in Math­cad you have to write them explic­itly. But Mathcad’s bet­ter at the pre­sen­ta­tionn of tech­ni­cal appli­ca­tions. Check out http://mathcadworksheets.blogspot.com for some of my Math­cad applications.

  5. Steve Keen says:

    Hi Sam,

    Thanks for that link–you have some pretty impres­sive math­cad sheets there.

    I actu­ally use the sym­bolic engine in Math­cad to con­struct my finan­cial flows ODEs with a very sim­ple piece of code; but then I have to cut and paste from the matrix it devel­ops. I’ll email an exam­ple to you shortly. I agree that oth­ers are far bet­ter at pro­gram­matic expres­sion, but the beauty of Math­cad for me is the man­ner in which it repli­cates paper in its inter­face, and how easy it is to remem­ber its syntax.

  6. MySchizoBuddy says:

    Sage ins’t an alter­na­tive to Math­cad. it isn’t a WYSIWYG math pack­age.
    SMath Stu­dio how­ever, is a free alter­na­tive to Math­cad. works just like Math­cad

  7. Steve Keen says:

    Hi MySchizoBuddy,

    Yes, I know. I’ve down­loaded (and paid some money for) SMath Stu­dio. It’s very good, but it lacks some key fea­tures of Math­cad that I use exten­sively (so it has RKAdapt rou­tines for exam­ple, but not the Ode­s­olve routine).

    How­ever it does offer a lot, and it has a Linux ver­sion, so I do rec­om­mend it to those who don’t have Mathcad.

    Also, the devel­oper could use some more funds! I think I donated about $20, which is a painfully sig­nif­i­cant frac­tion of the $830 he claims to have received from donors. Some more dona­tions would def­i­nitely help him expand the fea­ture list.

Leave a Reply