February 8th, 2010 | Tags:

A friend of mine got me interested in JavaFX recently and my interest grew when I discovered that it had some nice charting functionality.  Dean Iverson has written some great tutorials on the subject over at his blog and includes a link to a demo showing some of the different plot types that are available.

The demo is called ChartDemo and can be found here

http://pleasingsoftware.blogspot.com/2009/06/this-is-test.html

In an ideal world you simply have to click on the demo’s screenshot for it to download and launch but that wasn’t what happened for me.  What happened when I clicked on it was nothing.  No error messages…just nothing.  It’s difficult to google ‘nothing happened’ and get something useful so I downloaded the demo (which had the filename ChartDemo.jnlp) and tried to launch it from the command line using

javaws ChartDemo.jnlp

This gave me the error message

netx: Unexpected net.sourceforge.jnlp.ParseException: Invalid XML document syntax. at
net.sourceforge.jnlp.Parser.getRootNode(Parser.java:1200)

What follows is the story of how I eventually got this demo to work in the hope that it will help someone out there.

So, first things first, what are some of the relevant system specs I am using?  Well, I am running 32bit Ubuntu Linux 9.10 (Karmic Koala) and

java -version

gives

java version "1.6.0_0"
OpenJDK Runtime Environment (IcedTea6 1.6.1) (6b16-1.6.1-3ubuntu1)
OpenJDK Server VM (build 14.0-b16, mixed mode)

Now, when I googled the error message I discovered that Linux (more specifically, I guess, the OpenJDK) is much more sensitive to xml errors than Windows/Mac OS X (.jnlp files are written in xml).  Take double quotes for example; according to the W3C XML recommendations you should not use \” inside an xml attribute but should use “"” instead.  Some java implementations don’t seem to care but, at the time of writing at least, OpenJDK definitely does.  Follow this link to see the original discussion thread where I learned this.

The practical upshot of this extra level of strictness is that .jnlp files that work just fine on Windows and Mac OS X won’t work on Linux and I guessed that was what as happening here.  Sadly there were no examples of \” in ChartDemo.jnlp for me to change to “"” so there must be something else ‘wrong’ with it; but what?

I decided to try the ’stare at it until you figure it out’ approach to debugging and left the laptop on the side of the sofa while watching a movie on TV.   About halfway through the movie, inspiration struck and I changed the line

<update check="background">

to

<update check="background"/>

which got things past the xml parsing stage. Sadly, I then hit another problem. Rather than a working ChartDemo, my efforts were rewarded with nothing more than just a blank window and a load of java errors in the terminal. When I say ‘a load’ I mean HUNDREDS and none of them looked particularly illuminating. I was starting to remember why I had avoided Java in the past but was not about to give up so easily.

Let’s take stock:

  • The .nlbp file was fine (or at least didn’t return any parse errors)
  • The ChartDemo code must be bug free because if it wasn’t then the author would have been told so rather quickly in the comments section of his blog
  • My Java setup was presumably fine since I was able to run other JavaFX examples. For example I successfully worked through a JavaFX programming tutorial on Sun’s website without incident.

Of those three points I figured that the third one was the most likely to be wrong. It was OpenJDK’s handling of the .jnlp file that caused my first problem so maybe it was causing this second problem too. Could I switch from using OpenJDK to a different version of Java I wondered? Some googling ensued and I discovered some useful incantations.

I can list the versions of Java installed on my machine with the command

sudo update-java-alternatives -l

to get

java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk
java-6-sun 63 /usr/lib/jvm/java-6-sun

I can change from the openjdk to sun-java with

sudo update-java-alternatives -s java-6-sun

Once I did this I tried to run the ChartDemo.nlbp file again:

javaws ChartDemo.jnlp

and it worked perfectly. I was rewarded with a very nice demo of JavaFX’s charting functionality and Dean’s tutorials proved to be very useful to me. So useful in fact that I bought his book.

Incidentially, the java-6-sun version of java doesn’t care about the syntax of the .jnlp file quite so much as openjdk. However, if you want to change back to using openjdk you can do

sudo update-java-alternatives -s java-6-openjdk

I hope this little tale helps someone out there. Let me know if it does and also feel free to let me know if I have got anything wrong. My knowledge of all things Java is rather basic at the moment to say the least – something I am trying to change.

February 4th, 2010 | Tags:

A lot has been written about Apple’s iPad but most of the comments I’ve read could be summed up as follows:

  • It’s just a big iPhone..without the ability to phone; which sucks. (Example)
  • It doesn’t have flash so it sucks. (Example)
  • It doesn’t multi-task so it sucks. (Example)
  • Apple are evil because they take away control of how we use their devices.  So, the iPad sucks. (Example)
  • The iPad is going to force ebook prices up.  This sucks. (Example)
  • The iPad doesn’t have a camera.  This sucks too! (Example)
  • The name sucks! (Example)

