## Archive for the ‘general math’ Category

I work in a beautiful old building at The University of Manchester called The Sackville Street Building. Yesterday, I took part in a very interesting historical tour of the building and was astonished at the amount of beautiful things that I had never noticed before and yet walk past every day.

For example, I was delighted to discover that one of the stained glass windows in the great hall was themed around mathematics (thanks to Samantha Bradey for the original image which I’ve heavily compressed for this blog post)

While on the tour I posted a quick snap of the above window to twitter using my mobile phone and received some nice feedback along with a few pictures of other mathematical windows. It turns out that Manchester’s Nick Higham has a close up of the above window for example. Also, Kit Yates tweeted about several mathematical windows in Caius College, Cambridge, one of which is below (showing images related to Venn and Fisher).

Do you know of any other examples of mathematics in stained glass? Feel free to contact me and tell me all about it.

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**