Google Analytics

Showing posts with label mathematics. Show all posts
Showing posts with label mathematics. Show all posts

Sunday, 22 September 2024

Inflation

The minute Starmer gets in to power, prices go up. Just what you would expect. The Conservatives were getting inflation under control and it was coming down, but as soon as Labour gets in, it goes up again. And we have not seen the effects of the public pay rises yet. Did people realise what they were voting for? 

This is what I hear Conservative supporters saying. But is it really true that prices have risen since Labour was elected, and were going down until? 

On the face of it, yes. The monthly inflation figures published by the Office for National Statistics (ONS) show that inflation rose to 2.2% in July 2024, up from 2% the month before, and remained at 2.2% in August. That was much lower than a year earlier when it was 6.8%. 

I do not find the percentage rate all that meaningful on its own. If a bag of oranges went up to £2.10 from £2 the previous month, most of us would say they had gone up by 10p, not that they had gone up by 5%. If that continued with 10p increases each month for a year, so that oranges were then £3.20, few would say they had gone up 60%, or that the annual rate of increase had slowed from 5% per month to only 3.1%. We would say “Bloody hell! They’re expensive compared to what they used to be”, and think twice before buying than. 

We need to know about prices as well as inflation to properly understand what is happening. Prices are measured by the Consumer Prices Index (CPI). ONS calculates this each month by statistically combining the prices in a typical shopping basket. The percentage as usually reported is not the index. It is the change in the index over the previous year. The index itself is rarely reported. It is as if journalists think it would confuse us, or maybe they are confused about it themselves. 

The CPI was set at 100 in 2015. In August, 2024, it was 134.3. In August the previous year it was 131.3. The increase of 3.0 over the year is an increase of 2.2%, which is the inflation figure reported in the media. (Actually, it works out nearer 2.3 than 2.2, but let us not get paranoid). 

Finding the political point scoring irritating, I wanted to understand the figures better. This is my attempt to do so. 

I plotted prices against inflation over the past three years. What is most obvious is that they do not always move together. While prices over the last three years marched relentlessly upwards from 112.4 to 134.3, inflation increased and then decreased again, varying between 11.1% in October, 2022, and 2.0% in May and June, 2024. 

To see why, I imagined a scenario in which the price index remains unchanged at 100 for over a year, resulting in an inflation rate of 0%. The index then jumps suddenly to 130, causing an immediate rise in inflation to 30%. It then fluctuates between 100 and 130 in steps of 10 for the next 24 months. This is shown in the blue graph below. 

The red graph shows the effects upon annual inflation. 

As one might expect, for the 12 months after the first price rise, inflation and prices rise and fall together (A). This is because prices over the second 12 months are being compared with prices over the 12 months before, when they remained steady at 100. 

But the effects then become less intuitive. In week 25 (B), despite prices climbing back to their highest level, inflation falls to 0%. And in week 28 (C), as prices begin to go down again, inflation jumps back up. 

Another quirk is that inflation becomes negative in week 31 (D), and then falls further in week 34 (E), but this second fall is only marginal (from -8.3% to -9.1%) despite a fall of 10 in the index, and much less then the further fall in week 37 when the index is unchanged (F).

The scenario shows that prices can go up when inflation goes down, or down when inflation goes up, and when they do move in the same direction, one can change by a large amount while the other only changes a bit. Prices and inflation do not always change in the same direction, or to the same extent.

These effects occur because they compare current prices with those of 12 months earlier. There can be a time-lag between price changes and their effects. The percentage rate of inflation reflects what was happening a year ago as much as what is happening today. 

Are such month-by-month fluctuations found in the real ONS data? Indeed they are, but they are harder to see because the CPI goes up and down in small steps. You have to look more closely. This third pair of graphs shows the monthly changes in CPI and inflation in the ONS data. 

The largest CPI increase was in April, 2022, when it went up by 2.9. The smallest, actually a fall of 0.8, was in January, 2023. The large increase immediately showed in the inflation figure, which shot up by nearly 2%, but the fall had little impact. Most monthly changes are much smaller, but it is still fairly easy to find contrary movements, as in January and February, 2024, or movements of different sizes, as in October, 2023. 

Returning to the original questions, did inflation come down under the previous government, and will it go up under Labour? Yes and yes. But this begs the question as to whether this is caused by governments, or is it a simple statistical side-effects? 

