Archive for May, 2008

May 23rd, 2008

Although Mathematica 6 has been out for quite a while now there are still some people at my university who refuse to upgrade from Mathematica 5.2 for one reason or another. Some don’t like the new help system, others don’t have the time to rewrite teaching notes and some find that their old Mathematica scripts simply don’t run properly in version 6 and they can’t figure out why.

Of course most users have embraced the new version as there is simply too much new functionality to do otherwise. Some people, however, have minor problems with version 6 that might not be show stoppers but are definitely annoying. One such problem was reported to me today by a user who was missing the “Evaluate Notebook” option that used to be present in the menu of version 5.2.

Fortunately things like this are easily fixed. Within a standard Mathematica install, there is a file called which defines what appears on the menus. On my Windows system it appears in the following location

C:\Program Files\Wolfram Research\Mathematica\6.0\SystemFiles\FrontEnd\TextResources\Windows\

To get “Evaluate Notebook” to appear in the “Evaluation” part of the menu just modify this file by adding the line

Item[“Evaluate &Notebook”, “EvaluateNotebook”],

after the part that reads


Let me know if you find this useful.

May 23rd, 2008

Yesterday I wrote about Mathematica 6.0.2 not working properly on Ubuntu 8.04 and today I discover that Matlab 2007b doesn’t like it much either. When you run Matlab you might get nothing more than an empty gray window and Matlab will essentially be unusable. Apparently the problem stems from a bug with Java applications when using Compiz or Beryl effects so just turn them off and all will be well.

To fix the problem just click on System -> Preferences -> Appearance in the GNOME menu and select the Visual Effects tab. Set the effects to None and then click on close. Matlab 2007b should now work properly and you won’t be wasting any CPU cycles on eye candy.

Of course you might not want to disable all of the pretty visual effects. If so then try the workarounds detailed in The Mathwork’s article on this issue – I haven’t tried any of these extra tricks since they are unsupported and I am more insterested in a working Matlab than a pretty desktop.

May 22nd, 2008

I recently upgraded my Ubuntu installation from 7.10 to 8.04 and almost immediately ran into problems when trying to run Mathematica 6.0.2 – all of the fonts are not rendering properly. In addition, if I run mathematica from a console window I get error messages like

X Error of failed request: RenderBadPicture (invalid Picture parameter)
Major opcode of failed request: 158 (RENDER)
Minor opcode of failed request: 7 (RenderFreePicture)
Picture id in failed request: 0x440189f
Serial number of failed request: 69419
Current serial number in output stream: 69420

X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 158 (RENDER)
Minor opcode of failed request: 4 (RenderCreatePicture)
Serial number of failed request: 71071
Current serial number in output stream: 71074

The following screenshot shows the problem – you cannot see anything you type apart from a few symbols such as [] and {} .

Other people have come across this problem and workarounds have been identified. The first is to run Mathematica from a console prompt as follows

mathematica -defaultvisual

This allows you to see what you are doing but is a big ugly. Another workaround is to install libqt4-core and libqt4-gui by doing

sudo apt-get install libqt4-core libqt4-gui

and then rename a couple of files in the Mathematica distribution as follows

sudo mv /usr/local/Wolfram/Mathematica/6.0/SystemFiles/Libraries/Linux/ /usr/local/Wolfram/Mathematica/6.0/SystemFiles/Libraries/Linux/

sudo mv /usr/local/Wolfram/Mathematica/6.0/SystemFiles/Libraries/Linux/ /usr/local/Wolfram/Mathematica/6.0/SystemFiles/Libraries/Linux/

This fixes the problem but you may get two extra blank windows appear when you run Mathematica. To fix this open up the Option Inspector in Mathematica as follows:

Edit-> Preferences and click on Open Option Inspector

When in the Option Inspector click on Notebook Options and then Window Properties and change the WindowFrame option from “Normal” to “Generic” then click on Apply

A big thank you to the people in this thread on for developing all of these workarounds. I will be reporting these problems to Wolfram’s tech support as soon as I have finished writing this.

Update: 28 May 2008

