Skip to content

Tag Archives: maths

What if this entire scene, not just a horizontal slice of it, was the horizon of some other scene?

Serial: Chapter 1: A – Horizon

I had found myself walking down a pier about eveningtime; the sun was setting.

I focused on the horizon; how abstract an entity this is; it is not a physical “thing”, but depending on your position you can, thanks to the obliging sphericity of the planet, draw a line (well, a circle) on the globe, or a map an point at it and say “that’s the horizon I see”, which is really quite nice, when you think about it; at least our horizon at any time is a definite line of land, as opposed to the abstract line of land infinitely far off, as it would be if we lived on a plane. But, the notion of horizon is inseparable from this unreal prospect, at least in our thoughts.

How much depth is contained in this horizon, how fantastic it is. Then I thought, as one might, “what might the horizon look like in a higher dimensional world? – What might it be like to look out in to the distance to find yourself confronted with a horizon of not one dimension, a line, but two, a plane? I closed my eyes, and tried visualise this but my body instead froze, my heart was set racing – the overwhelming extent of this sight suddenly struck me, and I found myself unable to move for several minutes, unable to think about anything else, my mind fixated, unable to open my eyes lest I find myself faced with this terrible distant entity; a whole world might indicate the limits of my field of vision, a whole world that existed only as a conceptual nicety to me.

See wikipedia if you don't get the reference.

A burger or, something more than a burger?

So, I made a funny a few weeks ago

Friend:’A friend of mine used to go to burger king on a semi-regular basis and he always used to get really annoyed because they’d put the burger box (with the burger inside it) on to his tray upside down. And, one time when I was there with him he had just got given his tray – he opened the burger box thing, to find it was upside down, and he said to the dude who had given it to him “Dude, what do you think I am, left-handed?”‘

And we all laughed, and I was, like, “Well, what if it was a pseudo-burger?”

Some people laughed anyway. At least I did.

Maths & Music Talk

On the 7th April 2005, I gave for the Maths Society a talk with the above title. Below I link to two files, one a rough outline of what I talked about, the other a relatively detailed bibliography describing some good books in a few diverse areas related to music theory.

Outline [ PDF ] [ PS ]

Bibliography [ PDF ] [ PS ]

Applied Duality

(n.b. this articles is mainly, humourous, but some pretty bizzare/interesting things come out of it.)

What’s Duality?

Ok, if you don’t know…duality is a feature of some areas of maths where given a proof you can swap some terms and get the dual of it’s proof. For example, in projective geometry, you can switch the words “point” and “line”, and “meet” and “join” (and some others, but I’m only giving a simple example). So, given the statemenn “two points join to form a line”, you can get “two lines meet to form a point”. See? it works?


My main object here will be to construct a program that will, given a basic erotic story, reverse the sexes of the participants (and of course it will fail miserably in the process).

So, basically all i have to do is list all the different couples of male/female words. I’m going to avoid objective pronouns because though “his” matches with “her”, so does “him”…so it would work fine from male to female but not vice-versa (because she can have two meanings depending on context) Likewise, her shouldn’t be used as a objective pronoun. This can be overcome with a grammatical parser … but I don’t have time to implement such a program at the moment.

So here’s some things from the list, just to give you a rough idea.

Continue reading ›

A Jenga Probability Distribution


Ok, I’m going to try to build some rough mathematical description of the game Jenga

You know Jenga, the game where you have a tower of little wooden blocks, and players take turns removing one block at a time from the tower, stack it on the top. The last player to stack a block without making the tower fall wins the game.

Right, well, might as well get down to it.

Row Density

Ok, on any given row there are 3 blocks. If either of the side blocks are picked, then you can remove another block (i.e., there’s a 66% chance you’ll remove two blocks), and if you pick one from the centre, then you can not remover any other blocks from the stack (i.e., there’s a 33% chance you’ll remove only one block from a given row).

Formulating this, the average no of pieces you’ll take out of any given row is:


This also means that, on average, it will take 5/3 turns to exhaust any row.

So, given R rows, you will on average take (5/3).R turns to render the whole stack useless.