Statistics plays its part. Inflation was bound to decrease as it fell from the previous highs, and if the CPI continues to increase at its current rate, inflation will climb to over 3% by the end of the year as the earlier falls drop out of the numbers. One reason for the July increase in inflation was that prices did not fall as much as they had twelve months earlier. 

Prices are also influenced by other events and phenomena beyond government control. The peak in inflation in October, 2022, was largely caused by international events. The new public sector pay awards will be inflationary, as would have been the costs to not awarding them. 

Political point scoring will no doubt continue on both sides, but it might be helpful to report monthly inflation changes as well as the annual retrospective. 

I think I understand it slightly better, now.

Monday, 26 February 2024

Proof of the Pi

The proof of the pudding, they say, is in the eating, but what about the proof of the pi?

The ancient Egyptians, the Babylonians, Archimedes and blogger Bob Brague will tell you that we need pi (π) for circle geometry, and that it is roughly 3.14159. Blogger Yorkshire Pudding will also tell you that we need pie, lots of it, but he would be referring to the kind he makes from minced meat topped with mashed potato and baked. Yorkshire Pudding is right. There is no need for mathematical constants and strange symbols. We only need to know that the distance around the circle of a shepherds pie, as near as dammit, is three and one-seventh (22/7) times the distance across. You can use this to ensure you are baking enough for everyone. 

I took for granted what they said about pi at school, without any real understanding. If understanding is the ability to think of the same thing in different ways, and to be able to switch between them, this is my attempt to do that. 

So, this is another mathematical post, like the one in January about the Pythagoras theorem. I wondered whether the same technique could be used to illustrate similar concepts; such as pi.  

Here is a circle of 14 units across, zoomed in on the top right-hand quarter to make it easier to see and count. The quarter-circle is 7 units high, and it takes 11 units to go around its edge. So to go all the way round the full circle would take 44 units, which is three and one-seventh times the distance across the whole circle (14 x 22/7 = 44). 

Does it also work for area? Can it show that the area of a circle is three and one seventh times the area of a square fitted from the centre to the edge (American: Area = πr2)

Here is the circle again, with a square drawn from the centre to the edge, zoomed in on one quarter. 

If the square is divided into a 7 by 7 grid of 49 smaller squares, then most of the smaller squares are inside the circle, but some are outside. Of those outside, some are complete squares while others are part-squares. Counting them, I reckon that a total equivalent of around 10½ smaller squared are outside the circle, leaving 38½ inside. I have tried to show how I counted 10½ by putting numbers on the quarter-circle. Those with the same numbers make up one square. 

Multiplying this by 4, it would need 154 (38½ x 4) of the smaller squares to completely fill the full circle. This is equal to three and one-seventh times the 49 in the square on the radius (49 x 22/7 = 154). 

To prove this visually, I used three larger squares to cover three-quarters of the circle. Then I moved the parts that were outside the circle (shown in grey) into the fourth quarter. So far, in all, this has used 3 larger squares, a total of 147 smaller squares. 

But it does not quite cover all the fourth quarter of the circle. We need an extra 7 smaller squares (shown in yellow), in other words, one-seventh of a larger square.  

So, the area of a circle is equal to three and one-seventh times that of a square drawn from the centre to the edge. (Area = πr2)

Arithmetically, it takes 38½ smaller squares to fill the fourth quarter, but there are only 3 x 10½, or 31½, available to move. We are 7 short. 

I get it. At least I think I do. 

Tuesday, 23 January 2024

Pythagoras

It was well-known to the ancient Egyptians, that a triangle with sides of 3, 4 and 5 units makes a right-angle. The Babylonians also knew this four thousand years ago, as they did in India. They used it to measure out precise squares and verticals. I would not be surprised if the ancient Tom Stephenson used it too.

Rotate such a triangle four times by ninety degrees, and you are back to where you began. Put four of them together as shown below on the left and it makes a perfect square. The one on the right is the same with the middle bit filled in.

This works for any right-angled triangle, not just those of size 3-4-5. 

The sides of the square are equal in length to the long sides of the triangles.

I am now going to move the top two triangles, top right to bottom left, and top left to bottom right. Hopefully, the arrows and numbers help make this clear. It results in an L-shape.

