Thursday, 14 March 2024

Weird dates

Today is Pi Day, because the date in American usage is 3/14, the first three digits of pi. I call it "American Pi Day" because in the UK (and most other countries) the date would be 14/3. This led me to thinking - could we designate a Pi Day with the UK date format? 3/14 would be the 14th month, which doesn't work. And 31/4 doesn't work either because April has only 30 days.

But what if we relaxed the date format somewhat, by allowing the numbers to wrap around to the next month or year? Then 3/14 would be the 3rd day of the "14th month", which would be the 2nd month of the following year, so 3 February. Or 31/4 would be the "31st of April" which is 1 May.

This relaxed method of specifying dates allows us to find more special dates than we can with the normal format.  11/11/11 (11 November 2011, in both formats, as well as the quite common yy/mm/dd format) was very special, but that pattern ends there, unless we use our relaxed notation, when we get:

22/22/22    22 October 2023

33/33/33    3 October 2035

44/44/44    13 September 2047

55/55/55    24 August 2059

66/66/66    5 August 2071

77/77/77    16 July 2083

88/88/88    27 June 2095

99/99/99    7 June 2107

And finally, we can even do 00/00/00 by counting backwards: this would be 30 November 1999.

Friday, 30 December 2022

Installing an aerial hoop in the house

I bought my stepdaughter a one-metre aerial hoop for Christmas and then had to work out how to hang it. My preference was for her to use it outside, hanging from an A-frame which I could easily have made from scaffolding poles. But she persuaded me that she would use it more in her room. So, going against the advice of the manufacturers, I decided to hang it from the ceiling.

In the UK, ceiling joists are generally 4" x 2" or about 100 mm high and 50 mm wide. I would not be happy hanging an aerial hoop from a single joist, but I reckon spreading the load across 3 joists would be enough, based on the experience of a friend who has done this sort of thing before. The idea would be to screw a piece of 6" x 2" (150 x 50 mm) timber, placed horizontally under the ceiling at right angles to the joists, into the centre-lines of the joists, and then hang the hoop from this new beam.

The first task is to find the joists. You can get a rough idea from tapping the ceiling or using a stud finder. From there, my friend has a trick involving a U-shaped piece of stiff wire (like a very thin croquet hoop) which you feed through a small hole in the ceiling, roughly between the joists, and then waggle it round until it hits the joist, and mark the position of the end that is still below the ceiling. Unfortunately, this didn't work because my joists have fibreglass insulation between them, which stops the free movement of the wire.  I resorted to guessing the location and alignment of the joists and then, along two parallel lines just under 150 mm apart that are destined to end up covered by the beam, poking a bradawl through the ceiling, noting where it goes through into thin air (or insulation) and where it encounters resistance due to the joist. By using the two parallel lines you can ascertain not only the position but also the exact alignment, so that you can be reasonably sure to drill into the centre line of each of the 3 joists (which by the way are usually 16" (about 400 mm) apart).

I bought M10 (10 mm) coach screws that were 150 mm long (50 mm for the new beam, 100 mm for the full height of the joist, and about 10 mm for the ceiling board, so we nearly reach the top of the joist). I made the beam 1100 mm long to cover the 3 joists and allow about 100 mm at each end.  I drilled 10 mm holes through the beam and 5 mm holes through the ceiling into the joists. I used 2 screws for each joist, about 80 mm apart. I did consider offsetting these so that any potential split in the joist didn't spread to the other hole, but decided that it was more important to be as close to the centre line as possible, given that I still couldn't be 100% certain of the position and state of each joist.

It's difficult to hold the beam in place to align the ceiling holes correctly. With the 6 holes drilled in the beam, I drilled one hole through to the centre joist, screwed the beam into place with one screw, and marked the positions of the other 5 holes. It was then possible to loosen the screw and rotate the beam to uncover the 5 marked holes and drill them (even with the holes uncovered, you need a longer than average 5 mm drill to get right up to the top of the joist). Then move the beam back into place and put in the other 5 screws. Tightening up the 6 screws with a 17 mm socket is quite a workout - at least 100 quarter-turns (with some elbow grease) for each one!

