## Archive for the ‘general math’ Category

My attention was recently drawn to a Google+ post by JerWei Zhang where he evaluates 2^3^4 in various packages and notes that they don’t always agree. For example, in MATLAB 2010a we have 2^3^4 = 4096 which is equivalent to putting (2^3)^4 whereas Mathematica 8 gives 2^3^4 = 2417851639229258349412352 which is the same as putting 2^(3^4). JerWei’s post gives many more examples including Excel, Python and Google and the result is always one of these two (although to varying degrees of precision).

What surprised me was the fact that they disagreed at all since I thought that the operator precendence rules were an agreed standard across all software packages. In this case I’d always use brackets since _I_ am not sure what the correct interpretation of 2^3^4 should be but I would have taken it for granted that there is a standard somewhere and that all of the big hitters in the numerical world would adhere to it.

Looks like I was wrong!

Consider a periodic sequence, seq_{p}, with period p

seq_{p} = *a*_{1}, *a*_{2}, …, *a*_{p}, *a*_{1}, *a*_{2}, …, *a*_{p}, *a*_{1}, *a*_{2}, …, *a*_{p}, …

Two sub-sequences, each of length N where 2< N< p, are produced by choosing two random start points in seq_{p} and using the next N-1 numbers. What is the probability that these two sub-sequences will overlap?

If you take M>2 such length N sub-sequences then what is the probability that **any** two will overlap?

For a more concrete example, assume that p = 2^19937 – 1 (yes, a very big number) and consider 10,000 sub-sequences each of length 10^9.

Disclaimer: I don’t have the solution to this and haven’t yet tried to find it

Consider this indefinite integral

Feed it to MATLAB’s symbolic toolbox:

int(1/sqrt(x*(2 - x))) ans = asin(x - 1)

Feed it to Mathematica 8.0.1:

Integrate[1/Sqrt[x (2 - x)], x] // InputForm (2*Sqrt[-2 + x]*Sqrt[x]*Log[Sqrt[-2 + x] + Sqrt[x]])/Sqrt[-((-2 + x)*x)]

Let x=1.2 in both results:

MATLAB's answer evaluates to 0.2014 Mathematica's answer evaluates to -1.36944 + 0.693147 I

Discuss!

Matt Tearle has produced a MATLAB version of my Interactive Slinky Thing which, in turn, was originally inspired by a post by Sol over at Playing with Mathematica. Matt adatped the code from some earlier work he did and you can click on the image below to get it. Thanks Matt!

Over at Playing with Mathematica, Sol Lederman has been looking at pretty parametric and polar plots. One of them really stood out for me, the one that Sol called ‘Slinky Thing’ which could be generated with the following Mathematica command.

ParametricPlot[{Cos[t] - Cos[80 t] Sin[t], 2 Sin[t] - Sin[80 t]}, {t, 0, 8}]

Out of curiosity I parametrised some of the terms and wrapped the whole thing in a Manipulate to see what I could see. I added 5 controllable parameters by turning Sol’s equations into

{Cos[e t] - Cos[f t] Sin[g t], 2 Sin[h t] - Sin[i t]}, {t, 0, 8}

Each parameter has its own slider (below). If you have Mathematica 8, or the free cdf player, installed then the image below will turn into an interactive applet which you can use to explore the parameter space of these equations.

Here are four of my favourites. If you come up with one that you particularly like then feel free to let me know what the parameters are in the comments.

I saw a great tweet from Marcus du Sautoy this morning who declared that today, June 28th, is a perfect day because both 6 and 28 are perfect numbers. This, combined with the fact that it is very sunny in Manchester right now put me in a great mood and I gave my colleauges a quick maths lesson to try and explain why I was so happy.

“It’s not a perfect year though is it?” declared one of my colleauges. Some people are never happy and she’s going to have to wait over 6000 years before her definition of a perfect day is fulfilled. The date of this truly perfect day? 28th June 8128.

**Update:** Someone just emailed me to say that 28th June is Tau Day too!