The L-shape uses the same pieces as the large square we started with, so the overall area remains exactly the same.

The L-shape can be split into two squares, a large one and a small one, as below. The sides of the smaller square are of the same length as the shortest side of the original triangle (see right-hand side). The sides of the larger square are of the same length as the third side (see left-hand side). 

The two squares still use the same pieces as the large square we started with, so the total area remains exactly the same as it was before we moved things around. 

In other words, the area of the square formed around the longest side of the triangle is the same as the combined areas of the squares formed around the other two sides. 

Or as Pythagoras put it in 550 B.C.: “The square on the hypotenuse is equal to the sum of the squares on the other two sides.” 

Isn’t that just exquisite. They never showed me that at school.

Pythagoras may have discovered this by moving triangles around in the same way, one of the first to express the structure of nature as numbers, and advance understanding from the world of fact into the world of proof. He offered a hundred oxen to the muses in thanks for the inspiration (Jacob Bronowsti: The Ascent of Man).

And once you know this is true for any right-angled triangle, you can work out how much timber and how many tiles you need for your pitched roof, and are on the way to the kind of trigonometry that allows you to manipulate three-dimensional images on your computer screen. 

Tuesday, 5 July 2022

Nice Little Earner

Fixed-term Indexed-linked Savings Certificates, once nicknamed “Granny Bonds”. 9.0% interest this year. Not bad! And it’s tax-tree.

They are no longer on sale. National Savings and Investments withdrew them in 2011. However, if you already owned some, you have been allowed to renew them for another period at the end of their fixed term. These are now two years into their fourth five-year term. They started off at £10,000 in 2005 and were last renewed in 2020.

They used to be linked to the Retail Price Index (RPI) but NS&I switched then to the poorer Consumer Price Index (CPI) in 2019. Even so, interest of 9% (8.99 + 0.01) is good. I doubt I’ve ever had as much as that before on anything. But we have endured years of low interest because inflation has been low. More than once I’ve considered cashing them in.

To calculate the average compound interest over 17 years the formula is (no doubt Mr. Brague will correct me if wrong):

    £10,000 x interest17 = £15,287 
    therefore, interest = 17 √ 1.5287  (the seventeenth root of 1.5287) = 1.02528
    In other words around 2.528%

Which I guess is probably about what you would have received over that period in a Building Society account.

It’s swings and roundabouts. High inflation was inevitable. It affects everything. So perhaps we should not be trying to take seats off swings and rides off roundabouts. It puts things out of balance and makes us dissatisfied.

Friday, 18 February 2022

Factorials (or Bonding with Brague)

Dear Bob,

As I am sure you know, the factorial of any positive whole number is that number multiplied by all the numbers between it and 1.

So the factorial of 3 = 1 x 2 x 3 = 6
And the factorial of 5 = 1 x 2 x 3 x 4 x 5 = 120

I am also sure that, as a computer programmer, you could quickly write a program to calculate the factorial of any number N. One way to do it would be to set up a counter to cycle through all the numbers between 1 and N, multiplying each by a running total that is initially set to 1. In an imaginary programming language it might look like this:

RunningTotal = 1
FOR Counter = 1 to N
Multiply RunningTotal by Counter; (thereby altering the value of RunningTotal)
The factorial of N = RunningTotal

So, in calculating the factorial of 5, each step of the cycle would produce the following values:

 Counter   Multiplication of
 RunningTotal x Counter 
 New Value of
 RunningTotal 
1 1  x  1 1
2 1  x  2 2
3 2  x  3 6
4 6  x  4 24
5 24  x  5 120

But there is a more elegant way. This involves thinking of the factorial of any number N as being that number multiplied by the factorial of N-1.

So the factorial of 3 = 3 x 2 = 6
And the factorial of 5 = 5 x 24 = 120
And the factorial of 6 = 6 x 120 = 720

In our imaginary programming language, the program to calculate factorials using this method might look like this:

The factorial of 1 = 1
The factorial of N = N x the factorial of (N-1)

This is known as a recursive function because it has to re-use itself at each step of the calculation. For example:

The factorial of 5 = 5 x (the factorial of 4)
    The factorial of 4 = 4 x (the factorial of 3)
        The factorial of 3 = 3 x (the factorial of 2)
            The factorial of 2 = 2 x (the factorial of 1)
                The factorial of 1 = 1 (this causes the calculation to “unwind”)
            So, the factorial of 2 = 2 x 1 = 2
        So, the factorial of 3 = 3 x 2 = 6
    So, the factorial of = 4 x 6 = 24