Now, before I go on, bear in mind that I am a card-carrying, fully paid up member of the Linux/Android community.  My phone is a HTC Hero running Android, my work desktop machine spends 95% of it’s time running Linux while my personal laptop runs it 100% of the time.  Bashing the likes of Apple and Microsoft has been a side-hobby of mine for years and has given me at least one thing in common with almost every computer geek I have ever met.  I would never buy a Mac, not in a million years,  and I am highly unlikely to ever switch from Android to iPhone.

Despite all of this, however, I decided that I would like to buy an iPad after watching just the first few minutes or so of Steve Job’s iPad presentation.  As soon as he announced the price I knew that I would be buying one…without hesitation.  Suddenly I regretted all of the Apple bashing I have done over the years as I knew full well that my friends and colleauges weren’t going to let me live this one down.  Oh yes…I am going to be in for a roasting over this particular purchase; a roasting that I will happily endure.  If you’re interested, I’ll tell you why.

The never-ending commute

I live in Sheffield but work in Manchester and I don’t drive a car.  The practical upshot of this is that I spend somewhere between 3 and 3.5 hours every day sitting on either a tram or a train.  What I do with this time varies a lot according to factors such as how tired I am, how much work I need to do, the availability of seats etc etc.  I always carry my Android phone and I almost always carry my laptop.  Depending on my mood you might also find me carrying books, a newspaper or two and maybe a DVD.

In general, if I am doing something serious, such as writing code or a document, then I’ll be using my laptop and if I am doing something frivolous, such as catching up on RSS feeds, playing games, listening to music, reading ebooks etc, then I’ll be using my Android phone.  Of course, there are exceptions to this rule, but they are….well, the exception.

Apple iPad

A big screen, lots of apps, games, a decent e-book reader, tv-shows and movies

I love the Hero but I often wish it had a bigger screen – a MUCH bigger screen.  A screen about the size of the iPad would do nicely but then it would far too big to be a phone.  My laptop’s got a nice sized screen but it’s heavy and people think you are a crazy-man when you get your laptop out on the tram or bus.  So, if I want a big screen then I need another device and the iPad will do nicely.

I get bored easily and am always on the lookout for new apps or games to waste my commute time with.  I have an Android device to play with but I am missing out on all those Apple-exclusive apps that you can get for the iPhone OS.  I considered buying an iPod touch but couldn’t justify spending the money on one JUST to get access to iPhone apps.  The iPad offers me a bigger screen AND access to the Apple App store so it’s already ahead of the iPod touch for me.

I like playing video games and have to say that I am rather disappointed by the amount of games available for Android (It is getting better, however).  I’m not a hardcore gamer though, not by any stretch of the imagination.  Someone gave me a PSP a while ago but I can’t be bothered to carry it around, the games are too expensive and I keep losing the charger.  Mobile phone games are just right for me; they are cheap, easy to pick up and put down and the best ones are a lot of fun.  The iPhone has TONS of games for it and I’ll be able to play them all on the iPad.

I read a lot and I mean a LOT – it’s one of my favorite ways to pass the time.  I thought about buying a Kindle but couldn’t justify spending that amount of cash on a device that essentially does only one thing.  Also, I detest the way that e-ink devices flash so horribly whenever you turn the page.  The Android ebook readers I’ve used,on the other hand, don’t give me access to a lot of the stuff I want to read.  The iPad does a lot more than just read ebooks and lots of publishers want to put their content on the device so another reason to buy the iPad.

Movies and TV shows on the train….at the moment I watch them on my laptop.  The iPad will be easier.

Finally, I’m hoping that the iPad will replace my need to carry a newspaper.  For it to do so I need an app for The Times that will look just like the dead-tree version.  It should also allow me to download the entire newspaper overnight and store it locally on the iPad.  A network only version would be no use at all because, although the commute through The Pennines is exceedingly beautiful, it is a 3G dead-zone most of the time.  I’ll happily pay a subscription to such a service as long as it’s cheaper than the dead-tree version of the paper.

Instant-on web-browsing, photos and a board-game platform

When I am at home I often find that I want to quickly go online to look something up, buy something or bash out a quick email.  If I use my laptop then I sometimes spend more time booting the thing up and down than it takes to do the task.  If I use my phone then the small screen and even smaller keyboard becomes an issue again.  The iPad would be perfect for this quick and casual kind of Internet surfing.  The lack of Flash support will be a pain but I won’t lose any sleep over it.

I like playing traditional board games.  You know….things such as Chess, Checkers, Scrabble and Backgammon and, ideally, I like to play against people rather than computers.  It occurred to me the other day that the iPad would be the perfect platform for board-games – simply as a replacement for the board and all of the pieces if nothing else.  It will never be as good as the hand crafted, wooden chess set that my wife bought for my birthday one year but it will serve as a great replacement for our magnetic games compendium next time we go on holiday.

