Archive for February, 2008

February 29th, 2008

I love playing around with computer algebra software, which is useful since supporting them is part of my day job, and I also love reading well written blogs that offer little tidbits of advice and interesting examples. Fairly recently, the companies and groups that actually produce the software have started writing blogs.

Of these, some of my favorites include Doug’s Pick of the Week (Mathworks’ Matlab), Wolfram’s Blog (Mathematica), Loren on the Art of MATLAB, and the Sage Math blog.

The Mathworks’ have just launched a new one, Seth on Simulink, which looks like it has got real potential. Simulink is a part of Matlab that has been on my ‘stuff to learn’ list for a while now and so I look forward to reading what Seth has to say about it.

February 29th, 2008

I read a lot of blogs concerning topics such as numerical computing, programming and computer algebra and most of the time the subject matter can be a bit…well…hard! The articles concerned can often be interesting and very useful but it can take a heck of a lot of concentration on my part before I can properly grok what the author is trying to say.

Sometimes though I come across something that is both useful and interesting and also so mind-numblingly simple that I wonder why on earth I didn’t think of it before. A case in point is Loren’s recent “Art of Matlab” article called “Should min and max marry?”.

I won’t re-iterate what she has written since she has done a great job and makes her point well. I am also currently busy implementing her idea in a piece of code I am writing at the moment while pretending to everyone around me that its such an obvious idea that I had thought about it well in advance!

February 28th, 2008

At some point in the future I am going to need to do some Java programing for work-related purposes and so I thought I should set up my Ubuntu based laptop for Java development. Everything you need to do this are in the Ubuntu repositories so the installation went without incident but I hit a brick wall when I tried to compile and run this very simple program

class myfirstjavaprog
{
   public static void main(String args[])
   {
      System.out.println("Hello World");
   }
}

I compiled this with the command

javac myfirstjavaprog.java

The .class file was produced without any problems but when I tried to run it with

java myfirstjavaprog

I got a hideous looking error message that started off like this

exception in thread “main” java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

All that for a Hello World program! This was not a good start but it turns out that there is an easy fix. The version of Java being used by my java command was different from that being used by my javac command and they need to be the same. The commands that allow you to configure Java versions on Ubuntu are

sudo update-alternatives –config java

sudo update-alternatives –config javac

Ensure that they are set to use the same version and you should be good to go.

February 25th, 2008

The following open-source mathematical applications were recently updated:

Lyx (version 1.5.4) – Lyx is a document processor that is essentially a front-end for Latex. If you need to write a document that contains a lot of Mathematics but don’t want to have to learn Latex then this may be for you.

Mathomatic (version 12.8.7) – Mathomatic is is general purpose computer algebra system that has been in continuous development for over 20 years.

SAGE (version 2.10.2) – SAGE is the result of a project that is attempting to produce a viable open source alternative to commercial maths packages such as Magma, Maple, Mathematica, and MATLAB.

February 19th, 2008

There is an odd bug in Matlab 2007b that only seems to affect certain machines running windows. When you try to start it the splash screen displays very briefly and goes away, but Matlab never actually starts. The way to fix it is to create an environment variable called MATLAB_RESERVE_LO and set its value to 0

February 14th, 2008

A couple of weeks ago I started thinking about Valentine’s day and, since I like equations that have interesting plots so much, I wondered if I could find one that had a heart-shaped graph. A quick google search came up Wolfram Research’s Heart Surface page.

The main page described a couple of heart shaped algebraic surfaces which looked nice but there were a few more on the Mathematica notebook that the page linked to. This notebook was rather old and included plots from old versions of Mathematica so on the train ride home I wrapped these equations in some Manipulate functions and sent the resulting demo to Wolfram. The result was published today on the Wolfram Demonstrations site.

heart demo

Essentially all this demo does is use Mathematica’s ContourPlot3D function to plot the curves formed from the following equations and allow you to play with the results a bit.

Nordstrand
 \light -\frac{8}{45} x^2 z^3-y^2 z^3+\left(\frac{32 x^2}{9}+2 y^2+z^2-1\right)^3 = 0

Kuska

 \light -\frac{1}{10} x^2 z^3-y^2 z^3+\left(2 x^2+y^2+z^2-1\right)^3=0

Taubin

 \light -x^2 z^3-\frac{9 y^2 z^3}{80}+\left(x^2+\frac{9 y^2}{4}+z^2-1\right)^3=0

Trott

 \light 320 \left(-x^2 z^3-\frac{9 y^2 z^3}{80}+\left(x^2+\frac{9 y^2}{4}+z^2-1\right)^3\right)=0

Each equation is named after the person who first wrote it down (to my knowledge at least). It’s a simple demo but I hope you like it.

Happy Valentine’s day.

February 14th, 2008

I imagine that most of the people reading this will know what the Tangram puzzle is but just in case you are not one of them here is a quick excerpt from the Wikipedia page which says it all:

“Tangram (Chinese: 七巧板; pinyin: qī qiǎo bǎn; literally “seven boards of skill”) is a dissection puzzle. It consists of seven pieces, called tans, which fit together to form a shape of some sort. The objective is to form a specific shape with seven pieces. The shape has to contain all the pieces, which may not overlap. ”

The classical Tangram puzzle looks like this:

tangram

It is possible to make many shapes from these pieces; some of which are below (taken from tangrams.ca)

Tangram shapes

If you would like to have a go at making your own Tangram shapes then you can make your own Tangram set out of paper, buy a nice wooden one, try this java applet or use this Mathematica demonstration (written by Enrique Zeleny) using the free Mathplayer from Wolfram Research. There is even a Tangram game for the Nintendo DS!

In the week leading up to Valentine’s day I wondered if there is a standard variation of the classical Tangram puzzle that is constructed from a heart shape and I was delighted to discover that there is. Using Enrique’s Mathematica code as a starting point I wrote a demonstration called Broken Heart Tangram and it was published on the Wolfram Demonstrations site today.

heart tangram

I hope you have fun with this demonstration and would love to see some of the shapes that you come up with. As always, comments are welcomed.

Other articles you may like

February 14th, 2008

For my final Valentine’s day post I thought I would share a minor discovery I made while playing around with the polar equation

\light r=1-\sin(n\theta)

When n=1 the graph of this equation is a rotated cardioid which is exactly what I expected after reading the Math World page on the Heart Curve.

While playing around with the parameters I discovered that if you increase the value of n (to 10 say) then the resulting plot looks like a flower.

Very apt considering the time of year I think. If you would like to play with this equation yourself then feel free to try my very simple Wolfram Demonstration which was published today.

February 11th, 2008

The 26th carnival of mathematics has been posted over at 360 and includes a fantastic set of links. My favorite is the post on visualising complex analysis from the Teaching College Math Technology blog because I have a ‘thing’ for complex analysis but there is something for everyone in this first anniversary edition of the carnival so please do check it out.

February 6th, 2008

A little while ago I discovered that if you plot the following equation over a certain range then the result is rather surprising.

\light f(x,y)=e^{-x^2-\frac{y^2}{2}} \cos (4 x)+e^{-3 \left((x+0.5)^2+\frac{y^2}{2}\right)}

A lot of people seemed to like this post and quite a few people reproduced the graph on their website so I thought I would revisit it. To allow people to play with this equation I have written a Wolfram Demonstration which was published yesterday; a screen shot is below.

 

Head over to Wolfram’s site in order to download it (and the source code if you wish). Remember you do not need to have a copy of Mathematica in order to run demonstrations such as this one – the free MathPlayer will do the job nicely.