So, the factorial of 5 = 5 x 24 = 120

Isn’t that just exquisite!

Now, for homework, please would you explain the operation of recursive descent parsing giving examples from the Hebrew and Cherokee languages.

Sincerely yours

Thursday, 22 April 2021

Different Lives

Click graphic to view on external site. It also has a transcript if the text is too small to read.
 
Someone posted one of our school class photographs on that web site – the one that would rather show you things it thinks you’ll like or agree with. 
 
There we are, over fifty years ago in our school uniforms, thirty-one adolescent teenagers, seventeen boys and fourteen girls with hopes and dreams and insecurities, some smiling, happy in their skins, others serious or awkward, the way we were. Should it be there with names listed? No one asked for consent. Some names are wrong. Some are missing. I’m just a question mark. Good! Was that really me?

There’s that nasty bastard whose main pastime was punching others in the face whenever he felt like it. Look, he’s left a comment. He must think no one remembers. You can see him now in his profile pictures with his arms round different women: “single, sixty, keeps fit”. He’s older than that. Hell! With his piggy eyes and thick ape-neck he looks like Harvey Weinstein. Too many hormones. Avoid! He probably thinks this post is about him.

Let’s not make it so. There’s the clever kid who got into Oxford, another who became a games teacher and the thin chap with glasses who was rubbish at sports. 

That lad killed himself on a motor bike. Went round a bend too fast. Slow tractor, plough blades on the back. Cut to pieces. We shed buckets over his empty desk until the teacher moved us round.

Look at the girls! Aren’t they lovely, every one. I hope they can see past our round shoulders, big noses, spots and collective gormlessness and think we’re lovely too.

Those three were scary, and inseparable. They all went to train as primary school teachers in Sheffield. That one became a social worker. There’s the blonde girl I dreamed about, who they paired me up with in a swimming lesson because there were unequal numbers of boys and girls. “Forget that she’s a girl,” yelled the swimming teacher when I was supposed to stand between her legs and support her thighs while she did back-stroke arms. I never dared speak to her again. And there’s the pretty girl with freckles who sat close and wrapped her leg round mine and asked if I knew of any dances I could take her to. How might things have been different if I’d said yes? Dream on. 

Dream on indeed. The chance of life! In theory, any possible pair of those boys and girls could have married and had children (married, yes, they wouldn’t have lived together then). Actually, one couple did. They went to America. What about the others? How many different pairings of sixteen boys with thirteen girls? Sorry, fifteen boys: I forgot about the motor bike. I make it 195. If each possible pair had an average of two children, then there are 390 different possible children who were never born, and three in America who were. 

Nearly four hundred sentient individuals like you and me, never born, never will be, never laughing, weeping, wanting, loving, having days of wine and roses. Never having children of their own.

Should we multiply that by 450, the number of eggs a woman ovulates during her lifetime, any of which might have been fertilised? That’s over 175,000. Should we multiply it again by another billion, the estimated number of sperm cells a man produces each month, any one of which might have fertilised one of those eggs? What’s that? A hundred and seventy five thousand billion. 

Who would these unborn souls have been? There would have been musicians and artists, drug addicts and dictators, scientists and imbeciles, leaders and thinkers, and billions upon billions of ordinary people like you and me. Some might have been bloggers. Each with a unique sense of  “me”. If any had been my children, they wouldn’t have been the children I have, they would have been entirely different children, and the two I do have would never have existed. Could they really never have been born? Could some have inhabited different bodies? No, there aren’t enough bodies. Are some stuck somewhere in a queue, in limbo?

A hundred and seventy five thousand billion distinct individuals who were never born. Three who were. From one school class.  

The numbers are bigger still in the wider world, as the linked graphic shows. It estimates the odds against any one of us existing as we do, as the equivalent of two million people each rolling a trillion sided dice and all coming up with the same number. 

It happened for me. It happened for you. “Now go forth and feel and act like the miracle that you are.” 


Sunday, 18 April 2021

Sungold

Question: if packets of tomato seeds contain an average of ten seeds, what is the chance that one will contain just four? I will come back to this later. 