Like many people these days, my wife and I have thousands of digital photographs and if we want to look through them we tend to use a laptop.  In the future I imagine we will use an iPad, simply because it will be quicker and easier to pass around.

Future possibilities…Wolfram Demonstrations?

When I first got my Android phone, I thought that it would be cool if Wolfram Research released an Android version of their free Mathematica Player to allow me to play with Wolfram Demonstrations on the move.  I quickly realised that this would be a dumb thing to do, on Android or iPhone, because phone screens are too small.  The iPad screen isn’t too small though!  Wolfram could make maths VERY hands-on.  How about it Wolfram?

The price

$499 dollars for the entry level version.  That’s about 315 pounds at the current exchange rate.  In a year, I spend more than that on coffee and it’s not particularly good coffee either.  At this price point, if my iPad purchase proves to be a disaster then I just won’t care (too much) – I’ll just drink less coffee for a while and give the iPad away.  Alternatively I’ll just use it to put my coffee mugs on.

Things I don’t care about regarding the iPad

  • The lack of Flash. If I NEED to browse a Flash based website then I’ll just use my laptop, or my Hero.
  • 3G.  I’ll be using the iPad on my commute most of the time.  3G coverage SUCKS on my particular train route.  If I desperately need a net connection RIGHT NOW then I’ll fall back to my phone.  So, I’ll buy the wifi-only version.  Having wifi was enough back in my Dell Axim days.
  • Lack of multi tasking. When I am messing around, you know…just wasting time, I only need to do one thing at a time.  Read one book, play one game, watch one movie.
  • Lack of control over my computing experience. When I care about having full control over my system, I’ll use Linux or Android.  For the stuff I plan on using the iPad for, I just don’t care.
  • The price of ebooks. If they are too expensive then I won’t buy them.  When it makes more sense to buy the dead-tree version then I will.
  • DRM. There are lots of DRM-free outlets for stuff these days.  If I think that a DRM version of something will affect me in any way then I won’t buy it.  Other times I just won’t care.  Who cares if my newspaper has DRM on it?  I’ll be throwing it away the instant I’ve finished with it anyway.  The same goes for a lot of paperback fiction and episodes of TV shows.  My music, movies and textbooks, on the other hand, I care more about.  I’ll continue to get my music from Amazon, my movies on DVD and my textbooks will be dead-tree if they aren’t DRM free.
  • Lack of camera. I’ve got a webcam on my laptop, I’ve got a 10 megapixel point and shoot camera and I’ve got a half decent camera on my phone.  If the iPad had one then yay! but it hasn’t and I don’t need one.
  • The name. Who cares what something is called?
  • No removable storage. The basic iPad model has 16Gb which will be enough.  My phone has removable storage in the form of a micro SD card.  It’s 2Gb and isn’t full.
  • It’s not Android. Some of my friends say I should wait until there is a good Android tablet and buy that instead.  I don’t want to.  I’ve got Android on my phone and I like it but I want something a bit different.
  • The backlash from my friends. Bring it :)

Drip,Drip,Drip,Drip…want one!

Taken individually, none of the reasons I’ve given in this article are compelling enough to make me go out and buy an iPad – or any other device for that matter.  It’s the steady accumulation of reasons that slowly but surely make the iPad into something that I want.  The plain fact of the matter is that I don’t need one – I just want one.  The iPad won’t change my life, it’ll just make it very slightly better in a number of  small and rather trivial ways – very much like my old Dell Axim x50v PDA did a few years ago.  It’s about the same price as the Axim was too.

For me, the iPad is for trivial computing…it’s for stuff that I could do elsewhere but just can’t be bothered because of screen size, boot up time, price…whatever.  It’s not a phone replacement, it’s not a laptop replacement, it sure as hell isn’t a Desktop replacement and I don’t want it to be any of these things.  It’s cheap, different and could fill lots of little gaps in my digital life.  Since I’ll only be using it for trivial stuff, I simply don’t care about the things that it hasn’t got or can’t do because I can do all of those on my other devices anyway.

Yep..I want an iPad and, although I never really knew it, I always have.

January 30th, 2010 | Tags:

There are two carnivals in the mathematics blogging world: The Carnival of Maths (CoM) and Math Teachers at Play (MTAP), which are basically two different facets of the same thing — but exactly what are they?

At the most basic level, a maths carnival is just a set of links to recent blog articles about mathematics, but that’s selling the whole idea short somewhat.  I’ve always liked to think that the two carnivals are the shop-front of the mathematics blogging world — a reason for us all to get together and celebrate everything that we are proud of in our little corner of the web.  Other people compare a blog carnival to a magazine’s table of contents, which can direct you to a wide variety of articles. The articles are written by different people, but they are all tied together by the theme/focus/area-of-interest that defines the magazine.