However, after each turn you will stack one block on top, so you will also have added (5/3).R pieces on top of the stack, or have created (5/9).R new rows. With these rows, you will take (25/27).R turns to clear them and will generate (5/9)^2 R extra rows, and these extra rows will generate (5/9)^3 R, etc. etc.

So, in total, you will end up with

R+(5/9)R+(5/9)^2 R +(5/9)^3 R + ...

Rows by the end (note that in reality that after a certain term the terms in the sequence become less than 1, and so the above series is an overestimation).

This is a geometric series, with a=R and r=5/9, and the sum is given as:


Now, each of the (9/4)R rows take up roughly 5/3 turns, so the total number of turns it will take to finish up the tower is (15/4)R turns.

Now, we know that the total number of blocks in the tower at any one time is constant, but the total number of moveable blocks in the tower reduces every turn, it goes down by one every turn, but goes up every three turns because of an extra row being added.

Thus, denoting the number of free blocks as a function of time:


This just means that every turn the no of moveable blocks decreases by an average of 4/9. (remember that the extra row being added does not create three extra moveable pieces, it creates, 5/3 extra moveable pieces on average)

So, given that the initial number of moveable blocks is (5/3)R, we can write


Now we can go on to some of the proper maths :)

Probability Distribution

Now, taking any area of the tower, the chance that the person will pick a block from that area is proportional to the ration of the size of that area to the size of the whole tower, or, taking that area to be a specific row in it’s initial state:

P(Will be picked)=rho/Phi

Now, let D be the average number of blocks on a given row as a function of time.


or, simplifying:


Now, expanding it a little, a pattern will emerge:

D(t+2)=D(t). (Phi(t)-1)/Phi(t) . (Phi(t+1)-1)/(Phi(t+1)




D(t+2)=D(t).(Phi-1)/Phi . (Phi-1-4/9)/(Phi-4/9)

And so on…

D(t+3)=D(t) . (Phi-1)/Phi) . (Phi-1-4/9)/(Phi-4/9) . (Phi-1-2.4/9)/(Phi-2.4/9)

And so, by induction:

version of above equation for D(t+k)

Ok, all you need to know is that the gamma function has the property that


for all x greater than or equal to 1.

Now, lets look at part of D(t+k), namely the lower half of the D coefficient:


Let Phi(t)=A

same as above with a substituted

Now, look at the following:

gamma function identities

Expanding this further:

even bigger gamma identity

But this sequence does not end. We have to cap it be dividing by another function that will cancel out all terms after 9/4(A-(k-1)4/9).

So, let’s look at the following

gamma function

Dividing one by the other, we get

gamma equation

Now, we can substitute Phi for A and divide by (9/4)^k to get the thing quotiented at the start of this section:

(thing quotiented at the start of this section)

and – in addition, noting that the top half of the D coefficient from the previous section is of the same form with A as Phi-1.

Back to the Distribution

So, we get the following function

equation for D(t+k)

And the two fractions cancel out giving

another equation for D(t+k)

Which I think is pretty neat (coz I’ve never had a reason to use the Gamma function before, and coz gamma functions are neat :) )

Now, the rest is trivial:

Given an initial stack size of R, an additional row is created every three turns, so, rephrasing D as D_j(t_{0j}+t) where j is the row you’re looking for the number of pieces left to move, and t_{0j} is the turn on which the jth row was created.

equation for t_{oj}

Now, the average number of blocks left to be moved on a row j can be approximated (realising that D(t_{oj})=rho=5/3 ) as

equation for D_j

And that’s as much as I’m going to do with it. You wouldn’t believe how many weird roads I had to go down to find the above solution, and I’m sure as hell not going to go actively looking for any more geometric sequences for quite some time (I was going mad yesterday trapped in a maze of them!).

Hope it made some sense, will clarify anything if you feel that anything’s badly explained.

magic squares

A simple analysis of magic squares

Donal Moore and Stephen Lavelle

Everyone knows magic squares right? A square grid of numbers where the sums of the numbers along each of the rows and columns and both the diagonals are all equal. (there are proper books about this etc., so google if you want to find out more).


8 5 5
3 6 9
7 7 4

The sum along any row or column or diagonal is 18.

