Archive for the ‘general math’ Category

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.

February 1st, 2008

In a recent post over at 360 the author was discussing how Joe Turner (a prof of musical composition) has formed a musical composition based on the expansion of Pi in base 12 and it sounds pretty good considering the fact that it is based on a random sequence. This was picked up by another blog I discovered recently (thanks to the carnival of mathematics) where the author asked if anyone else would mind producing similar compositions based on other mathematical constants.

On the train journey home from work I thought that I might be able to get Mathematica to produce simplified versions of these sort of compositions without too much effort. So I fired up my copy of Mathematica, plugged in some headphones (I was fairly sure that my fellow commuters would not appreciate the music of Pi as much as I) and set to work. Although I knew that Mathematica had sound capabilities I had never used them before so the help browser (as usual) was indispensable.

I am going to present the rest of this post as a tutorial, with Mathematica commands in bold followed by the output in normal tyle. This is my first attempt at a tutorial in a blog post so feedback would be welcomed.

From the help browser I discovered that you can represent a note in Mathematica using SoundNote. Middle C is represented by SoundNote[0], one semi-tone above middle C is SoundNote[1] , a whole tone above Middle C is SoundNote[2] and so on. You can also use negative numbers so that SoundNote[-1] is one semi-tone below middle C for example.

So far so good but I don’t want to just represent the notes symbolically – I want to actually play them. The way to do this is by wrapping a SoundNote expression with Sound[]. So to play a middle C just evaluate

Sound[SoundNote[0]]

A little interface appears that looks like the graphic above and when you click the play button (represented by a triangle) you will hear a piano sample at middle C that lasts for one second.

So far so good – I have a way of playing any integer I choose but I need to be able to play a list of notes if I am going to convert Pi to music. For those of you who don’t know much about Mathematica all you need to do to create a list of ANYTHING is separate them by commas and wrap the whole thing in curly braces {} so a list the integers 1 to 5 looks like this

{1,2,3,4,5}

A list of strings looks like this

{“hello”,”world”,”these”,”are”,”strings”}

Finally, a list of three SoundNotes looks like this:

{SoundNote[3], SoundNote[1], SoundNote[4]}

Wrap this list with Sound[] to play the three notes in sequence:

Sound[{SoundNote[3], SoundNote[1], SoundNote[4]}]

So all I need now is to get the digits of Pi (or any other number I might choose) into a list of SoundNotes. If all I wanted was the decimal expansion of Pi to any number of digits I choose then I could use the N command:

N[Pi,20]

3.1415926535897932385

Since the original article asks for Pi in base twelve I could use BaseForm[number,base] to display Pi in base 12 as follows:

BaseForm[N[Pi,20],12]

3.184809493b9186645712

This is all well and good but what I actually want is a list of the digits of Pi in base 12 and so I am going to use the RealDigits command which has the syntax RealDigits[number,base,number_of_digits]. This returns a list of the digits of your number according to your specified base and number of digits. So to get a list of the first 20 digits of Pi in base 12 I do

RealDigits[Pi, 12, 20]

{{3, 1, 8, 4, 8, 0, 9, 4, 9, 3, 11, 9, 1, 8, 6, 6, 4, 5, 7, 3}, 1}

Now this result is not just a simple list but is list of lists instead. The first element is a list of the digits of Pi in base 12 and the second element is the number of digits to the left of the decimal point. I only want the first element of this list of lists – namely the list of digits of Pi. To extract elements from lists in Mathematica you use double square brackets [[ ]] so to get the 3rd element of the list {1,4,9,16,25} you would type

{1,4,9,16,25}[[3]]

9

So to get that first list from the result of RealDigits[Pi, 12, 20] we do

RealDigits[Pi, 12, 20][[1]]

{3, 1, 8, 4, 8, 0, 9, 4, 9, 3, 11, 9, 1, 8, 6, 6, 4, 5, 7, 3}