Now to a refinement: I wanted to make sure that the load would be applied equally to the 3 joists, especially if it was a heavy load.

This little bit of applied maths shows that putting a piece of 1/8"" (3 mm) plywood packing between the beam and the middle joist should help to equalise a large load of half a tonne. The hand-waving argument is that making the beam bend will push up on the middle joist, reducing the net downward force from the load on that joist and transferring it to the outer joists.


And here's the result...




Sunday, 25 September 2022

Fundamental Theorem of Arithmetic (update)

This is an update on my 2019 post on the subject. This new proof is even simpler and (hopefully) better explained.

Here's a simple, fairly non-algebraic and not particularly rigorous proof of the Fundamental Theorem of Arithmetic.  The theorem states that any natural number >1 can be uniquely expressed (apart from re-ordering) as a product of primes.  For example, 140 = 2 x 2 x 5 x 7 and there is no other set of primes that multiply together to make 140.

It is obvious by construction that any natural number can be expressed as some product of primes.  Now, if the Fundamental Theorem of Arithmetic is false, then, for some such natural number, there is another set of primes with the same product.  We can divide out any prime that appears in both sets, so that we end up with two sets of primes with equal products and no primes in common.

Now take the largest prime P (looking over both sets).  We need to show that P does not divide into the product of primes in the other set.  We do this by induction, building up the product in the other set.  We note that P does not divide into the first factor in the other set because that is prime (and because it is smaller than P).  Then if P does not divide into the product so far, we show that it won't divide into that product multiplied by the next factor.

Let R be the current product, and N the next factor. So we know that P does not divide into R, and we want to show that P does not divide into NR.

Instead of worrying about N itself, we look for the smallest number k between 2 and P-1 inclusive for which P divides into kR. If we can prove there is no such k, we have also proved that P does not divide into NR, since we know that N is between 2 and P-1.