Someone from Wolfram responded to these issues in this thread. For anyone who has googled themselves here I have copied and pasted his response below:

Note – this is not an “official” Wolfram response, I just wanted to let you all know we’re aware of the issues…

With that in mind, a few comments:

The original error messages are due to X11 providing an incorrect visual buffer to draw on – the ‘export XLIB_SKIP_ARBG_VISUALS=1′ command tells X to discard any composite visuals (which is what compiz and the like uses to do window effects) when we request a new visual. The reason we are getting a bad visual is complicated, but should be resolved by the next major release of Mathematica.

The extra windows are supposed to be hidden, and will go back into hiding with 6.0.3 (coming very soon).

The font rendering issues are related to Hardy’s lack of some fonts we normally assume to be installed by default, namely a decent Courier and Times fonts. Some adjustments were made for 6.0.3, but if these do not resolve your issues, you may want to adjust the substitution rules (Option Inspector->Global Options->Menu Settings->FontSubstitutions) to point to fonts installed on your system.

On deleting/replacing libQt* – this is not recommended, as we ship a commercial version of the Qt library, which can potentially differ from the open source version. If it works for now, that’s fortunate, but I would not consider that a permanent fix. We will be updating our shipping version of Qt with our next major release, most likely from the Qt 4 .3 version tree, as 4.4 is causing some compatibility issues (the above mentioned QObject warnings)

May 22nd, 2008

I will be attending the 9th International Mathematica Symposium (IMS) next month in Maastricht and wondered if any readers of this blog would be there. Feel free to let me know in the comments if you are and would like to meet up. If you don’t want your comment published just say so and I will withold it after getting your email address.

May 16th, 2008

Hello and welcome to the 33rd edition of the Carnival of Mathematics. This carnival very nearly didn’t happen since I didn’t realise that no one had offered to host it until a couple of days ago! I toyed with the idea of letting this edition of the carnival lapse and write something in a fortnights time but then that would break the carnivals unbroken run of 33 publications (well..apart from that one time which we don’t talk about) and I simply couldn’t have that. So, with only two days to go I bent the standard carnival rules a little and started leaning on people I know in order to get submissions. After that I started leaning on people I didn’t know and I am glad to say that everyone came through and I have a nice selection of articles for you all.

Before I get onto the articles themselves, tradition dictates that I attempt to fascinate you with some interesting facts concerning the number 33. Well how about this one:

It is known that for all numbers N below 1000 that do not have the form  \light\reverse 9n\pm 4 it is possible to express N as a sum of three cubes. In other words

\light  N=a^3+b^3+c^3

where a,b and c can be positive or negative. What does this have to do with the number 33? Well, 33 is the smallest such number for which a,b and c have not yet been found. If you fancy having a crack at solving this be aware that the solution for N=30 is

\light 30=(-283059965)^3 + (-2218888517)^3 + 2220422932^3

Anyway, enough with the trivia and on with the show!

As some of you know, I am a big fan of computer algebra systems (well most of them anyway) and so I thought I would start off with some submissions from three of the big names in the CAS world, Wolfram Research, The Mathworks and SAGE. I use the products of all three of these groups to one degree or another and so it is great to see submissions from them all. This is one of the areas where I bent the carnival rules slightly since I emailed the blog authors and said “Hi – please submit something to the carnival.” I thank them for humoring me and not consigning my email to the spam bin.

Loren from Loren on the Art of Matlab writes a regular blog on Matlab programming and her submission is a recent post entitled Acting on Specific Elements in a Matrix where she uses several methods to obtain the same result. This sort of article is very instructive when thinking about how to go about developing your code. Although she did not submit it, I thought that many carnival readers would also be interested in her post called Matlab Publishing for Teaching.

Next up from the Mathworks we have Doug whose submission is a coin tossing puzzle which he invites you to solve using Matlab. Some solutions can be found in the comments section so resist the urge to scroll down if you want to try and solve it yourself. Solving problems like this, using any system, can be a great way of learning how to use it – much more interesting than just reading through the manual; no matter how well written it is.