The best way of demonstrating what the carnivals are all about is to show you some examples, so here are the two most recent editions (I’ll try to keep this updated):

Let’s look at how the carnivals work in more detail.

Say you have just written a recent mathematical blog post which you are rather proud of.  Obviously you’d like as many people as possible to read your article, so you choose one of the two carnivals and submit it using one of the two forms below:

The carnivial host will receive your submission and, if they think it is suitable, will include it in their carnival.  You can then sit back and watch the extra traffic roll in.

Here are some frequently asked questions about both carnivals.

When are the carnivals published?

The Carnival of Maths usually gets published on the first Friday of the month and Math Teachers at Play gets published on the third Friday.

I would like to host a carnival at my blog.  What should I do?

Go to the relevant carnival home page and click on ‘Future Hosts’.  This will show you who is scheduled to host for the next few months.  Find an empty slot that suits you, contact me for the CoM or Denise for MTAP, and we’ll take it from there.

Who does the admin for the Carnivals?

At the moment, I am doing the admin for the Carnival of Math, and Denise of Let’s Play Math is looking after Math Teachers at Play.  So, if you have any questions, then we are your first port of call.

I’ve found a cool maths article that someone else has written.  Can I submit it to the carnivals?

Yes, but in an ideal world it will be a recent post and should have never been submitted to one of the carnivals before. The best way to be sure of this, if the post is not your own, is to send in only something published since the last edition of the carnival.

Can I submit an article to both carnivals?

We’d rather you didn’t — at least, not the *same* article. We don’t want to bore the audience.

Who decides what gets included in a carnival and what doesn’t.

The carnival hosts.  The carnival is just a guest on the host’s blog, and so what each host writes is entirely up to him or her.  In general, most carnival hosts will include almost everything that is submitted to them and a bit more besides.  However, if they choose NOT to link to something, then so be it.

The blog carnival server has been known to lose submissions on occasion. I have not heard of trouble with the maths carnivals, but the (much larger) Carnival of Education used to have problems quite often. If you are sure that your article met the carnival guidelines, but the host did not include it, then perhaps it simply got lost. Feel free to resubmit your post for the next edition.

Do I have to be a math teacher to submit an article to Math Teachers at Play?

No.  As long as the mathematics is below college-level, then you are good to go

Will the Carnival of Math take articles on basic math?

Yes — everything from kindergaten to cutting edge research is fair game for the Carnival of Math.  Basic mathematics can be submitted to either carnival, but advanced maths should generally be submitted only to the Carnival of Math.

Do you accept articles from subjects such as computer science or physics?

As long as there is a reasonable amount of maths content, then yes.

Is there anything else I need to do, besides submitting my article?

No, there is nothing else you have to do. When the carnival is published, however, you may want to post a link to it on your blog. The carnival host will appreciate your support, and your readers will enjoy a chance to browse what other math bloggers have written.

Does the carnival have a twitter feed?

Yes, @Carnivalofmath

January 23rd, 2010 | Tags:

Mathcad logo

Ever since PTC bought Mathcad from its original developers, Mathsoft, back in 2006 the future for the product has been uncertain.  The first PTC-led release of the software, Mathcad 14, followed a few months later to mixed reviews and it’s been very quiet ever since.  The only sign of life over the last couple of years has been a few minor bug-fix releases which, to be perfectly frank,  is rather insignificant compared to the competition.

All of this led me to write an article back in June 2009 called ‘Is Mathcad Dying?’ which garnered quite a lot of feedback from both the Mathcad user community and from PTC themselves.  The reaction from the user community ranged from people calling me some colourful names through to those who agreed with much of what I said and everything in between.  It quickly became apparent that there was a large user community who were fervently hoping that PTC would do something special with Mathcad rather than let it wither and die.  These users feel that Mathcad brings something unique to the technical software landscape; something that isn’t provided by the likes of Mathematica, MATLAB and Maple and they didn’t want it to go away.

In the meantime, some of the people at PTC got in touch with me to tell me that Mathcad is far from dying.  I learned that not only was a new release of Mathcad on the cards (Mathcad 15) but that they were also working on what was essentially a complete reboot of the system called Mathcad Prime.  They had also performed an internal company restructure which included the creation of a business unit specifically for Mathcad; this, I was told, would allow them to do much more with Mathcad than had been done before.  It all sounded very exciting and I was looking forward to a host of public updates but then it all went very quiet again.

Until now!

