# Brief Bites

Here I'll put notes that I might later turn into proper posts or articles. For now they are brief notes for people to read.

## Software checklists

The recent events of the Heartbleed bug have made me think again about checklists in software. It's the ubiquitous and relentless use of checklists that have made aviation so incredibly safe (according to an aerobatics pilot friend of mine) and recent studies (need to check references) have shown that checklists in surgery have improved results significantly.

So how could we automatically test for the sorts of problems seen in the Heartbleed situation, and how can we start using checklists in software development?

Or is it simply too late, and we're in the maritime situation, not the aviation situation.

## Size of the Earth with a ladder and a stopwatch

I recently told someone about how to calculate the Distance To The Moon using just a pendulum and a stopwatch. As part of that we need to use the period of the Moon (29.53 days synodic) and the size of the Earth. We get the latter from the orginal definition of the metre as one ten millionth of the distance from the North Pole to the Equator, running through Paris. That makes the circumference of the Earth to be 40 million metres, by definition.

However, he said "Using the stopwatch and a ladder you can calculate the size of the Earth from a single location."

And he's right. Stand on a two metre ladder at sunrise and wait till you first see the Sun. Start the stopwatch and jump off the ladder. The Sun will again be below the horizon, so wait for it to appear again. When it does, stop the stopwatch. And that's enough.

Can you work it out?

 Lime St map in the underground

## Oddly placed maps ...

So here's something I noticed as I was coming up from the Liverpool Lime St underground to the main concourse. By the lift is this map. It shows the layout of the station - the yellow dot shows where you are, and the lift, platform, and train track are all clearly marked. As you look at the map you can see that the lift is immediately on your right, and the tracks are off to the left.

Except that's exactly wrong. As you look at this map the lift can be touched by your left hand, and to get to the platform you turn right.

Bizarre.

If it were mounted on the opposite wall, behind me as I took this photo, then it would be absolutely accurate, and much more useful.

So there you are.

And this is not the only instance of this sort of thing. Frequently we find that in a lift the floors are listed with the bottom floor at the top, and the top floor at the bottom. I've written about this sort of thing before in The Forgiving User Interface - once you've seen one of two cases you start to see them everywhere.

There's a name for that effect, but I can remember what it is.

## Distance to Jupiter

Last night someone asked me how far away Jupiter is. Of course, the distance changes according to whether we're on the same side of the Sun or the opposite side, but we should be able to work it out more-or-less.

My memory suggests that the Jupiter year is a little over 11 Earth years. We know that the cube of the distance is proportional to the square of the orbital period, so the distance from the Sun should be $11^{(2/3)}$ AU. Now 11 squared is 121, and 5 cubed is 125, so that's probably close enough. I would guess the distance from the Sun to Jupiter is about 5 AU, or about 750 million km.

As it happens, Jupiter's orbital period is about 11.8 years, but the distance is about 5.2 AU, so I think that's pretty close all round.

## Why not start now ...

I'm sure people are starting to think of their New Year resolutions. I'm sure there are things they want to do, things they want to stop doing, things they want to do differently, and generally, things to think hard about changing in their lives.

Why not start now?

If it's the right thing to do, why wait until January 1st? If it's the right thing to do, why will it be the right thing to do then, but not now?

Why wait?

## A proof that the reals can't be listed

 In truth we only need an upper bound, but students will insist on trying to pin down a specific value, and that's OK.
First we establish that 1/2 + 1/4 + 1/8 + 1/16 + ... is a thing, and that it's less than or equal to 1. There's a cool way to do that with sheets of paper.

Then we talk about the number line, and the fact that every location is a number, and every number is a location. We tap into the intuition of number as length or location.

 Classic problem with the usual Cantor diagonalisation proof is that students say -"Well, just add that one in." If you've proved that adding one element to a countable set is still countable, then adding in your newly constructed element clearly doesn't make the set bigger. There's a confusion. This proof avoids that by showing that virtually all the reals fail to be on the list.
We want to show that there are lots of them. So many, in fact, that any list of them is woefully incomplete, Here's how we do that.

So let's take a list of reals, and cover the first one with a small umbrella of width 1/2. Cover the second one with a smaller umbrella of width 1/4. Then the next with an umbrella of width 1/8, and so on.

The total width of umbrellas is 1, so pretty much the entire number line must remain uncovered. Indeed, if you choose some small number, everything except that much will remain uncovered just by starting with a small enough initial umbrella.

So there are too many reals to list.

Related:

The latter has started a dialogue, which over time I hope to grow.

## The Simplex Method - a geometric visualisation

In Linear Programming problems we have several variables and a set of linear inequalities. We need to find values for the variables satisfying the inequalities, and then from those, find the values that maximise (or minimise) some objective function.

Solutions to the linear inequalities form what is known as a simplex in an appropriate dimensional space. If it's a three variable problem then we get a three dimensional simplex. This is convex, and you won't go far wrong thinking of it as a wonky polyhedron.

So our solution will be somewhere inside that simplex. But where?

Let's think about the (linear) objective function. Far a given value, this defines a dimension (d-1) hyper-plane in our d-dimensional space. You won't go far wrong thinking of this as a plane at an odd angle in 3D space. When this intersects our simplex, the intersection holds all the solutions to the inequalities that have that specific value for the objective function.

Now we make that value bigger. As we do so we move the plane through space. The area of intersection changes, and eventually the plane will leave the simplex (think wonky polyhedron) behind. The last point of contact is, in general, a point, and we can fairly easily see that it must be a vertex of the simplex.

So the optimal solution to a linear programming problem always occurs at a vertex of the simplex of solutions.

And so to the Simplex Method, or Simplex Algorithm. This works by finding a vertex, and then moving along the edges of the simplex to another vertex with a better value. It carries on doing this until finally it can improve no more, and that is the optimum.

I've not talked about providing any of this:

• If not at optimum, why can we always get better by moving along an edge?
• Why is this guaranteed to terminate?
• What if the solution space is unbounded?
• Why is the pivot in the Simplex Algorithm "moving along an edge"?
• Why is the specified choice of pivot guaranteed to make things better?

................. and so on - I'm sure you can think of many more questions. However, this was intended to give some geometric insight into what's going on.

Hope it helps.