So suppose such a k does exist.  Now look at the largest multiple of k that is less than P. Call this sk.  Then P divides skR.  But P also divides PR (obviously), so P divides (P-sk)R.  But P-sk <= k (otherwise sk wasn't the largest multiple). And P-sk is not equal to k (otherwise P = k(s+1) and P would not be prime) so p-sk < k. So k wasn't the smallest after all.  So there is no such k, including in particular the next element N in our product.  So P does not divide into NR.  Continuing this argument until we have reached the last element in the product, we have shown that P does not divide into the other product of primes, so the theorem is true.

Thursday, 27 August 2020

Some maths with 4-letter words

 

Have you ever done those puzzles where you have to get from one word to another by changing one letter at a time, with the rule that each change results in a proper word?  Usually this game is played with 4-letter words.  For example, to change LEAD to GOLD:  LEAD, LOAD, GOAD, GOLD.  Just 3 steps.  Of course you cannot do any better here, because 3 letters differ between the two words and you can only change one at a time.  But sometimes you need more steps.  I tried WOLF to LAMB and the best I could do was 7 steps: WOLF, WOLD, SOLD, SOLE, SALE, SAME, LAME, LAMB.

Thinking about this a bit, it occurred to me that there are probably some “isolated” words that cannot be turned into any other word.  Two examples I can think of are EVIL and EXAM.  I would imagine that most words can be reached from one another, but can we prove that?  And are there smaller groups of words that can be reached from each other, but not from any other words?  And, within the main group (if there is one), which pair takes the longest minimum number of steps to get from one word to the other?

It turns out that this is a wonderful application of the branch of mathematics known as Graph Theory.  In graph theory, a graph is not the notorious x-y plot of GCSE Maths, but a network of points (vertices) joined by lines (edges).  One problem solved in graph theory is to find the shortest path between two points, which we all now use when we turn on our satnav or use Google Maps (where “shortest” usually relates to time, rather than distance).  To find the shortest path, we use the Dijkstra algorithm (or one of its later improvements). Another less useful but mathematically very interesting application is in proving the four-colour map theorem, which says that you only need four colours to colour any map of regions so that adjacent regions have different colours. 

How is graph theory applied to our 4-letter words?  Each word becomes a vertex of a graph, and two vertices are joined by an edge if the corresponding words differ by just one letter, for example MIKE and MINE.  Our game is then played by applying the Dijkstra algorithm to find the shortest path between two vertices (words).  The longest such path, which is called the diameter of the graph, will answer our question about the most difficult pair of words.  Graphs are analysed and classified by looking at connected components, which are groups of vertices that can be reached from one another via edges but cannot reach any other vertices in the graph.  In a graph representing a country where the vertices are towns and the edges are roads, then islands (without bridges) would be connected components.  Such an analysis would answer our questions about isolated words and small groups.

So I thought it would be fun to apply some graph theory tools to our word game.  I started with the Official Scrabble Words list which has 5,638 4-letter words (some of which are admittedly rather obscure!).  It turns out that 5,563 of them are in one huge connected component, so can be reached one from another.  Of the 75 remaining words, 59 are completely isolated, and the other 16 are in tiny islands of no more than 3 words, the first of which is AMMO-AMBO-UMBO.

And what is the diameter of the graph (or more correctly, the subgraph consisting of the huge connected component?  It turns out to be 15, with many examples, but the first in my list was UNAU to YEOW (are these really words?):  UNAU, UNAI, UNCI, UNCE, ONCE, ONIE, OWIE, OWSE, OOSE, MOSE, MESE, MENE, MENU, MEOU, MEOW, YEOW.  And showing the limits of my vocabulary, the best answer for WOLF to LAMB is 6 steps, one better than I could manage: WOLF, WOLD, WALD, WALE, WAME, LAME, LAMB.

The fun continues: Another interesting question is to find the “best-placed” word – one whose worst pairing has the shortest number of hops.  This is the (Jordan) centre of the graph.  (If you think about it, the physical centre of a disc is the point whose longest distance to any point in the disc is the shortest).  If you’re still with me, that shortest longest distance (sic), called the radius of the graph, must be at least 8.  Why?  Because, if it were 7, you could get from any word to the centre in 7 steps, and from the centre to any other word in 7 steps, making 14 in total, and we know there are some pairs that need 15 steps.

Well, it turns out that the radius is 8, and is achieved by just one word, AIAS (an aia is a maid or nurse, in India).  So there you have it – you can get between any two four-letter words in 15 steps or fewer, and you can even guarantee 16 or fewer by visiting the word AIAS on the way.

One last result: the average number of steps between two 4-letter words is about 4.8.  This is not a million miles from the average "distance" between Facebook friends, which on research.facebook.com is reported as 3.57.

UPDATE for 2, 3 and 5 letter words

 So I had to repeat this work for other word lengths of course!  The results are in this table:




 

 

Monday, 19 August 2019

Fundamental Theorem of Arithmetic

Here's a simple, fairly non-algebraic and not particularly rigorous proof of the Fundamental Theorem of Arithmetic.  The theorem states that any natural number >1 can be uniquely expressed (apart from re-ordering) as a product of primes.  For example, 140 = 2 x 2 x 5 x 7 and there is no other set of primes that multiply together to make 140.

It is obvious by construction that any natural number can be expressed as some product of primes.  Now, if the Fundamental Theorem of Arithmetic is false, then there is another set of primes with the same product.  We can divide out any prime that appears in both sets, so that we end up with two sets of primes with equal products and no primes in common.  Take the largest prime P (looking over both sets).  We need to show that P does not divide into the product of primes in the other set.  We do this by induction, building up the product in the other set.  We note that P does not divide into the first factor in the other set because that is prime.  Then if P does not divide the product so far, we show that it won't divide that product multiplied by the next factor.  Consider the current product modulo P, call this R (modulo P means "the remainder on dividing by P").  Now R > 0 because P does not divide the product so far.  Clearly P divides PR.  Now find the smallest number k > 0 for which P divides kR.  We know that k < P.  Then find the largest multiple of k that is less than P, sk say.  Then P divides skR.  But P also divides PR, so P divides (P-sk)R.  But P-sk < k (otherwise sk wasn't the largest multiple), so k wasn't the smallest.  So there is no such k, including in particular the next element in our product.  Continuing this argument until we have reached the last element in the product, we have shown that P does not divide the other product of primes, so the theorem is true.

Wednesday, 22 October 2014

Some clever jokes

These are my favourite jokes from http://veryviral.com/21-jokes-so-clever-that-you-probably-wont-get-them-definitely-wont-get-them/ without the annoying photos!

RenĂ© Descartes walks into a bar. Bartender asks if he wants anything. … RenĂ© says, “I think not,” then disappears.

Sixteen sodium atoms walk into a bar… followed by Batman.  (it took me a while to get this one!)

An infinite number of mathematicians walk into a bar. The first orders a beer, the second orders half a beer, the third orders a quarter of a beer, and so on. … After the seventh order, the bartender pours two beers and says, “You fellas ought to know your limits.”

Pavlov is sitting at a bar, when all of the sudden the phone rings… Pavlov gasps, “Oh crap, I forgot to feed the dogs.”

Three logicians walk into a bar. The bartender asks, “Do all of you want a drink?”… The first logician says, “I don’t know.” The second logician says, “I don’t know.” The third logician says, “Yes!”

An MIT linguistics professor was lecturing his class the other day. “In English,” he said, “a double negative forms a positive. However, in some languages, such as Russian, a double negative remains a negative. … But there isn’t a single language, not one, in which a double positive can express a negative.” A voice from the back of the room piped up, “Yeah, right.”

I’m thinking about selling my theremin… I haven’t touched it in years.

What does the “B” in Benoit B. Mandelbrot stand for?… Benoit B. Mandelbrot.

What do you get when you cross a joke with a rhetorical question?

Thursday, 4 July 2013

Disastrous new "cycle facility"

When work started on a new cycle path on the southbound side of The Causeway in Petersfield, I was hopeful that this would help to promote cycling in the area and maybe encourage a few new cyclists.  Personally I was not fussed.  I use this road very day, and have never felt the need for special treatment.  For a fairly busy road, it is quite safe: wide, nearly straight, with wide verges and good visibility:

In the mornings I cycle up this road and turn left off it in the distance, up a steep country lane.  In the evenings I come down the steep lane, have plenty of time to look around, and turn right into the road.  Nice and simple.

Now the cycle path shown on the left of the photo above has been built, it makes my journey MORE DANGEROUS, SLOWER and LESS PLEASANT, whether I use the path or not!

What happens when I use the path?  I leave the road where the cycle path starts by slowing down (first hazard) and bumping obliquely up a badly dropped kerb (second hazard) onto the path:
On the path I have about a quarter of a mile of traffic-free cycling.  This was quite pleasant for a couple of weeks, until rubbish started to appear on the path and the trees started to grow and hang down below face level (third hazard):
Not to mention the obligatory low-visibility "feature" to keep cyclists on their toes (fourth hazard):
Then a fifth hazard: crossing the entrance to a lay-by, where now I have to give way:

Finally, where before I simply turned left, I now have to slow right down, turn hard left, hard right into the lay-by (sixth hazard) and hard left into the lane:
In the evening it is far worse.  Instead of my right turn with plenty of space and time, I now have to slam the brakes on at the bottom of the hill (seventh hazard), turn hard right (eighth hazard), then hard left over a slippery bit of ridged concrete (ninth hazard), then hard right onto the cycle path for a few metres:

Then it's over the lay-by entrance, back down the path, sometimes facing cyclists who don't realise it's a two-way path (tenth hazard), stop and cross the road at the busy new pinch point: (eleventh hazard)

Because it is a pinch point, the traffic is all bunched up, so it is much harder to get across than the original right turn onto the open road.

OK, so suppose I eschew the cycle path and just use the road as I used to?  Well, the pinch point is a pinch point for me, too.  And it rightly annoys drivers who now often have to stop on an open road::

And they look at me as if I'm responsible for the whole shambles, and shouldn't be on the road anyway because of the cycle path (they're wrong about that, but I can hardly blame them)!

Several hundred thousand pounds will have been spent on this ridiculous, inconvenient, unpleasant and downright dangerous pile of poo.  Oh, and I wonder how many cyclists were consulted?