I do the administration for the Carnival of Mathematics and am very happy to announce that the 77th edition has been published over at Jost a Mon. If you are unsure what a Math carnival is then check out my introductory article or just read some past editions from either the Carnival of Math itself or its sister publication, Math Teachers at Play which is run by Denis of Let’s Play Math fame.

The next Carnival of Math is scheduled to be hosted over at JimWilder.com and the submission form for articles is open now. If you’d like to host a future carnival of math on your blog or website then please contact me for further details.

Last month I published an article that included an interactive mathematical demonstration powered by Wolfram’s new CDF (Computable Document Format) player. These demonstrations work on many modern web-browsers including Internet Explorer 8 and Firefox 3.6. So, how do you go about adding them to your own websites?

**What you need**

- Mathematica 8.0.1 or above to create demonstrations. Viewers of your demonstration only need the free CDF player for their platform.
- A modern browser such as Internet Explorer 8, Firefox 3.6 or Safari 5.
- Basic knowledge of HTML, uploading files to a webserver etc. If you maintain a blog or similar then you almost certainly know enough

Our aim is the following, very simple, interactive demonstration.

If all you see is a static image then you do not have the CDF player or Mathematica 8 correctly installed. Alternatively, you are using an unsupported platform such as Linux, iOS or Android.

**Step 1 – Create the .cdf file**

Fire up Mathematica, type in and **evaluate** the following code. You should get an applet similar to the one above.

Manipulate[ Series[Sin[x], {x, 0, n}] , {n, 1, 10, 1, Appearance -> "Labeled"} ]

Save it as a .cdf file called** series.cdf** by clicking on **File**->**Save as –** Give it the File Name** series.cdf** and change the **Save as Type** to** Computable Document (*.cdf)**

** **

**Step 2 – Get a static screenshot**

Not everyone is going to have either Mathematica 8 or the free CDF player installed when they visit your website so we need to give them something to look at. So, lets give them a static image of the Manipulate applet. As a bonus, this will act as a place holder for the interactive version for those who do have the requisite software.

Open series.cdf in Mathematica and left click on the bracket surrounding the manipulate (see below). Click on **Cell**->**Convert To**->**Bitmap**. Then click on **File**->**Save Selection As **. Make sure you change .pdf to something more sensible such as .png

Don’t save your .cdf file at this point or it won’t be interactive. Re-evaluate the code again to get back your interactive Manipulate.

Here’s one I made earlier – series.png

**Step 4 – Hide the source code**

In this particular instance, I don’t want the user to see the source code. So, lets sort that out.

- Open series.cdf in Mathematica if you haven’t already and make sure that the Manipulate is evaluated.
- Left click on the inner cell bracket surrounding the Manipulate source code only and click on
**Cell**->**Cell Properties**and un-tick**Open**

**Step 5 – Hide the cell brackets
**

Those blue brackets at the far right of the Mathematica notebook are called the Cell brackets and I don’t want to see them on my web site as they make the applet look messy.

- Open series.cdf in Mathematica if you haven’t already
- Open the option inspector:
**Edit**->**Preferences**->**Advanced**->**Open Option Inspector** - Ensure
**Show option values**is set to**“series.cdf”**and that they are sorted**by category**.**Apply**. - Click on
**Cell Options**->**Display options**and in the right hand pane set**ShowCellBracket**to False - Click
**Apply**

Before you save series.cdf ensure that the applet is interactive and not a static bitmap. If it isn’t interactive then click on **Evaluation**->**Evaluate notebook **to re-evaluate the (now hidden) source code. Also ensure that there is nothing but the applet anywhere else in the notebook.

**Step 6 – Get interactive on your website**

Upload series.png and series.cdf to your server. The next thing we need to do is get the static image into our webpage. Here’s what the HTML might look like

<img id="Series_applet" src="series.png" alt="Series demo" />

Obviously, you’ll need to put the full path to series.png on your server in this piece of code. The only thing that is different to the way you might usually use the img tag is that it includes an** id**; in this case it is **Series_applet**. We’ll make use of this later.