Moving over to the Wolfram Research Blog we have two posts in this edition of the carnival, the first of which is called Two Hundred Thousand New formulas on the Web which is a discussion of The Wolfram Functions Site. At the time of writing the site has over 307,00 formulas on it which is, quite frankly, astonishing! Pretty useful too!

Next up from Wolfram we have a blog post called Making Photo Mosaics. It never ceases to amaze me how much you can achieve with so little code – I will be having a play with this code using photos from my recent vacation :) Check out the video that Theodore has produced as part of this post as I think it’s fascinating.

Moving over to the world of open source we have a submission from William Stein – Can There be a Viable Free Open Source Alternative to Magma, Maple, Mathematica and Matlab? where he discusses the SAGE project. I have recently been looking at SAGE myself and have been very impressed with it.

This edition of the carnival isn’t just about computer algebra packages though – we also have lots of non-CAS submissions. The first of which is one from Maria over at the TCM Technology Blog where she writes about her talk, Exploring Online Calculus, at the Michigan MAA meeting. Gotta love those graphs :)

John of jd2718 asks Can we find the area of a quadrilateral from just it’s co-ordinates?, with some interesting answers in the comments section. I reckon a nice Wolfram Demonstration could be made from this idea.

Sam Shah thinks that algebraic manipulation is overrated – head over to his blog to see why. In another post, Sam also writes about some interesting calculus projects that he has assigned to his students. When I was at school I used to love open-ending projects as it used to give me a sense of ‘owning the material’. I distinctly remember doing a project on the Fibonacci sequence when I was 11 years old and spending ages on it. To this day I still have a fascination for the topic and probably always will. I wonder how often such projects can be done by school children in todays test-centric environment?

Moving on, we have Math for the Very Patient from Vlorbik on Math Ed. Vlorbik has already demonstrated his patience in the past since my blog looks horrible on his browser and yet he still reads what I have to say – thanks Vlorbik! I seem to have a problem with IE 6 that I have no idea how to fix. Just look at this blog in IE 6 compared to firefox to see what we mean. One hexadecimal pound (thats two pounds and fifty six pence) to the first person who can diagnose and fix the problem for me.

Over at blinkdagger (among other things, a great source of Matlab tutorials) they have a competition where you can win prizes from the people at the art of problem solving. There is still time to enter so take a look at BlinkDagger burgers and have a go.

If you like the level of your mathematics to be a bit higher and median graphs are your thing then you will be interested in David Eppstein’s submission Median graphs and binary majorization over at OxDE.

Denise of Let’s Play Math sent me the details of her latest post, The Function Machine Game. This is another one I remember doing when I was at school. As she suggests it’s probably best to limit the functions one can choose from – “Waddya mean you couldn’t get it – BesselJ(x) is simple!” I feel yet another Wolfram Demonstration coming on :)

Next we have a post from a blog that writes posts on the all time classic combination of subjects, cats and maths – The post is about how to calculate \light \reverse\pi(x) (that is the number of prime numbers below an integer x) without having to calculate all of the primes up to x. I wonder how the various CAS systems calculate this function? Anyone care to enlighten me?

Finally, in another bending of the rules, I’d like to present Five Open Problems Regarding Convex Polytopes from Gil Kalai’s blog, Combinatorics and more. He didn’t submit this post himself but it comes highly recommended and so I hope he will not mind having it included here.

And…that’s it for this 33rd edition of the carnival. Thank you to everyone who submitted something – without you the carnival would be..well..just me posting a load of links! Finally, would someone please volunteer to host the 34th edition of the carnival? I think it really is a lovely tradition that has been kept going by maths bloggers for almost 18 months now, which is like an eternity in internet years and it would be a shame to see it go. I think that it’s a great way of finding new math blogs and also of generating a sense of community in the maths blogsphere.


Update: As it says in the comments, the next Carnival will be hosted over at 360 on May 30th so please head over there and submit a post. Making a submission is as easy as saying “Hi, what about this one…< insert link here>” 9 times out of 10 your post will be accepted so its an easy way to promote your blog.

May 14th, 2008