One of my contacts at PTC sent me a tweet last night to say that I might be interested in a blog post over at mathcad.wordpress.com and he was right.  Finally, everything that I had been told in confidence has been made official and more besides.  Mathcad 15 will be released later this year.  The date for Mathcad Prime is a little more vague but 2011 seems like a distinct possibility and there will be a virtual conference in mid-March where PTC will tell us more about its Mathcad strategy (I’ve already signed up).

I have to confess that I have never been a fan of Mathcad, preferring to use MATLAB, Mathematica and Maple, but I have been deeply impressed by the loyalty shown by some of its long-term users.  Some of these users have been kind enough to take the time to show me why they believe that Mathcad deserves such allegiance and I now realise that some of my earlier comments on the product were not as well thought out as they should have been.   So, I hope that these new developments by PTC not only repays this loyalty but also produces a product that I would want to use myself.

January 20th, 2010 | Tags:

Ever since version 6 of Mathematica was released (way back in 2007) I have received dozens of queries from users at my University saying something along the lines of ‘Plotting no longer works in Mathematica’ or ‘If I wrap my plot in a Do loop then I get no output.  The user usually goes on to say that it worked perfectly well in pre-v6 versions of Mathematica, is clearly a bug and could I please file a bug report with Wolfram Research?

It’s not a bug….it’s a feature!

If you have googled your way here and just want a fast solution to your problem then here goes.  I assume that you have code that looks like this

Do[
 Plot[Cos[n x], {x, -Pi, Pi}]
 , {n, 1, 3}
 ]

and you were expecting to get a set of nice plots (in this case 3) – one plot for each iteration of your loop. Instead, Mathematica 6 or above is giving you nothing…nada…zip! There are several ways you can ‘fix’ this and I am going to show you two. Option 1 is to wrap your Plot Command with Print

Do[
 Print[Plot[Cos[n x], {x, -Pi, Pi}]]
 , {n, 1, 3}
 ]

Option 2 is to use Table instead of Do

Table[
 Plot[Cos[n x], {x, -Pi, Pi}]
 , {n, 1, 3}
 ]

I am imaging that the average googler has now disappeared having got what they came for but some of you are possibly wondering why the above two ‘fixes’ work.  Here’s my attempt at an explanation.

Old versions of Mathematica (v5.2 and below) treated graphics very differently to the way that Mathematica works today. The output of a command such as Plot[] used to contain two parts – the first was a Graphics object which looked a bit like the following in the notebook front end

- Graphics -

This was the OutputForm of the actual symbolic result of the Plot[] command. The second part – the actual visualization of the plot – was effectively just a side effect that happened to be what us humans actually wanted.

In version 6 and above, the OutputForm of a Graphics object is its visualisation which makes a lot more sense then just - Graphics -. The practical upshot of this is that there is now no need for a ’side effect’ since the visualization of the plot IS the output.  If you are confused then this bit is explained much more eloquently in an old Wolfram Blog post.

That’s the first part of the story regarding plots in loops.  The second piece of the puzzle is to know that when you wrap a Mathematica expression in a Do loop then you suppress its output but you don’t suppress any side effects.  In version 5.2 the plot is a side effect and so it gets displayed on each iteration of the loop.  In version 6 and above, the plot is the output and so gets suppressed unless you explicitly ask for it to be displayed using Print[].

Does this help clear things up?  Comments welcomed.

January 15th, 2010 | Tags:

The Numerical Algorithms Group (NAG) is 40 years old this year and they have begun their celebrations by starting a company blog.  In their first blog post, one of the numerical library developers has asked the world a question:

“How useful would routines that provide particular solutions to the Painleve equations be to our customer base and to the research community in particular?”

I’ll confess that, until 10 minutes ago, I had never heard of the Painlevé equations but there are articles on Wikipedia and Mathworld to get you started if you are in the same boat as me.

If, on the other hand, you know all about them and can venture an opinion then head over to NAG’s new blog and say hi.

I am a big fan of the NAG’s products and you can see some of my posts about them at the following links:

January 8th, 2010 | Tags:

Did you make any New Year’s resolutions this year?  If you did then who will they help?  Just you?  Your family?  Your students?  The whole world?  If I am being honest then I have to say that most of the new-year’s resolutions I have made over the years tend to focus on myself because at my very core I am a bit selfish.  So, my resolutions tend to be things like “I want to get fitter”, “I’ll not stay late at work so much” or “I want to learn more Python programming.”

If I keep these resolutions then I’m going to be fitter, more knowledgeable and have a better work-life balance.  So far so selfish!

Over the last few days though I have made a rather different sort of new-years resolution.  Yes, I admit that it’s a bit late but why limit change to an essentially arbitrary date?  My new new year’s resolution is to give a little back to the community that has given me so much – the community of organisations and individuals who provide me with software – either for free or for such a trivial amount of money that it may as well be free.