Thirty years ago, the most popular television gardener in the U.K. was Geoff Hamilton. Here he is on the cover of the Radio Times wearing the same Marks and Spencer air force blue shirt as I had (Radio Times also lists TV programmes but has kept the same title since 1923).

In 1996, he wrote a column praising the virtues of Thompson and Morgan’s orange ‘Sungold’ cherry tomatoes:

        Ever since I first grew Thompson and Morgan’s cherry tomato “Sungold” I’ve rejected all others. For me, it has just the right balance between sweet and acid that makes it melt in the mouth. Mind you, I can’t afford to be a stick-in-the-mud, so I shall try others…

The column has been folded at the bottom of our seed box ever since. Sadly, Geoff Hamilton died shortly after it was published. He may not even have got to try the Sungolds he grew that year. His gardens at Barnsdale, Rutland, remain a much visited attraction.

They are pretty expensive as seeds go. They only put a small number in each packet, and, being F1 hybrids, they don’t re-seed themselves true to type so you have to buy new ones each year. Nowadays, they work out at between 30 and 50 pence per seed, and would probably be more if the patent had not expired and they were still only available from Thompson and Morgan.

We followed the advice and bought some, and, being able to afford not only the seeds but also to be sticks-in-the-mud, we have since rejected all others too. They are as good as Geoff Hamilton said. 

To return to the question I started with, about the probability of getting only four seeds in packets that have an average of ten. After pondering for some time, I’m afraid I still don’t know the answer, and neither do you unless you work for Johnsons Seeds of Newmarket, Suffolk, and can say how accurately the seeds are counted and whether packets are just as likely to contain more than ten seeds as less than ten seeds (in other words the spread and skew of the seed-count-per-packet distribution). I don’t think the question can be answered without this information. So let’s just guess the answer is: “very unlikely”.

What I do know is that I was pretty annoyed when it happened to me. About a month ago I opened a packet of Johnsons F1 Sungold tomato seeds, average contents ten, and found only four seeds. I am not sure when and where I bought them. I got them early last year, forgetting I had some left over from the year before.

I complained to Johnsons and after a few weeks received a replacement packet, but in the meantime I had bought another new packet to get things started. Tip: have a good feel of the packet before buying. Even if the seeds are too small to count, you can certainly detect the difference between four and ten.

Here are this year’s seedlings on their way from the house to the greenhouse to be moved into bigger pots. I always grow six seeds on the assumption they won’t all come up, but, as you can see, this year they did. Now, what are the odds of that?

 

Thursday, 8 February 2018

Agents Of Maths Destruction

Who needs brains any more except to ponder how computers and calculators have changed the way we do everyday calculations?

At one time we needed brains for long multiplication and long division, drummed into us at primary school from time immemorial. It is so long since I tried I’m not sure I can remember. Let’s try on the back of a proverbial envelope.

Long mulitiplication and division
Long multiplication and long division with numbers and with pre-decimal currency

To do it you had to be able to add up, ‘take away’ and know your times tables – eight eights are sixty four, and so on – but just about everyone born before 1980 could do these things without having to think. 

Those of us still older, born before say 1960, could multiply and divide pre-decimal currency – remember, twelve pence to the shilling, twenty shillings to the pound. You had to have grown up with this arcane system to understand it. Perhaps we should have kept it. It might have put foreigners off from wanting to come here and there would have been no need for Brexit. As the example reveals, even I struggle with the division.

Logarithms and Antilogarithms
Logarithms and Antilogarithms

Then, there were logarithms and antilogarithms, as thrown at us in secondary school. To multiply or divide two numbers, you looked up their logs in a little book, added them to multiply, or subtracted to divide, and then converted the result back into the answer by looking it up in a table of antilogs. For example, using my dinky little Science Data Book, bought for 12p in 1973: 

To multiply 2468 x 3579:
log 2468 = 3.3923; log 3579 = 3.5538; sum = 6.9461; antilog  = 8,833,000

To divide 3579 by 24:
log 3579 = 3.5538; log 24 = 1.3802; subtraction  =  2.1736; antilog  149.1