So far so good but we are not done yet – somehow I need to wrap each integer in this list with SoundNote[]. One way to do this is by using Map[]. For example I can wrap each element of the list {3,1,4} with SoundNote by doing

Map[SoundNote,{3,1,4}]

{SoundNote[3], SoundNote[1], SoundNote[4]}

Applying this knowledge to the code we have built up so far allows us to write the following

Map[SoundNote,
RealDigits[Pi, 12, 20][[1]]
]

{SoundNote[3], SoundNote[1], SoundNote[8], SoundNote[4], SoundNote[8],SoundNote[0], SoundNote[9], SoundNote[4], SoundNote[9],SoundNote[3], SoundNote[11], SoundNote[9], SoundNote[1],SoundNote[8], SoundNote[6], SoundNote[6], SoundNote[4], SoundNote[5],SoundNote[7], SoundNote[3]}

I have started to format my Mathematica commands a bit to make them more readable by using multiple lines. This is not necessary but I find that if I don’t do this then I soon start to loose track of all those square brackets and get into a horrible mess. All that I have to do now is wrap this result with Sound[] and my job is done.

Sound[
Map[SoundNote,
RealDigits[Pi, 12, 20][[1]]
]]

By modifying this group of commands you can ‘play’ any expression you like to as many decimal places as you like but there is still work to be done. For example we are stuck with only using a piano and every note has a one second duration which is far from ideal but this post is getting a bit long so I will explain how to change these in a future post if anyone is interested.

By the time my train journey was over I had produced a little ‘applet’ in Mathematica using the principles described here along with the Manipulate function. It could play Pi in any number base using any one of a range of instruments with variable note speed. I fully intended on refining it a bit and submitting it to the Wolfram Demonstrations project but when I got home and regained internet access I discovered that I had been beaten to it by someone called Hector Zenil. Hector has written a very nice demonstration called Math Songs which does exactly what I had been trying to achieve and a whole lot more. Not only can you listen to Pi but you can also listen to e, Euler’s Gamma constant, the golden ratio, the Catalan constant and a few more I haven’t even heard of.

Oh well…you can’t win them all and Hector has done a fantastic job (better than I would have done to be honest). The best thing is that you don’t even need Mathematica to play with his creation. The free (but rather large) MathPlayer will do the job nicely for you.

So, have fun with Hector’s little demonstration and I hope the mini-tutorial here was useful to someone. As always feel free to leave comments.

Comments Off on Music From Mathematical Constants
January 25th, 2008

Welcome everyone to this, the 25th edition of the Carnival of Mathematics. The 25th anniversary of many things is usually considered to be a little bit special and is often marked by a ‘Silver’ celebration of some sort. For example, in 1977, Queen Elizabeth II of the United Kingdom celebrated her 25th Year on the throne with a Silver Jubilee celebration and the British Royal Mail commemorated the event by releasing the postage stamps below

Technically speaking of course I should have waited until the Carnival had been around for 25 years rather than 25 posts but I thought I would exercise a little poetic license here – I hope the host of the real Silver Jubilee Edition in 24 years time will accept my heartfelt apologies.

So what else is interesting about the number 25? Obviously it is a square number but did you know that it is also the smallest square that can be expressed as the sum of two squares \reverse \light 3^2+4^2. It is also a Cullen Number and is the atomic number of the element Manganese. Twenty-Five is also the name of a card game that is sometimes referred to as the national card game of Ireland.

Enough of the random meanderings and on with the show…

The first two submissions come from Mathmom over at Ramblings of a Math Mom who asks the question “Should gifted math students tutor others?” This is something I had personal experience of when I was at school (both good and bad) so I found her arguments interesting – feel free to head over there and add to the discussion, I am sure you will be made very welcome. Her second submission concerns probability-fallacies.

Next up we have Arvind Narayanan from the randomwalker’s journal (we have no connection other than both of our blogs have cool names!) who explains the mathematics behind part of Arthur Benjamin’s act in “Mathemagics” explained. I love this sort of stuff and may well be trying it out on some of my (long suffering) friends.

