Archive for November, 2007

November 14th, 2007

According to the server logs one of the most popular posts I have made on Walking Randomly is the one I made a couple of months ago about the Logo programming language. Of course this may be due to the fact that this year marked the 40th anniversary of the language thus leading people to google for nostalgic reasons but it may also be because it is a genuinely interesting language. One thing that’s for certain is that programming in Logo can be a lot of fun and naturally leads to further study of concepts such as recursion, geometry and fractals.

With this in mind I thought it was high time I worked out a way of installing Logo on the pocket PC so that I can play with it on my new toy – the remarkable HTC TyTyn II My task set, I embarked on a set of very extensive google searches and to my surprise came up with very little.

The only native windows mobile solution that I could find was a free package called pocket turtle by Morten of Xpoint.dk. Although very much in the alpha stages of development (It only supports 6 commands and no user defined functions) this software looked promising and so I contacted the author to ask what he plans to do with it. His reply was prompt and friendly but unfortunately his future plans do not include any more pocket turtle development which is a shame but understandable since developing free software is a very time consuming affair. I tried to install it anyway since a little Logo is better than none at all but unfortunately could not get it on my new Windows Mobile 6 device.

Things were looking bleak on the pocket-pc logo front. Just as I was about to give up and resign myself to using my laptop to quench my Logo thirst, I came across a package called TinyLogo which was developed quite a while ago now. It is free, which is nice, but unfortunatley it only runs on PalmOS hardware. Now this is great news for the Palm users out there (Amanda – are you taking note of this?) but not so good for the likes of me.

A fantastic piece of (nonfree) software called StyleTap came to my rescue. Essentially what this does is emulate the Palm OS operating system on Windows Mobile devices so now you can run all of those must have Palm programs (such as TinyLogo) on your pocket PC.

I installed the trial version of StyleTap then installed TinyLogo on top of that and it worked like a charm. The TinyLogo icon appears on my device exactly as if it were a native application and the only way I can tell that this is not the case is that the menus look a little old fashioned (just like Palm OS) when I use it.

A quick read of the TinyLogo documentation later (recommended since the interface is not very intuitive in my opinion) and I was cooking on gas as the following screenshots demonstrate.

There is one minor problem. In order to write and edit TinyLogo scripts you need to use the standard PalmOS application ‘MemoPad’ and this is not included with StyleTap – probably for copyright reasons. All is not lost, however, since it turns out that MemoPad is not very good and so many people have developed free MemoPad replacements. One such example is jpad which also works on StyleTap without a hitch and has the added bonus of looking delightfully old fashioned which somehow enhanced the Logo experience for me.

I was so pleased with the StyleTap emulator that I ended up buying it – not just for TinyLogo you understand (honest) – but because there are quite a few Palm OS applications out there that I would quite like to play with again.

In summary using TinyLogo via StyleTap is a workable (albeit fiddly) solution for Logo enthusiasts who would like to code directly on their pocket PC. The interface is old fashioned and non-intuitive (well it was coded back in 1999 so this is to be expected) and because of this, and the fact that you have to pay for the StyleTap emulator, I would not recommend it for classroom use. Hopefully someone, somewhere will come up with a native Windows Mobile solution but for now TinyLogo on StyleTap is the best we have.

November 11th, 2007

While trawling around some of my favourite maths blogs I came across one from Good Math, Bad Math that left me slack jawed with wonder!

The British national lottery operator, Camelot, recently put out a scratch card game called “Cool Cash”. The rules are simple enough – there is a target temperature on the card and in order to win you have to uncover a temperature that is LOWER than the target.

This has been covered in several other blogs and the Manchester Evening News so I will not discuss it much further but will leave you to ponder the following quote from one confused customer.

On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn’t.

“I phoned Camelot and they fobbed me off with some story that -6 is higher – not lower – than -8 but I’m not having it.”

Perhaps this is why so many people are in debt here in the UK – they see a balance of -1000 pounds and assume that they are better off than last month when it was only -500.

November 8th, 2007

Are you geeky enough to have a favourite formula? Because I am and it turns out that I am not the only one either. I have just googled ‘favourite formula’ and the second result was a link to the aply named ‘Mathematics Weblog‘ where the author described an equation usually known as Euler’s formula.

 \light e^{i \pi} = -1

The Nobel prize winning physicist, Richard Feynman, once referred to this equation as ‘the most remarkable formula in mathematics’ and he really knew his stuff. Now I agree with Feynman, it really is an amazing formula since it connects some of the most important constants of mathematics in a small and elegant package, but it’s not my favourite. Elegant it may be but it’s not particularly useful.

My personal favourite is the general case of the above equation. Also called Euler’s equation, it is written as

 \light e^{ix}=\cos(x)+ i \sin(x)

Set  \light x to \light \pi and out pops Feynman’s favourite but we can do so much more with it than that and in this post I am going to focus on using it to obtain the trigonometric addition identities.

Read more…

November 6th, 2007

A user on comp.soft-sys.math.mathematica had a query about MD5 hashes in Mathematica that caught my attention recently. Now I was playing with MD5 in php a few days ago and one thing that I discovered was that the MD5 of a string seemed to vary depending on which program you used to generate it. For example if we use the unix command md5sum to hash the string ‘hello’ (Note the quotes are not part of the string) as follows

echo ‘hello’ | md5sum

we will get

b1946ac92492d2347c6235b4d2611184

All well and good but if we use the php md5 function to hash ‘hello’ (using the script here for example) then we get

5d41402abc4b2a76b9719d911017c592

Clearly different which was enough to annoy at least one person. It turns out that the reason for this is quite straightforward. The php function is returning the hash of the string ‘hello’ as required but the standard unix example is returning the hash of the string ‘hello\n’ where \n stands for a newline. Initially I thought this was interesting but then it hit me that the output of

echo ‘hello’

is in fact ‘hello\n’ so no one should have been surprised really. I would have quickly forgotten about this but someone was having a similar problem in Mathematica. In Mathematica strings are enclosed in double quotes so we hash the word hello as follows:

Hash[“hello”, “MD5”] // BaseForm[#, 16] &

5deaee1c1332199e5b5bc7c5e4f7f0c2

Which is completely different from our two cases above so what on earth is going on? Again, it turns out that the solution is, in fact, rather dull. It seems that Mathematica includes the enclosing double quotes when it produces the hash – which is not what I would expect at all. You can confirm this by running the string (including quotes) “hello” through the php md5 function.

I know its not exactly earth shattering stuff but I thought that I would write it up just in case someone else wondered about this stuff and was googling for it.

TOP