Now I am not a rich man so I can’t give away great wads of cash and although I am a programmer I have neither the time nor the knowledge to provide significant amounts of code to any particualr project.  So what can I do?

Donations

Well, although I am not minted, I can easily afford the occasional small donation or two so I will start making them.  It’s already begun with my Sage bounty hunt and will continue with other projects over the year.  Another small donation I made recently was to buy the ‘Premium’ version of Aldiko – a great ebook reader for Android smartphones.  Aldiko is a free piece of software, has been downloaded by tens of thousands of users and is used by me on an almost daily basis.  I noticed that they had a ‘Premium’ version available for $1.99 but it turns out that it is identical to the free version.  The $1.99 simply represents a donation to the developers and it’s a donation I made without hesitation.  Doing the right thing for less than two dollars – getting the warm fuzzies has never been easier!

Bug reports and feedback

Thanks to my job and to running Walking Randomly I get to see how researchers, teachers, students and average joes use mathematical software quite a lot.  I get told about bugs, about feature wish lists, about gripes with licensing, performance issues…the list goes on and on.  The best way to get bugs fixed is to report them – first tell the developers and, if the bug is interesting/severe enough, tell the world.  I do this plenty with commercial software but I am going to make the effort more with free software from now on.  Feedback is part of the lifeblood of free software and developers need both the good and the bad.

Did you try out Octave, Maxima, Sage or Smath Studio and it didn’t work out?  Why didn’t it?  What did these packages have missing that forced you to turn to alternatives?  Try to be specific; saying ‘I tried it and it sucks’ is a rubbish piece of feedback because it’s just an opinion and gives the developers nothing to do.  Saying something like ‘I tried to calculate XYZ and it gave the following incorrect result whereas it should have given ABC’ is MUCH more productive.

Tutorials, examples and documentation

One comment I have heard over and over again from people who have tried free mathematical software and then turned their back on it is that the ‘documentation isn’t good enough’.  These people want more tutorials, more examples, more explanations and just more and better documentation.  Do you like writing?  Do you like fiddling with math software?  I do and so I intend on giving as many examples and tutorials as I can.  I also have a (moderately) successful blog so I can provide a publishing outlet for people who want to write such things but don’t want to start a blog of their own.  This has already begun too with Greg Astley’s tutorial on how to plot direction fields for ODE’s in maxima.  Contact me if you are interested in doing this yourself and we’ll discuss it.

Talk

I like to talk.  Many people who know me personally would probably go so far as to say I talk too much but I can use this to help towards my new resolution too.  I’m going to give short talks, demonstrations and seminars on free mathematical software to interested people over the coming year via various fora.  Maybe you could too?

So, in summary, I plan to do the following to give back to free software over the next decade and I invite you to do the same.

  • Give small, direct donations to some of my favourite open source and free software projects
  • Set up bounty hunts for particular features I want in various packages
  • Buy donation versions of Android software whenever possible
  • Publish as many examples of using software such as Sage, octave and maxima as I can
  • Help write tutorials and documentation
  • Give talks to help spread the word

I’ll admit that none of this will change the world but it will possibly help a few more people than “I resolve to get myself fitter.”

January 7th, 2010 | Tags:

I recently received a notification about the 2010 International Mathematica Symposium (IMS) which is due to take place in Beijing, China from July 16th this year.  The IMS is not run by Wolfram Research (although I think that Wolfram is a sponsor) but is run by Mathematica enthusiasts for Mathematica enthusiasts.  I was lucky enough to be able to attend both the 2008 IMS in Maastricht and the 2006 IMS in Avignon where I had a fantastic time, learned lots of stuff and met loads of people who just love Mathematica and mathematics.

I have to say that I have never been to a conference quite like the IMS before; the attendees were simply fizzing with enthusiasm and the range of talks and activities were wonderful.  In Avignon, I learned how to use Manipulate even before Mathematica 6 was released.  In Maastrict I was among the first to see some of the new features in Mathematica 7 and have seen Mathematica applied to subject areas as diverse as cancer research, high school math teaching, puzzle solving, quantum mechanics, electronics, radio astronomy and finance.  I’ve been taught Mathematica tricks from some of the very people who wrote the thing and have swapped programming methods and scripts with users of all levels.

The knowledge base of those attending the IMS ranges from people who eat, breathe and sleep Mathematica through to people who have only just started using it and everything in between.  I’ve met (and now consider among my friends) a statistics expert from Australia, a genetic algorithms expert from Canada and a college instructor from Finland among many others.  I’ve celebrated Mathematica’s 20th birthday in some underground caves, had my head read and also got a couple of very nice T-shirts which I love but my wife refuses to be seen with (she doesn’t like my MATLAB T-shirts either)!