Let’s represent the magic square mathematically.

a b c
d e f
g h i

And let the sum of each row/column be equal to n

Now we have the following equations:

  1. a+b+c=n
  2. d+e+f=n
  3. g+h+i=n
  4. a+d+g=n
  5. b+e+h=n
  6. c+f+i=n
  7. a+e+i=n
  8. c+e+g=n

Now, because all the equations equal n, we can put any left side equal to any other left side. Let’s combine the 1st one with the 7th one: we now have:


So we can substitute this into the former equation:

Which, we concluded, was quite a neat thing. You can also easilly find that a similar thing holds for the other corners, so all magic squares have to be of the form:

(y+z)/2 w (x+z)/2
x ? y
(w+y)/2 z (w+x)/2

Now, because we now know the value of one of the rows we can easily find the value of the ? in the center.

(y+z)/2+x+(w+y)/2 = w+k+z

but x+y=w+z

so w=(x+y)/2

which i think is pretty cool :)

So, we have

(y+z)/2 w (x+z)/2
x (x+y)/2 y
(w+y)/2 z (w+x)/2

But we can restrict if further, because for (y+z)/2 to be a whole number that means that y+z must be even, which means that y and z have to have even parity (either all even or all odd).

And we actually only need three numbers because:

which gives:

(x+w)/2 w (2x+w-y)/2
x (x+y)/2 y
(w+y)/2 x+w-y (w+x)/2

So we need only three numbers of similar parity then. But there’s 1 further thing(using the variable names below) if we want to restrict ourselves to having only positive values in the table:

a b c
d e f
g h i

If h+e>=a+e+f then w would have to be non-positive. Therefore

Similarly you can show that any of {b,d,f,h} have to be greater than any of {a+i,c+g} :)

So, they’re the constraints we’ve managed to work out so far – we’re looking at trying to make all the numbers different – but that’s pretty hard to do.

Exactly the same method can be used to find out how to construct a 4×4, or 5×5, or NxN magic square, but the calculations are AWFUL to carry out by hand, and very quickly you find that the number of free variables begins to outnumber the number of dependant ones. Anyway, here’s the structure of 4×4 and 5×5 magic squares:

h+l-m h-j+k+l-m-n+p j-h-k-l+2m+n m+n+o-h-l
j+k-h 2m+n+o-h-k-l h-j+l-m+p h
m+n+o+p-j-k-l j k l
m n o p

Notice that for the one above, for any integers h,j,k,l,m,n,o,p, the whole table contains just integers (to put them all positive takes an awful amount of constraints-not really worth it)

And the 5×5:

(h+2j+l-m+n+2o+r+2s-3t-u-v-w-x)/2 (h+2j-l+m+n+2o-2q+3r+2s-3t-3u-v-w+x)/2 -h-m-r+t+u+w+x -j+m-n-o+q-r-s+2t+u+v -j-o-s+t+u+v+w
(-h-2j+l+3m+n+2q+3r-t-u-v-w-x)/2 (-h-2j-l-m-n-2o-3r-2s+5t+3u+3v+3w+x)/2 h j-m+o-q+s-t+x j
-l-m-n-o+t+u+v+w+x l m n o
-q-2r-s+t+u+v+w+x q r s t
u v w x y

It’s awful, the formula don’t ya think?

I found out these by using the following mathematica code (the 3×3 code’s there as well, though it gives a different version of the formula to mine):

    	a + b + c == x,
    	d + e + f == x,
    	g + h + i == x,
    	a + d + g == x,
    	b + e + h == x,
    	c + f + i == x,
    	a + e + i == x,
    	c + e + g == x

    	a + b + c + d == x,
    	e + f + g + h == x,
    	i + j + k + l == x,
    	m + n + o + p == x,
    	a + e + i + m == x,
    	b + f + j + n == x,
    	c + g + k + o == x,
    	d + h + l + p == x,
    	a + f + k + p == x,
    	d + g + j + m == x


      a + b + c + d + e == z,
      f + g + h + i + j == z,
      k + l + m + n + o == z,
      p + q + r + r + s == z,
      t + u + v + w + x == z,

      a + f + k + p + t == z,
      b + g + l + q + u == z,
      c + h + m + r + v == z,
      d + i + n + r + w == z,
      e + j + o + s + x == z,
      a + g + m + r + x == z,
      e + i + m + q + t == z