The magic happens thanks to a small javascript applet called the CDF javascript plugin. Version one is at http://www.wolfram.com/cdf-player/plugin/v1.0/cdfplugin.js and that’s the one I’ll be using here. Here’s the code which needs to be placed **before** the img tag in your HTML file.

<script src="http://www.wolfram.com/cdf-player/plugin/v1.0/cdfplugin.js" type="text/javascript"></script><script type="text/javascript">// <![CDATA[ var cdf = new cdf_plugin(); cdf.addCDFObject("Series_applet", "series.cdf", 403,109); // ]]></script>

The only line you’ll need to change if you use this for anything else is

cdf.addCDFObject("Series_applet", "series.cdf", 403,109);

where **Series_applet ** is the id of the image we wish to replace and series.cdf is the cdf file we want to replace it with. The numbers 403,109 are the **dimensions of the applet**. These will not be the same as the .png file as the dimensions of the .cdf file are slightly larger. I used trial and error to determine what they should be as I haven’t come up with a better way yet (suggestions welcomed).

So that’s it for now. Hope this mini-tutorial was useful. Let me know if you upload any demonstrations to your own website or if you have any comments, questions or problems.

**Update (6th June 2011)**

Thanks to ‘Paul’ in the comments section, I have discovered that this mechanism won’t work for .cdf files that Wolfram deem are unsafe. According to Paul the definition of unsafe is as follows:

Dynamic content is considered unsafe if it:

- uses File operations
- uses interprocess communication via MathLink Mathematica Functions
- uses JLink or NETLink
- uses Low-Level Notebook Programming
- uses data as code by Converting between Expressions and Strings
- uses Namespace Management
- uses Options Management
- uses External Programs

I love mathematics and I also love gadgets so you’d think that I’d be overjoyed to learn that there are a couple of new graphical calculators on the block. You’d be wrong!

Late last year, Casio released the Prizm colour graphical calculator. It costs $130 and its spec is pitiful:

- 216*384 pixel display with 65,536 colours
- 16Mb memory
- The CPU is a SuperH 3 running at 58Mhz (according to this site)

More recently, Texas Instruments countered with its color offering, the TI-NSpire CX CAS. This one costs $162 (source) and its specs are also a bit on the weak side but quite a bit higher than the Casio.

- 320*240 pixels with 65,536 colours
- 100Mb memory
- CPU? I have no idea. Can anyone help?

If you are into retro-computing then those specs might appeal to you but they leave me cold. They are slow with limited memory and the ‘high-resolution’ display is no such thing. For $100 dollars more than the NSpire CX CAS I could buy a netbook and fill it with cutting edge mathematical software such as Octave, Scilab, SAGE and so on. I could also use it for web browsing,email and a thousand other things.

I (and many students) also have mobile phones with hardware that leave these calculators in the dust. Combined with software such as Spacetime or online services such as Wolfram Alpha, a mobile phone is infinitely more capable than these top of the line graphical calculators.

They also only ever seem to be used in schools and colleges. I spend a lot of time working with engineers, scientists and mathematicians and I hardly ever see a calculator such as the Casio Prizm or TI NSpire on their desks. They tend to have simple calculators for everyday use and will turn to a computer for anything more complicated such as plotting a graph or solving equations.

One argument I hear for using these calculators is ‘*They are limited enough to use in exams.*‘ Sounds sensible but then I get to thinking ‘* Why are we teaching a generation of students to use crippled technology?*‘ Why not go the whole hog and ban ALL technology in exams? Alternatively, supply locked down computers for exams that limit the software used by students. Surely we need experts in useful technology, not crippled technology?

So, I don’t get it. Why do so many people advocate the use of these calculators? They seem pointless! Am I missing something? Comments welcomed.

**Update 1: **I’ve been slashdotted! Check out the slashdot article for more comments.

**Update 2:** My favourite web-comic, xkcd, covered this subject a while ago.

**Other posts you may find useful / interesting**