There is usually a sprinkling of Wolfram employees among the attendees which gives you the chance to get the inside track on what is going on within Wolfram Research.  If you have a problem understanding something in Mathematica or there is a bug that winds you up then who better to talk to?  The IMS has also given me the chance to meet the authors of some of the most well known Mathematica books over the years which was fantastic.  Discussing a fun math problem with people like this and then watching them cook up a cool looking demonstration in minutes will surely get your imagination fired up.

Unfortunately, due to a distinct lack of funds, I probably won’t be at the IMS in Beijing but if you are into Mathematica and can make it there then I highly suggest you go.  You won’t regret it and I’d appreciate it if someone could send me the T-Shirt ;)

January 5th, 2010 | Tags:

This is the first post on Walking Randomly that isn’t written by me!  I’ve been thinking about having guest writers on here for quite some time and when I first saw the tutorial below (written by Manchester University undergraduate, Gregory Astley) I knew that the time had finally come.  Greg is a student in Professor Bill Lionheart’s course entitled Asymptotic Expansions and Perturbation Methods where Mathematica is the software of choice.

Now, students at Manchester can use Mathematica on thousands of machines all over campus but we do not offer it for use on their personal machines.  So, when Greg decided to write up his lecture notes in Latex he needed to come up with an alternative way of producing all of the plots and he used the free, open source computer algebra system – Maxima.  I was very impressed with the quality of the plots that he produced and so I asked him if he would mind writing up a tutorial and he did so in fine style.  So, over to Greg….

This is a short tutorial on how to get up and running with the “plotdf” function for plotting direction fields/trajectories for 1st order autonomous ODEs in Maxima. My immediate disclaimer is that I am by no means an expert user!!! Furthermore, I apologise to those who have some experience with this program but I think the best way to proceed is to assume no prior knowledge of using this program or computer algebra systems in general.  Experienced users (surely more so than me) may feel free to skip the ‘boring’ parts.

Firstly, to those who may not know, this is a *free* (in both the “costs no money”, and “it’s open source” senses of the word) computer algebra system that is available to download on Windows, Mac OS, and Linux platforms from  http://maxima.sourceforge.net and it is well documented.

There are a number of different themes or GUIs that you can use with the program but I’ll assume we’re working with the somewhat basic “Xmaxima” shell.

Install and open up the program as you would do with any other and you will be greeted by the following screen.
Maxima Tutorial 1

You are meant to type in the top most window next to (%i1) (input 1)
We first have to load the plotdf package (it isn’t loaded by default) so type:

load("plotdf");

and then press return (don’t forget the semi-colon or else nothing will happen (apart from a new line!)). it should respond with something similar to:

(%i1)  load("plotdf");
(%o1)  /usr/share/maxima/5.17.1/share/dynamics/plotdf.lisp
(%i2)

We will now race ahead and do our first plot. Keeping things simple for now we’ll do a phase plane plot for dx/dt = y, dy/dt = x, type:

plotdf([y,x]);

you should see something like this:
Maxima Tutorial 2

This is the Openmath plot window, (there are other plotting environments like Gnuplot but this function works only with Openmath) Notice that my pointer is directly below a red trajectory. These plots are interactive, you can draw other trajectories by clicking elsewhere. Try this.  Hit the “replot” button and it will redraw the direction field with just your last trajectory.

Before exploring any other options I want to purposely type some bad input and show how to fix things when it throws an error or gets stuck. Type

plotdf(y,x);

it should return

(%i3) plotdf(x,y);
Maxima encountered a Lisp error:

Error in SECOND [or a callee]: $Y is not of type LIST.

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
(%i4)

We forgot to put our functions for dx/dt,dy/dt in a list (square brackets). This is a reasonably safe error in that it tells us it isn’t happy and lets us continue.
Now type

plotdf([x.y]);

you should see something similar to
Maxima Tutorial 3

The problem this time was that we typed a dot instead of a comma (easily done), but worryingly when we close this message box and the blank plot the program will not process any commands. This can be fixed by clicking on the following in the xmaxima menu

file >> interrupt

where after telling you it encountered an error it should allow you to continue. One more; type

plotdf([2y,x]);

