## Archive for September, 2009

So here’s a way of using Mathematica that, I have to admit, never occurred to me.

Essentially the idea is to make a big, empty graphic and then use the 2d drawing tools palette tools along with equation palettes and the ‘Evaluate in place’ menu item to produce a Mathcad-like interface. I like it!

It’s a neat trick but I highly doubt that it would be enough to lure Mathcad users away from their application of choice. Any thoughts?

Among my friends I am the resident mathematics nerd and so I get asked all sorts of weird and wonderful little questions ranging from the trivial to the impossible to answer. One such question that came up while on a night out was ‘why is a minus times a minus equal to a plus?’

I have to admit that I couldn’t come up with an answer that satisfied my non-mathematical friend which bugged me no end so I asked around….’How would you explain it?’. I asked on Twitter, I asked in my office, I asked some math teachers I know. I even came up with a ‘proof’ (I am an ex-physicist so I apologise if this is considered to be far from rigorous) as follows.

From the distributive law of multiplication we have

a*(b+c) = a*b + a*c

which holds for all real numbers. So it will hold if we put a=-1, b=1 and c=-1 right? let’s do it!

(-1)*(1+(-1)) = (-1)*1 + (-1)*(-1)

1+(-1) = 0 and -1*1 = -1 so we get

(-1)*0 = -1 + (-1)*(-1)

0 = -1 + (-1)*(-1)

rearrange to get

1 = (-1)*(-1)

Simple enough but not exactly intuitive is it? By the way, would any proper mathematicians care to comment as to whether this constitutes a proof or not?

Ideally I wanted an explanation that was completely intuitive and so far the best I have come across is the explanation from my friend Paul over at Crossed Streams who’s fiancee asked us this very question while we were all on a night out. Other good explanations involved ideas such as vectors and direction but when we tried those out on our target we were met with suspicion – ‘I thought we were talking about **numbers** and you explain using **vectors**!’

What fascinated me was that my tweets asking for explanations were possibly the most popular I have ever made. I had people phone me at my office to ask ‘So did anyone come up with a good explanation then?’

A minus times a minus is a plus….everyone knows it….but how would you explain it such that even the least mathematical person would grok it?

Welcome to the 58th Carnival of Maths – the late edition! I should have published this a couple of days ago but work and life commitments got in the way and I have only now found time to put it together. So, working on the assumption that late is better than never let’s get on with the show.

Whenever I discuss mathematics on this blog I often focus on using technology and so naturally I turned to technology to help me answer the traditional carnival question ‘**What is interesting about the number n?**‘ – where n is the edition number of the carnival being hosted. So, let’s see what I can find out about the number 58 using the best technology the web can offer.

The Number Gossip website informs me that 58 is the smallest Smith number (in base 10) with a prime sum of digits. In addition (and more mundanely), 58 is also composite, deficient, even, evil and square free. Wolfram Alpha also has a lot to say about the number 58 such as the fact that it is an idoneal number and that it can be expressed as the sum of two squares: 58= 3^{2} + 7^{2}. Wolfram Alpha doesn’t finish there though since it also gives a wealth of other trivia about 58 such as how it can be written in binary, Roman Numerals, Greek, Babylonian and Mayan. It tells us that its prime factorisation is 2*29, that 58 is the ASCII code for a colon along with the set of quadratic residues modulo 58. Finally, it finishes off by telling us that

is a near integer. A spot of googling helps me discover that 58 is the sum of the first seven prime numbers (2+3+5+7+11+13+17=58) and is also the sum of the totient function for the first thirteen integers . Hmmm, fascinating! However, enough of the number trivia and on with the show.

First up, we have a post from Jason Dyer of Number Warrior where he analyses one of his baby daughter’s favourite toys. That’s right ladies and gentlemen, only 6 months old and already inspiring mathematics.

Brent Yorgey, of Math Less Travelled fame submits the post Challenge #12, Part II, where he discusses counting “hyperbinary” representations (like binary representations, but allowing up to two copies of each power of two instead of just one). If you thought this carnival was late then you ain’t seen nothing yet ;)

Pat Ballew, author of the aptly titled Pat’s blog, sent in two related submissions for this edition of the carnival. First up is a post about a problem and its solution in ‘problems from the land down under‘ (I don’t know about you but I can’t read that title without thinking of a certain song from the 80’s). Pat worked on making the solution to this particular problem more understandable and, with a little help from his friends, he came up with a graphical solution.

The next submission comes from the blog Math with my kids where the writer asks some questions about sequences of rational numbers. He knows the answers to four of the questions but the fifth question is open as far as he knows.

Moving over to The Endeavour, we have two related submissions from John D Cook all about The Mercator Projection and its inverse.

Finally, we have a submission from Paul Brabban who’s non-mathmo fiancee asked him ‘Why is a minus times a minus equal to a plus?’ How would you answer this question if asked?

And that’s pretty much it for this edition of the carnival – or at least I think it is. I had to pull two of these submissions out of my spam bin so it seems that the filter has been a bit over-zealous recently. I have published everything that was submitted to me so if you submitted something and it is not in this post then you have fallen foul of the spam filter gremlins. If you let me know via a comment to this post in the next few days then I’ll fix the situation.

Thanks to everyone who submitted.