Until recently, I didn’t realise that no one had volunteered to host the next Carnival of Mathematics and so I had a quick chat with Alon and we agreed to have it here. I know that it is short notice but I would really appreciate it if you could send in any submissions as soon as possible please.

By far the easiest method of submission would be to write a comment giving me all of the details of your post – I will then withhold that comment from being published on this page, email you to confirm receipt and start putting together the carnival for publication this Friday.

Your Carnival needs you!

Update: You can also submit your post via the carnival submission form.

May 13th, 2008

One of the many things that happened while I was away was the release of version 12 of the popular computer algebra system, Maple. I am not a Maple user myself so I cannot say very much about this new release but Maplesoft have released an extensive set of what’s new pages and a casual scan reveals a lot of interesting stuff.

I do have access to some network licenses for Maple and recently installed version 11 to try and get a taste of its abilities compared to products that I am more familiar with so I guess I will be getting access to version 12 eventually. The problem with this set-up is that it means that I can only access it from work and we are not exactly inundated with Maple queries here so it is rather low priority at the moment. Oh well, I am sure I will get around to it eventually.

If there are any Maple users out there who would like to tell me what their favorite new features are then please do so via the comments. I’d also like to hear from people who can tell me what Maple can do that Mathematica, Matlab, Mathcad etc can’t.

May 13th, 2008

One of the newsletters I subscribe to described the following ‘bug’ in Excel. If you sum the following numbers by hand then you get a result of zero:


but if you use Excel to sum these numbers then you get a result of about 8.6402e-12 which, shock, horror, is not zero. So, clearly there is a bug, Excel sucks and we can all have a happy rant about Microsoft’s incompetence. Right?

Wrong! Excel is behaving exactly as I would expect it too and you should expect it to behave this way too. First of all let us determine that this ‘bug’ doesn’t just occur in Excel. Fire up your copy of Matlab (or the open source equivalent, Octave) and type


The result?

8.6402e-12 – exactly the same as Excel.

Either you come to the conclusion that 3 different development teams have produced software that can’t add up or that something more subtle is going on.

The ‘something subtle’ is the fact that computers represent numbers internally using binary and when you only have a limited number of binary digits to play with you cannot represent all decimal numbers exactly. A classic example is the decimal number 0.1. The binary representation of 0.1 requires an infinite amount of digits and so if you only store a finite number of these you will always be working with an approximation (just like when you write 0.33333333 as the decimal expansion of 1/3).

In fact, when working in double precision, 0.1 is approximated to


Which you can see in Matlab by typing


You can see the effect of this if you do the following calculation in something like Octave or Matlab

(0.1 + 0.1 + 0.1) – 0.3

the result of which 5.551115123125783e-17

If you need to learn more about this sort of thing then the Wikipedia page on IEEE arithmetic is quite good and so is this article from the Mathworks.

May 12th, 2008

Regular readers of this blog will know that I have been keeping an eye on the open source mathematics package, SAGE, but have never really had time to take a closer look at it. A couple of things happened recently that made me find time to sit down and have a play with this extremely promising piece of software.

First of all I discovered that the developers of SAGE have been implementing a command called interact which is essentially a free version of the Mathematica command Manipulate. I love tinkering with Manipulate and so this open source alternative proved to be very tempting. Secondly, the developers of Sage recently released version 3.0 and, usually, a .0 release signifies a major milestone in development.

So first things first. What exactly is SAGE? In my opinion, the easiest way to sum up the answer to this question is to quote the projects mission statement which is

“Creating a viable free open source alternative to Magma, Maple, Mathematica, and Matlab.

No small task! I have access to three of the four CAS systems that SAGE has chosen to compare itself with and they are all extremely powerful (not to mention expensive) applications backed by large, well funded development teams. Not content with taking just on just one of them – SAGE has chosen to compete with all four at the same time!

Free maths packages are nothing new of course – there are several good quality, regularly updated open-source packages that one could choose from. For example we have

  • Octave – A numeric-centric application that aims to be source-compatible with the base version of Matlab
  • Maxima – A more symbolic-centric package than Octave that is an open source development of the old commercial Macsyma code.
  • Scilab – Another numeric-centric package that has similar functionality to Matlab but it does not aim to be source compatible in any way.