It’s absolute magic, although the real magicians were individuals like Napier and Briggs who invented it. How ever did they come up with the idea? It was not perfect. Log tables gave only approximate rounded answers and it was tricky handling numbers with different magnitudes of ten (represented by the 3., 6., 1. and 2. to the left of the decimal points), but it was very satisfying. You needed ‘A’ Level Maths to understand how they actually worked, but not to be able to use them. Some also learned to use a slide rule for these kinds of calculations – a mechanical version of logarithms – but as I never had to, I’ll skip that one.

Slide Rule
A Slide Rule

Due to a hopeless lack of imagination, I left school to work for a firm of accountants in Leeds. Contrary to what you might think, our arithmetical skills were rarely stretched beyond adding up long columns of numbers. We whizzed through the totals in cash books and ledgers, and joked about adding up the telephone directory for practice. The silence of the office would be punctuated by cries of torment and elation: “oh pillocks!” as one desolate soul failed to match the totals they had produced moments earlier, or a tuneless outbreak of the 1812 Overture as another triumphantly agreed a ‘trial balance’ after four or five attempts.

Sumlock Comptometer
A 1960s Sumlock Comptometer.

But when it came to checking pages and pages of additions we had comptometer operators. Thousands of glamorous girls left school to train as Sumlock ‘comps’, learning how to twist and contort their fingers into impossible shapes and thump, thump, thump through thousands of additions in next to no time without ever looking at their machines. By using as many fingers as it took, they could enter all the digits of a number in a single press. It probably damaged their hands for life. I still don’t understand how they did it. There was both mystery and glamour in going out on audit with a comp.

Friden Electromechanical Calculator
A 1950s Friden Electromechanical Calculator

Back at the office we had an old Friden electro-mechanical calculating machine. What a beast that was. I never once saw it used for work, but we discovered that if you switched it on and pressed a particular key it would start counting rapidly upwards on its twenty-digit register.

“What if we left it on over the bank holiday weekend?” someone wondered one Friday. “What would it get to by Tuesday?”

Fortunately we didn’t try. It would probably have burst into flames and set fire to all the papers in the filing room. But we worked it out (sadly not with the Friden). It operated at eight cycles per second. So after one minute it would have counted to 480, after one hour to 28,800, and after one day to 691,200. So if we had started it at five o’clock on Friday, it would have got to 2,534,400 by nine o’clock on Tuesday morning. So, counting at eight per second gets you to just two and half million after three and a half days! It shows how big two and a half million actually is.

The obvious questions to us awstruck nerdy accountant types were then “what would it get to in a year?”– about two hundred and fifty million, and “how long would it take to fill all twenty numbers in the top register with nines?”– about thirty nine million million years. As the building was demolished in the nineteen eighties it would have been switched off long before then. But what would it have got to? 

ANITA 1011 LS1 Desktop Calculator
An ANITA 1011 LS1 Desktop Calculator (c1971)

The first fully electronic machine I saw was a late nineteen-sixties ANITA (“A New Inspiration To Accounting”, one of the first of many truly cringeworthy acronyms of the digital revolution) which looked basically like a comptometer with light tube numbers.  Then, fairly quickly with advances in integrated circuits and chip technology, came the ANITA desk top calculator followed by pocket handhelds that could read HELLHOLE, GOB and BOOBIES upside down, and 7175 the right way up. Intelligence was as redundant as comptometer operators. We revelled so much in our mindless machine skills that I once saw a garage mechanic work out the then 10% VAT on my bill with a calculator, and get it wrong and undercharge me. It can still be quicker to do things mentally rather than use a calculator.

Around 1972, my dad saw one of the first pocket calculators for sale in Boots. It could add, subtract, multiply and divide, pretty much state of the art for the time, but at £32 (about £350 in today’s money) and not as compact as now, it required large pockets in more ways than one. I told him it was ridiculously overpriced. Infuriatingly, he ignored me and bought one. On the following Monday they reduced the price down to just £6. It was his turn to be annoyed but the store manager refused to give a refund. He stuck with that calculator for the next thirty years.

How often now do we even use calculators? Not a lot for basic arithmetic. Do we ever doubt the calculations on our computer generated energy bills and bank statements? Do we check the VAT on our online purchases? Do accountants ever question the sums on their Excel spreadsheets? Just think, a fraction of a penny here, another there, carefuly concealed, embezzlement by a million roundings, it could all add up to a nice little earner.


I believe the above images to be in the public domain except for the first which is mine.