Welcome to the slightly delayed Carnival of Mathematics #74 – Tungsten Edition. In a departure from COM tradition, this edition is on the same blog as the last edition due to a lack of hosting volunteers. Fortunately, however, the volunteers are starting to turn up and so this is the last month that you’ll have to put up with me for a while. Next month will see the carnival hosted by Daniel over at General Musings and April will be taken care of by AcmeScience (thanks peeps!). The rest of the year is up for grabs so if you’d like to host a future carnival then contact me and we’ll work something out.

One tradition that I’m not about to give up on, however, is the number trivia section. So, let’s see what 74 has for us. In stark contrast to 73, the Chuck Norris of Numbers, 74 doesn’t seem to have much going for it. It’s probably overweight for a start since it is the 3rd hungry number (hungry because it tries to eat as much Pi as possible). Other than that it is odious, semiprime and altogether rather dull!

Enough of the trivia and on with the show.

First up we have a post from Datavisualization.ch which shows a set of infographics from around 150 years ago. Much of this work is rather beautiful and demonstrates that the field of infographics is much older than you might think.

For a rather more modern take on statistics and infographics I highly recommend the UK BBC Four TV documentary, The Joy of Stats. This was a one off show broadcast in late 2010 and hosted by Hans Rosling (Also the star of a brilliant TED talk). Several clips of the show are available over at The Open University and it was recently mentioned by The Royal Statistical Society.

From statistics and onto the theory of numbers with a post by Matt Springer called ‘Sunday Function’. In this post, Matt demonstrates a wonderfully simple proof concerning fractions which have terminating decimal expansions. It turns out that it just happened to be a Sunday morning when I read this delightful little post over coffee and it set me up for the day.

Number theory has been big news in the mathematical world recently thanks to some work by Ken Ono and colleagues who have found a finite, algebraic formula for partition numbers. The original papers can be found at http://www.aimath.org/news/partition/ (thanks to everyone on twitter who sent me that) and there has been discussion all over the web including at Wired.com and The Language of Bad Physics. Emory University (where Ken works) have a press-release but the best resource I’ve found so far is an informal talk by the man himself at YouTube (see below).

One of my biggest personal interests is mathematical software and so my contribution to this month’s carnival is a round-up of mathematical software news for January. January also saw a post from Wolfram Research on how to use some of Mathematica’s new control theory functions to stabilize an inverted pendulum which also serves as a nice introduction to some standard control theory techniques.

Another mathematical software article that was brought to my attention last month was a post from the Mathcad team concerning a very simple looking integral. Computers often do symbolic calculus using different techniques to human beings and this is occasionally reflected in the results. Check out the article for the details.

On a lighter note, we have Music is Math: Ten Songs about Mathematics from Dave Richeson of ‘Division by Zero’ fame. My favourite of the bunch is ‘A finite simple Group of Order 2′ (below) which I’ve some across before. The rest of them, however, are new to me and a lot of fun (and in a couple of cases, quite nice to listen to).

My boss used to be a research mathematician and is something of a pedant (In a good way Chris…in a good way). It seems that this is a trait he has in common with Peter Rowlett, author of Travels in a mathematical world, who has written a piece called Pedantry on Euler and Masts where he investigates the facts behind an old Euler story. There’s also some interesting discussion of the difficulty of presenting maths for the masses.

Whereas I do Random Walking, Sander Huisman does Random Hopping and in the process he comes up with some great looking pictures and interesting mathematics.

John D. Cook compares the iPhone to the method of least squares in When it works, it works really well, Ed4All shows us a mental arithmetic short cut for squares ending in five and Math-Frolic presents A Seemingly Impossible Task, That Isn’t.

Last but by no means least, Guillermo Bautista, organiser of the Math and Multimedia blog carnival, gives us an introduction to similarity while Alasdair’s Musings brings us A cute result relating to sums of cubes.

**Follow the Carnival of Math on Twitter: @Carnivalofmath****Learn more about Math Carnivals: What is a math carnival?**