I was recently given the task of converting a small piece of code written in R, the free open-source programming language heavily used by statisticians, into MATLAB which was an interesting exercise since I had never coded a single line of R in my life! Fortunately for me, the code was rather simple and I didn’t have too much trouble with it but other people may not be so lucky since both MATLAB and R can be rather complicated to say the least. Wouldn’t it be nice if there was a sort of Rosetta Stone that helped you to translate between the two systems?

Happily, it turns out that there is in the form of The MATLAB / R Reference by David Hiebeler which gives both the R and MATLAB commands for hundreds of common (and some not so common) operations.

While flicking through the 47 page document I noted that there are a few MATLAB commands for which David hasn’t found an R equivalent (possibly because there simply isn’t one of course). For example, at number 161 of David’s document he describes the MATLAB command

**yy=spline(x,y,xx) **

which he describes as

*‘Fit cubic spline with “not-a-knot” conditions (the first two piecewise cubics coincide,as do the last two), to points (xi , yi ) whose coordinates are in vectors x and y; evaluate at points whose x coordinates are in vector xx, storing corresponding y’s in yy.’*

At the moment David doesn’t know of an R equivalent so if you are a R master then maybe you could help out with this extremely useful document?

The 58th Carnival of Maths will be hosted here on Friday 25th September and so I am looking for submissions. Pretty much anything goes as long as it’s got something to with mathematics from advanced research through to the very basics. The 57th carnival was hosted last week over at the blog 360 so head over there to see what it’s all about.

The carnival submission form no longer works but you can send your submissions in as comments to this post (I will supress them from publication to avoid spoiling the surprise), by email or send me a message on Twitter. All I need is a link and a brief discussion about what the post is about – I’ll do the rest.

This isn’t the first time that the carnival has been hosted at Walking Randomly – I also hosted the 25th and 33rd editions so feel free to take a look at those too.

In his blog post, Factoring Schmactoring, Sam Shah took a look at how many quadratic equations of the form* x^2+bx+c* = 0 (where *b* and *c* are integers) could be factored over the integers and produced a chart that was a powerful reminder of just how few of these there are.

After reading his post I fired up Mathematica and set to work extending Sam’s original chart to include negative values of *b* and *c* – the result of which is shown below. Out of 441 different quadratic equations, only 76 have integer solutions which is only 17.23%, and yet these are the only ones that succumb to the heavily drilled and killed method of factoring.

Sam and his commentators discussed the serious question of whether or not we should even be teaching factoring these days (for the record, I think we should) but my concerns were much less lofty. I wondered if I’d make something pretty if I did a similar chart to the one above but for values of *b* and* c* ranging from -100 to 100.

OK, so it’s not so pretty but it is possibly even more striking than the original charts – there is a LOT of red. Next, I wondered about values of *a* (the *x^2* coefficient) other than 1 and thought that this was the perfect situation for a Manipulate (Click on the image to download an interactive version which can be used in either Mathematica or the free Mathematica Player):

Of course, when dealing with values of *a* other than one, we should include the possibility of rational solutions so let’s do that and assign rational solutions to the colour blue – again click on the image below for the Mathematica-Payer compatible interactive version.

I’m not really going anywhere with this – just having a bit of fun with Mathematica but comments are welcome.

Just a quick note to say that I’ve released version 0.15 of PyNAG – my Python interface to the NAG C library and given it its own dedicated page on Walking Randomly. New features include

- Basic support for 165 functions from Mark 8 of the NAG C library.
- 29 simple but fully functional examples.
- Added initial support for NAG’s Complex structure.

May 2009 saw the launch of STS-125, a NASA Space Shuttle mission which conducted a set of upgrades on the Hubble Space Telescope. As well as making the space telescope more powerful than it has ever been before, the upgrades included repairs and replacements that would help Hubble last until at least 2014.

As of today we can see some of the results of all this work since NASA has released the first set of pictures from the upgraded system including the one below which is of NGC 6302 or, to give it its more snappy title, the Butterfly Nebula. Head over to NASA’s website for the full story along with high resolution images.

Smath Studio is a freeware alternative to Mathcad developed by Andrey Ivashov for Windows, Linux and Windows Mobile. The latest release, version 0.85, was made available yesterday for all platforms and includes a lot of new functionality combined with a set of bug-fixes. A small selection of the improvements is shown below but you should head over to the SMath forum to see the full list of changes

- Every page now has its own thread for evaluation – The user can evaluate pages even if evaluation of one of them in progress;
- Multi-threading implemented for the Plot Controls;
- Added ability to convert English symbols of the Math and Text Controls to Greek characters with a Ctrl+G keystroke;
- New functions implemented: eval(..), polyroots(..), reverse(..), sort(..), rsort(..), csort(..), normi(..), norm1(..), norme(..), linterp(..), cinterp(..) and ainterp(..);
- Functions for(..) and while(..) condition evaluating improved;
- Added support for Infinity into Symbolic Library;
- Function if(..) can be used in symbolic calculations now;
- Native support of functions added: abs(..), trunc(..), mod(..), round(..) in Symbolic Library;
- Composition of Logarithms simplification added into Symbolic Library;
- Danish translation added;

SMath Studio is an extremely promising project that has already caught the interest of many Mathcad users (it even has **basic** compatibility with Mathcad’s file format) and is well worth the download. Let me know if you try it out.

**More about free mathematical software from Walking Randomly
**

- Maxima Tutorial – plotting direction fields for 1st order ODEs
- Interactive Fourier Series with SAGE math

**Update 3rd April 2010: version 0.85 is now out of date. Click here for the latest version of SMath Studio.**