yeah, so sue me for using mathematica – the alternative was to program it the matrix way, and i really don’t have time for that right now.

Just because it’s relevant, the any of the above systems of linear equations can be written in matrix form, so all you have to do is solve it – :D

That’s why i like computers


The Evacuation

The following isn’t intended to be a big great literary work, it was just written to contain a couple of simple things from category theory. See if you can find implicit use of any of: limits, colimits, the Category in question, image, preimage, equalizers, coequalizers, cone to the base B, cone from the base B, products, coproducts, mono-epi factorization. The idea was that, even if you don’t know the language, the below should read in a not overwhelmingly confusingly way (tediousness be damned!). And, of course, it’s all fictional. And unfinished; there was a third section planned to bring in functorial ideas …but I couldn’t think of a way to make it work nontrivially… .

The Evacuation

  1. My home city of Ballina has long been a place of great peril, ravaged by famines and repeatedly decimated by earthquakes. Our governor appointed myself as the chief of evacuations, and I have spent many years in deep thought on this matter.

  2. I regularly put together evacuation plans. A typical evacuation, to Foxford, say, is organised by sending out a letter to each household in Ballina, telling them of the dangers at hand, and specifying an address in Foxford where they are to go in the case of this emergency. Similarly, the houses in Foxford are notified of the residents that will be staying with them; I personally do not favour large refugee camps, preferring to house families with residents of the host city. Naturally, coordinating such a thing as an evacuation, and getting the agreement of the people who are to help our city takes a great deal of planning and diplomacy.

  3. Before an evacuation, it is usual for groups of residents from the imperilled city to discuss their destinations amongst themselves.

  4. Perhaps more often, neighbourhoods in the host city will meet together to discuss the households that they will be accommodating in the event of a disaster.

  5. Three years ago, a great crop failure was forecasted in mid-summer. Knowing that there was nothing our citizens could do to save them, a flight to Bahola was planned. It is a far off place (the blight severely affected crops for miles around), and so we had servicemen set off in advance to build a camp-site half way. The refugees were instructed to group together with other people who were heading to the same residence in Bahola, so that they might travel in a group together and know eachother before arrival.

  6. Often I do not manage the details of a whole evacuation myself, but rather I might delegate the evacuation of various districts of Ballina to local residences whom have shown themselves influential and trustworthy. Thus an evacuation can be split into many parts.

  7. There is another way that an evacuation can be split into many parts: The city of Carlow was built during a particularly odd architectural era; its residential areas consist entirely of identically constructed, and rather bleak, apartment blocks, each having two hundred apartments. One rather poorly planned evacuation, from Galway I believe, was carried out in two parts; firstly, every house in Galway was sent a street and the name of apartment-block in Galway, and then, two days later, letters were sent out containing the apartment number – the number was just randomly picked between one and two hundred. Needless to say, chaos ensued. Thankfully, there are not many places like Bahola.

  8. It did happen once, during an evacuation from Limerick to Cork, due to terribly bad organizing on the part of their evacuation team, that two plans were simultaneously put into action: two addresses in Cork sent to each household in Limerick.

  9. Now, there were a few families who were, by chance, allocated the same residence in Cork on both occasions. These people’s evacuation was neat and orderly.

  10. But, in general, it seemed everyone was left with a choice of destinations to go two. The council of Cork was appalled at this terrible administrative blunder, and insisted that it would need to know the precise numbers of refugees that would be arriving in each district of Cork. The best that the Limerick council could manage was to divide Cork up into districts such that a household’s two choices were always contained in the same zone. These zones needn’t have made much geographical sense at all, but due to the relative similarity of the two plans, such zones were relatively localised, and the Cork council was able to use this information to plan how to distribute aid to the refugees when they arrived.