It should return with

  (%i5) plotdf([2y,x]);
  Incorrect syntax: Y is not an infix operator
  plotdf([2y,
           ^
  (%i5)

This time we forgot to put a binary operation such as * or + between 2 and y. If you come up with any other errors and the interrupt command is of no use you can still partially salvage things via

  file >> restart

but you will, in this case, have to load plotdf again. (mercifully you can go to the line where you first typed it and press return (as with other commands you might have done))
I will now demonstrate some more "contrived" plots (for absolutely no purpose other than to shamelessly give a (very) small gallery of standard functions/operations etc... for the novice user) there is no need to type the last four unless you want to see what happens by changing constants/parameters, they're the same plot :)

  plotdf([2*y-%e^(3/2)+cos((%pi/2)*x),log(abs(x))-%i^2*y]);
  plotdf([integrate(2*y,y)/y,diff((1/2)*x^2,x)]);
  plotdf([(3/%pi)*acos(1/2)*y,(2/sqrt(%pi))*x*integrate(exp(-x^2),x,0,inf)]);
  plotdf([floor(1.43)*y,ceiling(.35)*x]);
  plotdf([imagpart(x+%i*y),(sum(x^n,n,0,2)-sum(x^j,j,0,1))/x]);

I could go on…notice that the constants pi, e, and i are preceded by “%”. This tells maxima that they are known constants as opposed to symbols you happened to call “pi”, “e”, and “i”. Also, noting that the default range for x and y is (-10,10) in both cases; feel free to replot the first of those five without wrapping x inside “abs()” (inside the logarithm that is). remember file >> interrupt afterwards!

Now I will introduce you to some more of the parameters you can plug into “plotdf(…)”. close any plot windows and type

plotdf([x,y],[x,1,5],[y,-5,5]);

You should notice that x now ranges from 1 to 5, whilst y ranges from -5 to 5. There is nothing special about these numbers, we could have chosen any *real* numbers we liked. You can also use different symbols for your variables instead of x or y. Try

plotdf([v,u],[u,v]);

Note that I’ve declared u and v as variables in the second list. I will now purposely do something wrong again. Assign the value 5 to x by typing

x:5;

then type

plotdf([y,x]);

This time maxima won’t throw an error because syntactically you haven’t done anything wrong, you merely told it to do

plotdf([y,5]);

as opposed to what you really wanted which is

plotdf([y,x]);

Surprisingly to me (discovered as I’m writing this), changing the names of your variables like we did above won’t save you since it seems to treat new symbols as merely placeholders for it’s favourite symbols x and y. To get round this type

kill(x);

and this will put x back to what it originally was (the symbol x as opposed to 5).
You don’t actually have to provide expressions for dx/dt and dy/dt, you might instead know dy/dx and you can generate phaseplots by typing say

plotdf([x/y]);

In this case we didn’t actually need the square brackets because we are providing only one parameter: dy/dx (x will be set to t by maxima giving dx/dt = 1, and dy/dt = dy/dx = x/y)

A number of parameters can be changed from within the openmath window. Type

plotdf([y,x],[trajectory_at,-1,-2],[direction,forward]);

and then go into config. The screen you get should look something like this:
Maxima Tutorial 4

from here you can change the expressions for dx/dt, dy/dt, dy/dx, you can change colours and directions of trajectories (choices of forward, backward, both), change colours for direction arrows and orthogonal curves, starting points for trajectories (the two numbers separated by a space here, not a comma), time increments for t, number of steps used to create an integral curve. You can also look at an integral plots for x(t) and y(t) corresponding to the starting point given (or clicked) by hitting the “plot vs t” button. You can also zoom in or out by hitting the “zoom” button and clicking (or shift+clicking to unzoom), doing something else like hitting the config button will allow you to quit being in zoom mode click for trajectories again. (there might be a better way of doing this btw) You can also save these plots as eps files (you can then tweak these in other vector graphics based programs like Inkscape (free) or Adobe Illustrator etc..)

Interactive sliders

There are many permutations of things you can do (and you will surely find some of these by having a play) but my particular favourite is the option to use sliders allowing you to vary a parameter interactively and seeing what happens to the trajectories without constant replotting. ie:

plotdf([a*y,b*x],[sliders,"a=-1:3,b=-1:3"]);

Maxima sliders

Hopefully, this has been enough to get people started, and for what it’s worth, the help file (though using xmaxima, you’ll find this in the web-browser version) for this topic has a pretty good gallery of different plots and other parameters I didn’t mention.

just to throw in one last thing in the spirit of experimentation, is the following set of commands:

A:matrix([0,1],[1,0]);
B:matrix([x],[y]);
plotdf([A[1].B,A[2].B);

which is another way of doing the same old

plotdf([y,x]);

where here I’ve made a 2×2 matrix A, a 2×1 matrix B, with A[1], A[2] denoting rows 1 and 2 of A respectively and matrix multiplied the rows of A by B (using A[1].B, A[2].B) to serve as inputs for dx/dt and dy/dt

Tutorial written by Gregory Astley, Mathematics Undergraduate at The University of Manchester.

January 4th, 2010 | Tags:

I’m really late doing this article and it has already been done very well by MathNotations and 360.  There’s also a nice game involving the number 2010 over at Let’s play math.  They didn’t mention this fact though

2010 = 1+2-(3-4-5)*6*7*8-9

Which I think is nice.  Do you have any more interesting facts about the number 2010?