We also have YACAS, Mathomatic, PARI/GP, GAP, R, Singular and GINAC among others – some of which are very well known in various academic disciplines. So what makes SAGE different?

SAGE is a car

The first major thing I noticed when reading about SAGE is that its developers realised that there is a lot of good code in packages such as Maxima and it would take a long time to develop equivalent levels of functionality from scratch. So, to paraphrase their slogan, rather than re-inventing the wheel they built a car.

In other words they did not try to compete with Maxima by re-implementing its algorithms – they simply included the entire Maxima executable with the base install of SAGE and wrote a SAGE-Maxima interface. So that’s one of the wheels of the car for a start.

For the other wheels they included GAP, PARI and Singular with SAGE so you immediately have access to four different systems from one standard interface – that’s a lot of funtionality. Continuing with the car metaphor I guess we have Python as the engine along with the statistical package, R, as um..the doors? You also have GMP (multi-precision arithmetic), Matplotlib (2d plotting), Tachyon3d (3d plotting) and lots more!

You don’t have to stop with just these included systems if you don’t want to. For example, if you have a copy of Octave on your machine then you can also call that from inside SAGE. Apparently you can even use commercial packages such as Mathematica or Maple although I have yet to try this out myself.

Of course, SAGE is much more than just an interface to existing systems – the developers have also written 250,000 lines of new, SAGE specific code, that adds to this plethora of functionality.

This isn’t just any old car – this is a car with all the optional extras. That gets constantly upgraded. For free!

SAGE uses Python

The next thing about SAGE that stood out for me is the fact that you use the Python scripting language to interact with it. I already know some Python and so, without needing to learn a thing, I already know how to use large parts of SAGE.

SAGE’s use of Python doesn’t just provide a shallower learning curve for Pythonistas, there are a great many other benefits too. In particular, the use of Python gives SAGE access to all of the routines of the extensive numerical library numpy along with the plotting library, matplotlib. These two Python libraries alone provide a reasonable amount of matlab-like functionality before you start considering everything else in the SAGE system.

SAGE has a great user interface

Its been a while since I used any of the other open source maths packages in anger so what I am about to say might be a bit out of date but in general it seems that their user interfaces are a bit, well…primitive. Many of them look just like a terminal prompt with a graphics output window. This is all well and good but when you are used to the pretty, notebook-like interfaces in Mathematica or Maple they all look very last-century.

SAGE uses your web browser as its notebook-like interface and I think it looks great. Here is an example of it in use (shamelessly stolen from here)

Of course you can still use it in good, old fashioned terminal mode if you really want to :)

SAGE has the interact function

SAGE is first and foremost a tool written by researchers for research and so it contains a lot of very advanced mathematics. For example the lead developer, Willian Stein, is very pleased about the fact that SAGE includes code for computing with modular abelian varieties. Now I wouldn’t know what a modular abelian variety was if it hit me over the head (I would welcome an idiot’s guide by anyone willing to write one) but I am sure that this code is very important to those who work with them.

So, bearing in mind that the SAGE developers have worked very hard to include all of this cutting edge functionality, I would like to apologise to them in advance for the fact that the piece of SAGE that really got me interested was the interact command – something that many people may well find frivolous.

In a nutshell interact offers similar functionality to Mathematica’s Manipulate command which I am a HUGE fan of. If you are new here and have no idea why the Manipulate command is so wonderful – check out the Wolfram Demonstrations Project and note that without Manipulate, the project would not exist.

In the second part of this blog post (coming in a few days) I will give you an idea why I think the interact command is so wonderful, what you can do with it and how to use it along with some comparisons with the Manipulate command of SAGE’s competitor, Mathematica. If you can’t wait for me to write the next post and want to see some interact examples right now then check out the interact page on the SAGE wiki.

If you enjoyed this article, feel free to click here to subscribe to my RSS Feed.

May 12th, 2008

While I was away the 32nd carnival of Mathematics was posted over at TCMTB. This edition might be small but it is perfectly formed with articles on topics such as the combinatorics of words and a nice variation on Tic Tac Toe.