Category Archives: Maths

Latex for WordPress

I’ve just installed ‘Jetpack‘ which comes with \LaTeX. This post is to provide a quick reference. \LaTeX parses the text in the WordPress post, and lays out the display as a graphic for the viewer. Though someone reading this will see images, there are no images referred to in the edited post.

\LaTeX is a generalised document layout language, but as far as I am concerned, the main use of \LaTeX in WordPress is mathematical.

Note that as the images are generated on the fly, the page will be slower to load than if the page were pre-rendered. Therefore, I think it may still be best for the web to generate the image, save it and then display the result via an <img> tag (keeping the \LaTeX hidden in a comment so that the image can be regenerated if need be). As already mentioned, I have not pre-generated the images for this post, it is all done in code.

It’s a pity that MathML isn’t well supported at the moment.
Continue reading Latex for WordPress

Flies in Houses

Another twitter science question. Morena Baccarin (@missmorenab) recently posted:

Flies always find a way INTO your house but never OUT. Ugh! (source)

to which Patrick McAvoy (aka @stamponbunnies) said:

That’s because like Mac users, flies don’t understand Windows. (source)

Let’s put aside the funny for a moment. There is an element of truth here, I’d thought I’d simulate it.

Let’s imagine a situation with 100 flies immediately outside the house, randomly hitting windows/doors etc, and no flies inside. Let’s say that in each time interval, there is a 3% chance a fly will go from being an outside fly to an inside fly (or vice versa). As all the flies are outside and none inside, this means that a fly is more likely to fly in than out. As the number of flies inside grows, some start to leave. The number of flies stabilise when the number leaving is the same as the number arriving.

In the simple simulation, stability occurs when 50 flies are inside, and 50 outside – i.e. when the number of flies matches inside and out.

This simulation really refers to ‘fly density’ rather than number – and I’ve assumed a fly is just as likely to enter as to leave. In practice, flies may be more likely to fly toward light, or toward food etc, so this’d make the stable position different. Swatting will upset the balance for a while, but those flies will be replaced unless you shut the window.

In short, it matters not what the chance of a fly coming through your window is exactly, the number will stabilise – even if you swat them. If there are none inside, some will come in. If there are some inside, they will leave, but others arrive. It’s not necessary to assume that the flies came in deliberately and can’t leave, only that they are randomly moving. Of course, none of this proves that the flies aren’t doing it on purpose….

Graph of flies in a house

Note, random fluctuations will happen – but it stabilises (in this simulation) at 50/50. Changing the probability affects how long it takes to stabilise (about 40-50 time periods for 3%), but not the values at which it stabilises.

The only probability which gives no flies inside is 0% – a hermetically sealed house.

Note, with real flies, if the probability of entering the house is low, then night may fall before the stable condition is reached, killing off the flies inside, thus giving fewer flies inside than average fly density would suggest.

Also, in reality it is often true that outsides are bigger than insides. Therefore the outside fly density won’t drop in any significant way.

My table of data is shown in the full post


The following is blatantly stolen (and slightly adapted) from Cosmic Variance

The decathlon combines ten different track and field events, so to come up with a final score we need some way to tally up all of the scores. You know what that means: an equation. Let’s imagine that you finish the 100 meter dash in 9.9 seconds. Then your score in that event, call it x, is x = 9.9. This corresponds to a number of points, calculated according to the following formulas:

points = α(x0x)β for track events,

points = α(xx0)β for field events.

That’s right — power laws! With rather finely-tuned coefficients, although it’s unclear whether they occur naturally in any compactification of string theory. The values of the parameters ?, x0 and ? are different for each of the ten events, as this helpful table lifted from Wikipedia (always trustworthy!) shows:

Event α x0 β Units
100 m 25.437 18 1.81 seconds
Long Jump 0.14354 220 1.4 centimeters
Shot Put 51.39 1.5 1.05 meters
High Jump 0.8465 75 1.42 centimeters
400 m 1.53775 82 1.81 seconds
110 m Hurdles 5.74352 28.5 1.92 seconds
Discus Throw 12.91 4 1.1 meters
Pole Vault 0.2797 100 1.35 centimeters
Javelin Throw 10.14 7 1.08 meters
1500 m 0.03768 480 1.85 seconds

The goal, of course, is to get the most points. Note that for track events, your goal is to get a low score x (running fast), so the formula involves (x0x); in field events you want a high score (throwing far), so the formula is reversed, (xx0). Don’t ask me how they came up with those exponents ?.

You might think the mathematics consultants at the International Olympic Committee could tidy things up by just using an absolute value, |xx0|β. But those athletes are no dummies. If you did that, you could start getting great scores by doing really badly! Running the 100 meter dash in 100 seconds would give you 74,000 points, which is kind of unfair. (The world record is 8847.)

However, there remains a lurking danger. What if I did run a 100-second 100 meter dash? Under the current system, my score would be an imaginary number! 61237.4 – 41616.9i, to be precise. I could then argue with perfect justification that the magnitude of my score, |61237.4 – 41616.9i |, is 74,000, and I should win. Even if we just took the real part, I come out ahead. And if those arguments didn’t fly, I could fall back on the perfectly true claim that the complex plane is not uniquely ordered, and I at least deserve a tie.

Don’t be surprised (!) if you see this strategy deployed, if not now, then certainly in 2012.

Personally, I think this’ll be covered by some bit of small print that says (if x>x0 for track, or x<x0 for field, then the score is Y)