Over at Reasonable Deviations (I always think of Richard Feynman when I see that blog name), Rod presents an interesting problem in thinking about permutations. It has already sparked an interesting discussion in his comments section so why not head over and see if you can have a go at solving it? I tried, and failed, but you might have more luck.

Maria Miller highlights a link to Classic Math Mistakes over at Homeschool Math Blog which includes posters for classic howlers like “3.1hrs = 3 hours 10 minutes.” My favorite is “Finishing an exam early and then sitting doing nothing” which is clearly an elementary error when every true math geek knows that the correct procedure is to clear your throat loudly as you stand up to leave. This ensures that all of your classmates know that you have finished early and so must be better at maths than they are – just make sure that they never find out that your actual score on the exam was only 6% as it ruins the illusion.

The next submission comes from the blog of Mr Kruopatwa’s AP Calculus AB (2007-2008) class and concerns a favourite topic of mine – namely the evaluation of integrals. One of his students, Mr Siwwy (AKA Chris), asks the question ‘How “approximate” can approximate can be’ and discusses some of the elementary methods of numerical integration. In an ideal world we would always be able to come up with exact answers for our definite integrals but, as we all know, the world is far from ideal and so we often must make do with numerical approximations. Chris’ post discusses how you might start to go about making such approximations. I had not discovered this blog before now and, if all of the posts are going to be this good, then I look forward to reading more.

Over at Goods and Chattels, Amanda has been reminiscing about one of the problems from her student days in An interesting mathematics puzzle. Some maths problems seem trivial when you first read them and so you mutter “All too easy!” as you start working on them, expecting it to all be over after a few minutes. Several hours (and pieces of paper) later you give up in frustration, try to forget about it and get on with your life…but then another idea strikes you….another way of attacking it….this one might just work you know…just one more go….and it has you again. This is one of those problems. Have fun – but no peeking at the solution!

Sol’s Fun Math Blog has only been around for four months and yet it is one of the most read in the blath-sphere. Building up a Technorati rating of 88 in such a short amount of time says it all really – Sol writes stuff that the rest of us like to read and link to. His submission, “five constants tie together multiple branches of mathematics”, discusses some of the mathematics behind the equation that Feynman once called “The most remarkable formula in math”. I remember the first time I discovered this equation – my response was pretty similar to this one (don’t click if swearing offends you).

Denise discusses a quotation from Ralph P. Boas about what it takes to learn math over at her blog, Let’s Play Math. The phenomenon mentioned is something that I am sure we are all familiar with from our student (and teaching) days and her article is well worth a read. Any blog article that mentions a paper with the title “A Contribution to the Mathematical Theory of Big Game Hunting” is just begging to be read in my opinion.

What sort of calculations can do perform using nothing but your fingers and thumbs? Until I read Heathers’ article – Three finger tricks for multiplying – the best I could do was count to ten on them but now they quite a bit more versatile Head over to 360 if you want to upgrade your digits.

And now for something completely different…Rick from Big Ideas submitted an article called
Mathematical Beauty and the K4 Crystal. Check out that gorgeous looking bit of perl – If only I could write stuff like that :)

Finally, we have a last minute submission from Brent, the author of The Math Less Traveled, who has written the third installment of his “Recounting the Rationals” series.

And – with that – I’m done. I hope you have enjoyed reading this carnival as much as I enjoyed writing it. Thanks to everybody who submitted articles – I loved reading through them all. The next carnival is over at 360 so start thinking about what your submissions might be,

Mike

January 22nd, 2008

What is the only integer below 500,000 that has exactly 13 factors (including 1 and itself)? What is the next integer with this number of factors? For extra credit list all of the factors of these two numbers.

Finally, what is the only integer below 10 million that has exactly 23 factors (including 1 and itself)?

January 17th, 2008

If you have come here from the InsideHPC article and are a little confused it is because they used an incorrect link.  The article you are looking for is Vectorising code to take advantage of modern CPUs (AVX and SSE).