Fantasy of an Evacuationist

  1. Just as the orderly flowing of a stream, or the regular currents of the oceans inspire great awe and appreciate of their beauty and efficiency, so might
    the emigration patterns of a kingdom, if planned in detail and laws enforced, also be.

  2. I picture this: an entire kingdom, meticulously construct, all places of business and dwellings alike built and planned by the ruling King. Each city will have designated it several other cities “downstream”, where people may migrate to. However, families will not have freedom where they will live in the cities. In each house there will be a golden plaque; engraved on it will be an address in each of the cities downstream – the inhabitants may only move to these residences. Of course, the river metaphor isn’t terribly useful, as it can be nice to allow circulations: for people to be eventually able to move back to a city they once departed tearfully, or to allow people to move to different residences in the same city (For a city to be downstream from itself).

  3. Now, if a ruler fair be, he would not torment his subjects by having them agonise that maybe they would end up in a better house in Cork if they moved first to Clare and then after a few months on to Cork, rather than just move directly. This would create great inefficiency in the Kingdom I do believe. Better that people be allocated, and know that they be allocated, at most one house in any city (this does rule out the notion of a city being downstream from itself). But perhaps not; when one takes one’s fantasies this far it becomes difficult to gauge fairness.

  4. In a similar vein to the botched evacuation from Limerick to Cork described in the previous section, it can be useful to divide up such a kingdom into \emph{streams}, that is, groups of residences spread out over different cities, where you cannot migrate from one stream to another. If it was possible for people to move anywhere, then this would not be a useful conceptualization, but it is possible to plan one’s kingdom in a way that you will get a good number of streams.

  5. Let us dream that England is such an orderly migratorial-utopia as the one described above, and let it be Dublin that is terribly imperilled.

  6. In planning an evacuation from Dublin to England, if I just designate you one house in one city, you might, upon arrival, see the address of a much nice house in a much nicer city on your gold plaque. Or you might think that you may be able to get to a better house in your current city by moving around a few other cities then coming back (this is assuming England did not agree with the argument that I presented some paragraphs back). Such unnecessary movement would stir up great trouble amongst the local residents no doubt, and I believe that the refugees should not have to worry about issues such as this in any event! Thus, I would have it that every Dublin household is sent one address in each English city, which have been chosen so that if you move to the Nottingham address, you will know that however you migrate, you will always be residing in one of the addresses in that list. Thus people would only have to choose once where to evacuate to, and not ever worry about moving around England in their time there. This amounts to injecting people into the agreeable streams that I argued for.

  7. If there world was ideal, we would not have to impose two households of refugees on an English family, and we would make use of all the agreeable streams in England.

  8. Similarly, if I was to plan an evacuation of England to New York, I would allocate addresses to residences in such a way that an English family, disappointed that they have been told to move to an industrial district of New York, would not find that by migrating to another city they would be allocated an address in a more prestigious place. No, if an address is allocated to a particular residence, it will be the same address that is allocated to it all places downstream from it.

How much wood would a woodchuck chuck?

How much wood would a woodchuck chuck?

Given that a woodchuck could chuck wood

Stephen Lavelle

[here lies a picture of a woodchuck]

This is just a pretty rough sketch of how i would go about it – but it should get the point across.

Given a chucking distance of 1m (seems reasonable) – and a woodchuck of mass 3.3kg (roughly avr. mass), the maximum energy that this wood chuck could have for throwing wood is:


minimum velocity required to chuck a piece of wood 1m :


max efficiency at 45 degrees



so E=1/2mv2 …looking for m


roughly 1*1018 kg of wood could potentially be chucked by a woodchuck operating at maximum efficiency (this is only an approximate maximum limit).

Here’s a basic diagram for apparatus for carrying out the procedure:

diagram of woodchuck accelerator

There are some other important things to consider as well:

1:This sort of mad chucking would annihilate the woodchuck in the process, and so would be ethically a less than clear-cut question.

2:There is reasonable cause to increase the limit further, because one could allow the woodchuck to eat if his chucking was spread out over a non-singular time, and that would increase the amount he could chuck
(though by a negligible magnitude, which is why i don’t consider it here).

3:Considering the size of a woodchuck, the chucking distance could easily be reduced to half a meter and still be considered a chuck.

