Archive for June, 2008
If you are a user of MATLAB’s Symbolic Toolbox then you are a user of the Maple 10 kernel since this is what MATLAB uses ‘under the hood’ in order to perform symbolic calculations. As of Septemeber 28th 2008 the Mathworks will be switching the kernel of the Symbolic Toolbox from Maple to Mupad. So should you care?
The answer is almost certainly yes. Mupad is completely different from Maple with a different set of abilities, behaviours and, inevitably, bugs. For example, things that didn’t work in Maple versions of the symbolic toolbox will start to work in the Mupad version. On the flip side, some things may stop working where there was once no problem.
I have been through this before when Mathcad switched from the Maple kernel to Mupad and there were a few issues but I support a much larger number of MATLAB symbolic toolbox users and so I am fearing the worst, but then I always do when something major changes like this.
An example of the kind of issue I came across when dealing with the Mathcad change included things like equation solvers changing their behavior due to using different algorithms internally. This sort of thing cropped up in problems that had multiple solutions such as when you try to find the roots of certain equations. Lecturers notes suddenly started disagreeing with the output because, for a given starting value, Mathcad converged to a different solution. No big deal in a class situation (in fact it might be a good learning experience) but not good if you have legacy code that depends upon that result.
Other bugs were a lot more embarrassing.
I’ll be honest – I do not know enough about either Maple or Mupad (I don’t even have access to Mupad in fact) to be able to decide if this change is going to be a good thing or not but one thing is for certain – it will be different and that will need to be managed.
The practical upshot is – when you upgrade, you should check all scripts that depend on the symbolic toolbox
I have just returned from the 9th International Mathematica Symposium which was held in Maastricht last week where, among other things, we celebrated the 20th anniversary of the release of Mathematica. The birthday itself was on June 23rd and, as luck would have it, this was also the day of the conference dinner at the wonderful man-made caves of Geulhem so all of the IMS delegates celebrated in style. I will write more about the conference itself in a future post – once I get hold of the some of the photos.
For now, I simply wanted to highlight the fact that Wolfram have made a scrapbook that shows some of their developments over the last 20 years. We were shown a preview of it at IMS and I think there is some great material there including the complete manual for Mathematica’s predecessor, SMP (Symbolic Manipulation Program) – great for getting a flavour of how computer algebra was done in the 1980’s. While on the subject of SMP – there is a couple of screenshots of it running on a minicomputer. If you have never heard this term before you might be forgiven for thinking that a minicomputers were small, but in fact they were only small compared to the gigantic mainframes of the day. Essentially a minicomputer was the size of a two or three family washing machines as compared to the size of a house for a mainframe (or something like that – I was only 10 at the time so can’t remember!). If anyone is looking for a project, it would be very cool to get a copy of the original SMP code to work on a modern mini-computer such as a mobile phone. I wonder what the license issues are….
There are also details of the early development of the Mathematica language. What I find interesting here is how much of the early ideas survive in the present system. For me, reading code from that 20 year old dialect of Mathematica felt a little like reading victorian english – slightly odd but perfectly understandable.
I also enjoyed reading the media reactions to those early versions…one entitled “Twilight of the pencil?” by William Press for example. I find it interesting that, despite the remarkable evolution of packages such as Mathematica over the last two decades, I have yet to find a Mathematician who never does any pencil and paper maths.
I remember when I first discovered Mathematica ,version 3.0 I think it was, running on some sort of ancient Unix based system which my University had christened Newton. It was in the first month of my PhD and I had been wrestling with some terrifying looking (to a freshly minted grad student at least) integrals that were taking me ages to evaluate by hand. My PhD supervisor was a symbolic integration master and during this phase of my work I was learning loads of shortcuts and tricks that you never get taught as an undergraduate. Even with these tricks though, the work was starting to get out of hand.
One integral took me 8 A4 pages of paper to evaluate and when I took the result to my professor she glanced at it and said “that’s wrong.” For an moment I thought she already knew the answer and had just set me the problem as an exercise but she then went on to show how my result was not dimensionally consistent. A day’s work later and I had the correct answer. Over coffee someone said “There’s a package called Mathematica that could probably do those integrals – it’s installed on a machine here somewhere – maybe go and try it out.”
It took a day to find the name of the machine with Mathematica installed, another day to find said machine, 5 minutes to learn how to feed my problem to Mathematica and then about 30 seconds to reproduce several days worth of manual labour. I was in love! You would think that the pace of my research would have accelerated but I got very sidetracked learning what else I could do with my new toy.
If you have any stories concerning your early Mathematica experiences, feel free to share them in the comments section.
Oh, and the scrapbook is here – www.wolfram.com/company/scrapbook/
Version 3 of the Mozilla Foundation’s superb web browser, Firefox, has been released and is available for download. Firefox really is a massive improvement over Internet Explorer in my opinion and, most importantly of all, Firefox renders walkingrandomly.com properly! It looks hideous in Internet Explorer 6 and it simply isn’t my fault.
No matter what operating system you use – Windows, Linux or Mac OS X – there is a version of Firefox for you. So please…go get it now and experience this blog the way it’s creator intended.
Some people collect stamps, some collect coins. I collect bugs in computer algebra systems and this is a particularly amusing one in my opinion. If you evaluate 2^31 using Mathcad’s symbolic engine in version 14 then you get a negative result! It comes up with the following
2^31-> -2147 483648
Note the negative sign! No computer algebra system is perfect but it is not often that you get a bug from such an elementary calculation – shame on you Mathcad! At least it gets the right result if you use its numerical engine
2^31 = 2.147 *10^9
Hopefully PTC will be releasing a bug fix soon.
At the beginning of the year I wondered what interesting facts I could discover about the number 2008 and, with the help of readers of this blog, I came up with a lot more than I expected to. Now that we are over half way through the year I thought it was time to take another look at the integer 2008 with the following puzzle.
Choose any one of the digits from 0 to 9 and attempt to express the number 2008 using only that digit. You can repeat your digit as often as you like and use any of functions that are built into something like Mathematica, MATLAB or SAGE but, as you may expect, kudos will be awarded for using only simple functions and small numbers of repeats.
I spent a few minutes thinking about this problem and so far have only come up with
2008= (2*2^2)*(2^2^2)^2 – 2*2^(2*2) – 2*(2 + 2)
2008 = Ceiling[6*6*6*6 + 6! – Sqrt[66]]
2008 = Ceiling[Gamma[7.7] – (777) + 7 + 7 + 7/7]
but I am sure you can do better – those ceiling functions are pretty ugly for a start. Feel free to post your solutions in the comments section – I look forward to seeing them.
A few years ago, while working through a degree in theoretical physics at Sheffield University, I took a course on special functions in physics that was given by the legendary lecturer Dr Stoddart (saviour of many a physics undergraduate, including me, during his many years there – please leave a comment if you studied at Sheffield and remember him).
This course introduced me to the fascinating world of the so called ‘higher transcendental functions’ of mathematical physics. I remember that we covered topics such as Bessel functions, Laguerre polynomials, Hermite Polynomials and the Gamma function among others but in a one semester course we only really scratched the surface of the subject.
Since then I have come across several other special functions during the course of my work such as the LambertW function, Mathieu functions, Chebyshev polynomials and more. I used to be a physicist and so, despite the fact that the theory behind these functions can often be fascinating, all I had time to consider back then was how to evaluate them.
In fact, as far as my professional life goes, the question of evaluation is still the only thing that I get asked about regarding special functions. Questions such as ‘How can I evaluate the LambertW function in MATLAB?’ (Answer – by using this user-defined function) or ‘Do you know of a free, open source, implementation of Bessel’s function?’ (Answer – the GNU Scientific Library).
The idea for this post came to me while reading an article written in 1994 (and subsequently updated in 2000) where the authors discussed the Numerical Evaluation of Special Functions. One of the features of this document was a list of various special functions combined with a list of software packages that could evaluate them. For example it lists Dawson’s integral and tells us that if you need to evaluate this then you can use various software packages such as the NAG libraries or Numerical Recipes.
I thought that this was a very useful document but a major problem with it is that it is rather out of date! Wouldn’t it be great if someone were to create an updated version that included all of the latest advances in software libraries and applications. I even idly thought of attempting to do this myself and publish the results here but it turns out that I have (thankfully) been beaten to it.
It’s not finished yet but the NIST Digital Library of Mathematical Functions looks like it is going to be exactly what I need. Apparently this project aims to be a sort of modern rewrite of Abramowitz and Stegun’s Handbook of Mathematical Functions, a book that almost every physicist I knew had a copy of. The preview looks very promising to say the least! For example, take the section on the Gamma Function. The library contains everything you might want to know about this function such as its definition, 2D and 3D plots of its graphs, its series expansion and, of course, a list of software packages and libraries that can be used to evaluate it. I note that, for the Gamma function, one can choose from MATLAB, Mathematica, MAPLE, NAG, Maxima, PARI-GP, the GSL, Numerical Recipes and several others – not exactly short of Gamma function implementations are we?
When it’s finished, the work will be published as a book called ‘Handbook of Mathematical Functions’ but will also be available freely online as a digital library – fabulous!
Some time ago now I worked with Will Robertson to produce a package that allowed Mathematica users to add MATLAB like colorbars to their graphs. The package was called ColorbarPlot and version 0.3 was released on Wolfram’s Library Archive last October. It was very well received and we were both pleased to find that people were actually finding it useful. The feature requests started rolling in and Will and I started to hack in extra bits of functionality as they were requested. Eventually, we had enough new features hacked in to demand a rewrite which Will duly did and the resulting version 0.4 of the ColorbarPlot package was sent out to a few users a little while ago.
We refrained from actually announcing it though since we wanted this new version to replace the old one in the Wolfram Library. Will sent them an email ages ago but has heard nothing and so we decided to just publish it ourselves. So, without further ado, here is a link to a zip file containing the ColorbarPlot package itself along with an examples notebook.
Think of this as a ‘snapshot’ of the live package – it will never change and is hosted on my server. If you have googled your way here and are wondering if there is a newer version then you should take a look at Will’s GitHub repository where you will always be able to find the latest version of ColorbarPlot along with some other packages that he has authored. Will’s own announcement of this upgrade can be found on his website.
So, what’s new in this version? The most useful change is that you can now add colorbars to List based plots – useful for experimental data. The following piece of Mathematica code creates a List of data and uses ColorbarPlot to plot it.
data2d = Table[Sin[x y^2], {x, -2, 2, 0.1}, {y, -2, 2, 0.1}];
ColorbarPlot[data2d, PlotType -> “Contour”]
Of course you are not limited to just 2D list based plots
ColorbarPlot[data2d, PlotType -> “3D”]
ColorbarPlot[data2d, PlotType -> “Point3D”]
The full list of Plot types you can use with ColorbarPlot is
- (List)ContourPlot
- (List)DensityPlot
- (List)Plot3D
- ListPointPlot3D
Other new features include the ability to manually choose the min/max scale of the colorbar, the ability to fine tune the padding and height of the colorbar along with various clean ups and bug fixes. All new (and old) features are documented and demonstrated in the accompanying examples notebook. Thanks to Will for his hard work on this release (he did most of it – my contributions are rather small this time).
Feedback and suggestions are, as always, very welcome. If you publish any results using this package then please let me know – it would be great to see.
The 34th Carnival of Mathematics is up over at 360 and, as always, it includes a lot of great math related links. I didn’t submit anything to this edition because I haven’t written anything suitable recently but will try to submit something to the next one.