I haven’t had many submissions for the next carnival of mathematics yet and it is due to be published in just over a week. If you would like one of your articles to be featured then please let me know about it via the comments section of this post, email me or use the submission form. Please help me make the 25th carnival one of the best yet.

To find my e-mail address, start with the following and “subtract one” from each letter (for example, you should change the first “n” into a “m”, and so on). There will still be one incorrect letter but it will be obvious what you should correct it to. (I stole this idea from The Math Less Traveled and think it’s a great way to fool the spam bots).

njdibfm.q.dspvdifs@hpphmfnbjm.wpn

If you have Mathematica then evaluate the following to get it (don’t forget to correct the obvious mistake in the resulting email address)

FromCharacterCode[
 ToCharacterCode["njdibfm/q/dspvdifsAhpphmfnbjm/wpn"] - 1]

It annoys me that we have to go to such lengths to prevent spam but such is life.

January 14th, 2008

The 24th carnival of mathematics has been posted over at Ars Mathematica and includes articles ranging from Mathematics Magic to supersymmetric quantum mechanics. As with all Maths carnivals, it is well worth a read no matter what your level of mathematics is. The next carnival will be hosted here so please send your submissions to me via the submission form or, if that doesn’t work for you, let me know of your submission by posting a comment here.

Pretty much anything that has a reasonable amount of maths related content can be included in the carnival and can be at any level from elementary to cutting edge research so if you have never submitted anything before then why not have a go now?

January 11th, 2008

How good is your symbolic integral calculus? Do you think that you can do better than Mathematica? Let’s see – try and evaluate the following (there is a hint in the comments if you get stuck).

 \light \int_0^1\frac{x^3 + 1}{x^4 + 4x + 1}dx

My integration skills are a little rusty but I found the solution, log(6)/4, without too much difficulty (I have picked up the habit of writing log(x) when I mean ln(x) from using computer algebra packages too much) . Let’s see how Mathematica handles the same integration. Plugging the following command into version 6

Integrate[(x^3 + 1)/(x^4 + 4*x + 1), {x, 0, 1}]

gives a solution of

(RootSum[1 + 4*#1 + #1^4 & , Log[1 – #1]/(1 + #1^3) & ] -RootSum[1 + 4*#1 + #1^4 & , Log[-#1]/(1 + #1^3) & ] +
RootSum[1 + 4*#1 + #1^4 & ,(Log[1 – #1]*#1^3)/(1 + #1^3) & ] -RootSum[1 + 4*#1 + #1^4 & , (Log[-#1]*#1^3)/(1 + #1^3) & ])/4

Ugh! Applying the FullSimplify command doesn’t help so it seems that this is the best that Mathematica can do at the moment. If you evaluate this expression numerically then it agrees with the symbolic result but I think you would agree that Mathematica has not done a very good job here.

I found this integral while looking through the changelog of the latest version of Maxima – an open source mathematics package. If you try and evaluate it in pre-5.14 versions of Maxima then it will appear to hang (actually it will return a result eventually if you leave it long enough and have enough memory but it makes the Mathematica result look positively pretty). This has been fixed in version 5.14 and now issuing the command

integrate ((x^3 + 1)/(x^4 + 4*x + 1),x,0,1);

gives the result you would expect. So what went wrong – why does such a simple integral cause problems with these powerful software packages? The answer can be found in the full Maxima bug report for this issue – I will let you read it yourself if you are interested but in a nutshell pre 5.14 versions of Maxima were attempting to use a technique from complex analysis called contour integration to evaluate this integral. Contour integration is an amazingly useful technique that can be used to evaluate all sorts of definite integrals that are very difficult to do via other methods but using it in this case was a bad idea. It is possible that Mathematica tried to evaluate the integral in the same way but since it is closed source only the developers at Wolfram know the answer to that.

So this has been fixed in Maxima and I imagine that it will only be a matter of time before it is fixed in Mathematica but until that happens why not give this integral to your students and show them that, sometimes at least, they can do calculus better than Mathematica?