4:We currently do not have the technology to carry out this great a reaction, though i am currently applying for funding for a timber/groundhog collider, a massive underground structure 30 kilometers in diameter, to be built in the west of ireland (yes, the west of ireland is greater than 40 kilometers in diameter, or so a detailed inspection i conducted last year reported). This would allow me to test my above upper limit hypothesis to a high degree of accuracy.

Logic Proof-Sketches in Rhymed Verse!

Logic Proof-Sketches in Rhymed Verse!

This come about after trying to memorize some bits of Dr. O’Dunlaing’s 371 notes for our end of year exam. The notes can currently be found on his website,
but may not always be, and so the following might lose their followability pretty quickly (though his proofs are similar to those in Mendelson’s book on logic).

Diagonalization lemma:

Diagonalization here does state
For any formula numerical,
There is a sentence which one can equate
With its insertion theorem P-Arithmetical.
Firstly diagonalize for all x2,
To imply the initial formulae.
Now, diagonalize this to form a sentence new,
And now the proof must go both way:
Hypothesize, insert, ponens and close,
Retract, ponens, generalize, deduce – post twice suppose.

Gödel’s First Incompleteness Theorem:

In Gödel one, consistency implies
The theorem of big G is not a truth,
And if it’s consistent omega-wise
neither can you there its negation deduce.
If it can be proved there is a proof,
Expressible within the system’s word
Then there exists a proof which, in a puff,
Implies the language to be quite absurd.
In omega for each you cannot prove,
Thus there exists no proof, as we were wont to shew.

Gödel-Rosser Theorem:

G.R. says this can’t be proved either way:
For all the second the proof of first implies,
There is a prior proof of it’s nega-
tion. Take this sentence and diagonalize.
Positively, proof and second part
You can at most substitute to exist.
Insert negative there and depart
To early lemma that shows disproof exist;
If not: write out, make clear, and find a proof of this.

Praying towards mecca

Praying towards Mecca


( kudos to Chris and Donal for giving me the idea :) )

[here's a picture of a guy on a mat praying towards mecca]

One of the Muslim rules about praying is that, wherever possible, one should pray towards Mecca. Consciously praying any other direction presumably makes the prayers count less.

[A more global view: on a curved surface, how can you really pray towards mecca while being at a tangent to the surface?

In terms of vectors, this means that one can think of one’s prayer as being divided up into two parts, one towards Mecca and one perpendicular.

[A decomposition of the prayer vector into the Mecca component and the ... other ... component]

What should be done to orient one’s self properly towards mecca involves
somewhat more extreme posturing than the normal horizontal orientation
most people take – one must also orientate one’s self vertically to face
Mecca (i.e. one must take into account the curvature of the earth).

However, taking into account the curvature of the earth, it is clear that in America one’s prayer isn’t going towards Mecca by any means. However, thanks to physical reasoning, all is not lost.

You see, treating the prayer as a vector (lets call it P, a certain amount of it ALWAYS goes towards Mecca so long as the prayer makes an angle less than 90 degrees with the direction that you should be praying.


The first, and most obvious solution is to pray harder to make the component of the prayer in the direction towards Mecca large enough so as to be satisfactory.

The second solution is to pray upon a wedge that will point you directly towards Mecca:

[the solution: a man on a wedge!]

However prayer using the “prayer wedge” can be just as difficult as one has to fight off the force of gravity pulling you off the wedge. However, for locations
relatively close to Mecca, this is easy (for longer distances this effect is no longer negligable, and the use of a light harness may become desirable and indeed
necessary to ensure a safe session; elsewise all your prayers might well end up being those asking Him to keep you secure on your Prayer Wedge!).

It came to my mind that maybe I was a bit, shall we say, excited, about my theory and did not take the traditional Muslim tradition as seriously as perhaps I
should; because taking it that one merely has to pray tangential to the earth leads me to believe that perhaps instead of moving along *straight lines* the prayer
vectors have some mass and travel instead along geodesics around the earth. This minimization of work in getting to Mecca would be miraculous indeed, and may
even lead to some solid estimates of the properties of prayer (mass, velocity, etc.).

Please, please note that this article does not stem from my fundamental distaste
for organised religion, but rather from a wholly respectable and respectful sense of
fun-poking thereat.