[00:00] i am taking this physical money into that physical  sainsbury supermarket because in order to test a   mass theory i need to find some combination of  items that when i buy them the selfch checkout   [00:15] will give me a 50 p coin in my change here we  go so i can buy a oxford exam set for £450 and   [00:27] we can examine what the soft checkout's going  to do okay here we are a cash and card going   to scan this barcode on the back okay notes  in it in my change will come out out of here [00:49] wipes there's my£5 note my change 220s two fives  what the heck sainsburries four coins when one   [01:02] would do we have a perfectly good 50p coin here in  the uk we have one and two pence coins 5p 10p 20p   50p and then 1 pound and two pound which i'll be  referring to as 100 and 200 for consistency sake   [01:17] above that it's a£5 note now of those eight coins  for some reason the sainsbury soft checkouts do   not have 50p or 10p coins you can spend them  but the coins you put in go into a different   [01:33] bucket they're not reused to give change to  someone else all new coins have to be loaded   in for change purposes and they don't put in tens  they don't put in 50s so your worst case scenario   [01:45] if you should get a 50p coin you get four coins  instead two 20s and two fives that's three more   coins than you need if you need to get a 10p coin  in your change you'll get two 5p coins that's one   extra one but they don't combine because 60p you  just get 320s so worst case scenario you can get   [02:03] up to three more coins in your change for the  same value of change and just out of curiosity   i knocked a little bit of code together to  take every conceivable value below 500 and   [02:19] then across all of them average the number of  coins you would get and in normal use across   all eight coins you expect to get on average  4.6 coins in your change because sainsburries   are using two fewer you get on average 5.9 coins  in your change that's over an entire extra coin   [02:38] it's ridiculous and we'll get to why sainsburries  are doing that later and it's not good but given   i'd put together some code that could test  the effectiveness of different combinations   [02:52] of coins i thought i'd see if i could do an anti-  sainsburries what if we wanted to add a coin to   make things better all right give me one second  i'm just going to knock a quick coin together [03:21] all right there it is i've just struck a 1  33 coin this is the coin the uk is missing   so here's what i did i took the standard eight  coins and then i added one more coin for every   [03:37] possible value between 1 and 499 and then  averaged how many coins you get in change   assuming all values between 1 and 499 below  the note are equally likely and here's the   [03:49] plot of the average number of coins for every  possible value we could add into the mix and   there actually there are two two optimal points  two local minimums that are 133 and 137 i assume   [04:02] the general public will be more open to a 1  and a3 pound coin as opposed to a 1.37 pound   coin but either one you add it in and the average  number of coins in your change is now a mere 3.9   [04:16] that's under four that's an improvement  but can we do better oh you know we can [04:33] i'll make sure i get the eight up the right way  don't get me started on eights that are up the   wrong way makes me angry so matt why did you have  to move office uh beats me why they didn't want me   as an office mate so forget the 1.33 coin instead  we're going to add a 77 p coin and we're going   [04:53] to add a184 coin and with these combined with the  eight we already have it brings the average number   of coins you get in your change down to 3.6 come  on and we can keep adding coins the at this point   [05:07] i'm like you know what eventually we're just going  to have one coin per value and it'll be an average   change of one coin because there's 499 of them  at some point you got to say look we can't just   [05:20] keep adding coins maybe eight is already too  many what if we just replaced more of the ones   we've already got it didn't take much to alter my  code so instead of adding every possible coin to   [05:32] all eight it would take every subset of seven so  like remove all the possible coins one at a time   actually except for the one p coin we need that  well we need that we'll get to that in a moment   but we do need it if we want penny accuracy  so it took each of the other seven out one at   [05:48] a time tried every possible replacement and your  optimal improvement is to get rid of the£1 coin   and replace it with a123 coin now i'm not going  to belt that out of metal partly because it's   [06:00] super loud and fun fact we've had a complaint from  someone in a nearby office but also because just   replacing the one pound with the 123 brings the  average down from 4.6 to around about 4.2 but we   [06:14] can do better because i just left the code going  it started again and checked if there was another   replacement that would be even better and another  one that would be even better it turns out there   are three more as well as£1 becoming 123 you can  get rid of the two the 10 and the 50p coins and   [06:30] replace them with a 13 a 37 and an 88 pence coin  and now your average number of coins in change is   down to 3.9 we're back under four we haven't had  to add any we just got to replace them and i was   [06:43] like wait a minute is that the best there's an  interesting point here though because my search   of finding what one swap is optimal at any point  in time doesn't actually let you search all the   [06:55] possible solutions because you can't just change  a coin in isolation it depends on the other ones   so what you need to do is look at whole new sets  because you don't just like choose a coin when   you're giving change on its own it depends what  other coins are available so you need to change   [07:10] all of them at once to find the global solution  and thankfully someone who's better at programming   than me has done just that i believe the optimal  coinage problem tracks back to a 2002 paper what   [07:23] the country needs now is an 18 cents piece  however i first came across it when my friend   adam townsend a mathematician at durham university  wrote an article for chalk dust and at the time   [07:36] adam was able to work out the optimal solutions  across all possible combinations of coin values   for the uk for everything up to the case for five  coins so we now know if we only had two coins we'd   [07:49] have a 1 p and a 22p and your change on average  would have well over 20 coins in it three coins   gets us under 10 with a 1 p a 14p and a 61p and at  the time eight years ago the computation fizzled   [08:04] out after five when i contacted adam saying i was  finally making a video about this maybe we should   dust off the code and give it another go straight  away he got the case for six coins which was very   [08:17] exciting not long after that we got seven and then  it seemed like we were not going to get eight the   code was going to take so long to run it was hard  to justify that amount of processing power until   [08:29] one day adam was struck with inspiration changed  the code made it more efficient and now we have an   answer which is why i'm filming this bit after all  the other stuff you've just seen cuz it literally   [08:41] just happened and i can now present the official  8 coin solution if we swapped the eight current   coins used in the uk for these and come on we  get a11 coin we would have way fewer coins in   [08:57] our change would bring the average all the way  down to 3.82 so good and i was so excited you   better believe i 3d printed them so there's a uh  1.58 coin we got the pound 55 if you're thinking   [09:12] these are just way too big it's because i wanted  the volume of these to be proportionate to their   value so if you go all the way down to the the  1p that's got one 158th the mass of the pound 58   [09:28] coin so what it means is if you get your change  and you just chuck all the coins on some scales   and weigh them it'll give you the exact value  how good are these available now or the most   [09:40] optimal set of eight coins possible and all of  these could be yours if you just convince the   government to change to these and then do a lot of  complex arithmetic anytime you want to make change   [09:52] or because of the scaling volume just weigh your  change and get the exact value straight away it's   so dumb now you might be thinking if we found  these coins via an exhaustive search is there   [10:06] a hey speaking of money it's time for me business  matt get out of here so these fantastic coins we   have printed for the video were all printed on  that bamboo labs x1 printer behind me and they   [10:21] are sponsoring this video which is why i'm going  to say it's a printer so good you can literally   print money like actual money i don't think we  can legally say they can print money look who is   [10:34] the business finance expert here you are correct  i'm the one wearing a jacket that's how you know   i'm business matt get out of here how it works  bamboo printers so good you can literally print   [10:46] money legality to be questioned the bamboo labs  x1c is a high-speed high quality 3d printer it   can take multiple colors at once and it's got all  sorts of smart features which actually work and   [11:05] it means even i a 3d printing novice can print  all sorts of fantastic multicolored things and   thanks to everyone who sent in models after the  last promo we did for bamboo including andreas   müller who sent this i said if enough people  used the link and we got to do another promo   [11:22] i'd print out files people sent in so andrea  sent in this it's a ring of regular deahedra   so in theory this could be like will this go  around my head it won't go around my head but   andreas has put this model and other longer more  flexible ones that will go around your head here   [11:38] on maker world the bamboo labs website where you  can download all sorts of great models and thank   you to adam adam lutter who sent in some assembly  required this is what's called an industrial dice   [11:51] it's based off a design that james prop came up  with i need to go home glue this together then i   can roll it and i'll have a link below you can  check out the mass of that so do check out the   link in the description below and if enough of  you click it we'll do another one of these send   [12:06] me in more ridiculous models and i'll print them  out business matt away is he gone okay fuel skye   we're safe come on up here good girl sit lie  down there you go now if you're thinking if   [12:22] we found those coin combinations via exhaustive  search surely there's a more clever way of doing   it and actually when the results came in for the  six coin setup i thought you know what that 140   [12:37] and that 99p are awfully suspicious of course as  these numbers were coming in we were looking for   patterns so we could just generate them instead  of having to do such tedious exhaustive searches   [12:51] and at the point when we got to six so i hadn't  seen seven or eight yet i was like "wait a minute   99 p 140." well a pound 40 that's almost the  square root of two well 100 times it wait 99   [13:05] p that's about 100 hang on a minute it turns out a  pound 40 divided by 99 p is <unk>2 how interesting   but are there other ratios between the coins  we were finding which was root two well we can   [13:20] spread this out a little bit to give us a bit more  room and of course i calculated the ratio between   every two consecutive coins for all the solutions  we found and there's our root two and there's kind   [13:32] of root two is that root two what about this one  that's route twoish now i believe these are close   enough to indicate something is going on now we  don't actually know what if you come up with a way   [13:45] to generate these that would be as far as i know  all new maths and it seems like it's got something   to do with square roots you could argue i'm just  reading tea leaves here and i'm overfitting to   [13:57] what i'm seeing and there is a line so the one  here 1.597 that's pretty much exactly the fourth   root of 6.5 but i feel like that's an accident  the route twos however that might be something   [14:11] and the reason i think it could be an indication  what's going on is square roots do abound and if   we have a closer look at the two coin case so  you get a 1 p coin and some other coin why 22   [14:24] or 23 why are they equally good well in our case  we have to make change up to £500 and the square   root of 500 is suspiciously right between the two  equivalent values it seems like square roots have   [14:40] a lot to do with this and the two coin case is  the nice simple starting case we can actually   investigate so let's say we have two coins one  is worth a single pence because we need penny   accuracy and then we have some other coin of some  other value and we have to make change for any   [14:55] value from one up to some value capital n well  i mentioned this to adam he had to think about   it and he ran his code again and put together this  plot and the blue is what came out of his code and   the orange is when you fit an equation to it and  it looks like the equation of the expected number   [15:12] of coins for when you add in some x pence coin and  your capital n's 500 is a half 500 /x + x but why   and it turns out that's true and here's why if you  think it through the number of coins you need for   [15:29] some value little n so that's some value between  one and capital n for one specific case you're   making change you go okay well i want to use as  many x pence coins as i can because they're the   bigger value coin so you take the target n divide  it by x that's way you got to round it down that's   [15:45] how many x pence coins you can use and the rest of  it whatever the remainder is we can calculate the   remainder that's how many 1 pence coins we need so  that's the total number of coins for any specific   [15:57] value little n if we want to do all the values to  capital n well we just take one n and then we sum   it up for all the n's divide by n and that gives  you the average number of coins for some coin x   [16:12] here's where we can have some maths fun and then  by the way this is all too fast for you to follow   in close detail you can pause it and have a good  think and work it through yourself if you want but   broadbrush you convert that to an integral because  we can actually work that out exactly you do that   [16:27] integration and the equation for the number of  coins on average for a coin x is this look how   neat that is and if we want the minimum what's  the best x well we just differentiate that set   [16:41] it to zero and would you believe it it gives you  x= the square root of n that's where the square   root comes from at least in the two coin case very  sadly we can't extend this to three or more coins   [16:56] because of an assumption see here where we had the  number divided by x we're basically saying do the   biggest coin first do as many as you can then  do the next coin down and that while it seems   intuitive and logical that's called the greedy  algorithm and very sadly it doesn't always hold   [17:14] the greedy algorithm is where you take the next  biggest coin to get up to the total you're aiming   for and i hate to admit it but it means that these  are not very practical because in over half the   [17:26] cases 320 out of 499 change scenarios the greedy  algorithm doesn't work so if you had to make   change for 31 p you'd be like well we got to use  the 28 first cuz that's the biggest one under 31   [17:42] and then we make it up with three pennies and that  would be four coins because you went biggest first   however if you skipped over the biggest one and  instead you picked up the 21p you then only need   [17:55] two 5ps to make up the total that's only three  coins and our normal coinage doesn't have this   problem this better coinage does and the worst  case scenario by the way is if you had to make two   [18:09] coin's the 158 we'll do that we then need uh two  28s we need two fives and then we can make up the   rest with four ones which is a lot of coins and  you've completely neglected to notice that 228 is   [18:28] just the 155 and the 73 you can do it in two coins  that's seven fewer it's just super not obvious   so not only are these coins unusual numbers that  make the arithmetic difficult but you can't even   [18:44] do it the normal easiest way you got to use  difficult numbers and do it the hard way so   there you are opportunity for way more maths  in my mind however now i return you to past   [18:56] matt he's probably banging on about what's more  practical there is another solution to simplify   change that we're overlooking here and it is  dare i say a practical which i appreciate is the   [19:09] thinking there's no way i'm using those coins and  there's no way the general public are going to be   adding up ridiculous coin denominations well it's  simple we keep all the values we currently have   [19:24] and to simplify it we just get rid of the one  and two pence coins and just by getting rid of   them and rounding our change to the nearest 5 p we  will drop the average number of coins all the way   [19:39] down to 3.4 way better and if you think well hang  on people aren't going to do that people won't be   happy rounding their change well in australia they  got rid of the one and two cent coins they had an   [19:53] identical range to what we have in the uk got  rid of one and two cent coins in the early '9s   and for over a third of a century it's worked  fine for more on this we go to on location [20:07] matt thank you studio matt no you hang up are  we not doing that i thought we were anyway i'm   here on location in australia and i can confirm  and i remember this in the '9s we got rid of the   [20:23] one and two cent coins and nobody cared no one  cares now we still have the notion of 1 cent   because if you pay electronically or you know  with a card you pay to the nearest whole cent   [20:35] if you pay cash rounded to the nearest 5 cents  so actually if you're a little bit strategic and   you choose between cash or card depending on  which way the rounding is going to go you can   save literally ones of cents in a lifetime but  what about selfch checkckout machines well of   [20:51] course there is a supermarket here at the beach  that has selfch checkouts and i've worked out if   i go in there and spend these 10 dollars and the  machine has to give me $3.85 85 cents change it   [21:06] should do it with one of all six different  coins available if it has them let's find out as is tradition once i got to the supermarket  i went to the stationary aisle this time i found   [21:21] a clear plastic ruler 30 cm for $25 i just have  to add to that a single box of barbecue shapes   for four wait a minute two halfp price boxes  of barbecue shapes for $4 bonsai and that's   [21:37] going to give me exactly $385 change put in my  10 bucks and here comes the change there's a   $2 coin or $1 coin and following that what a heap  of 20 cent coins where's my 50 cent where's the   [21:54] 10 unbelievable coals have given me three 20 cent  coins three coins when i should have had a 50 and   a 10 that's one more coin overall than was optimal  what on earth is going on with selfch checkckout   [22:07] machines i'll tell you what i'm going to email  coohl's and if they reply i'll edit their response   in right now nothing nothing i guess they didn't  get back to me the point is whatever's happening   [22:20] with these soft checkout machines just doesn't  measure up but that's it from me here in australia   no longer have one and two cent coins although  interestingly never replace them with anything   [22:32] else h back to you studio matt thank you on  location matt no you hang up oh we're not doing   that bit oh sorry anyway so if we get rid of the  one and two pence coins and we replace them with   [22:48] two new coins which australia didn't do we can do  even better and now we don't get any weird values   because everything is a multiple of five and for  some reason everyone's okay with that so if we get   [23:00] rid of one and two and replace them with 165 and  225 we bring the average number of coins in change   in the uk down to 2.6 under three how good is  that and if you want to take this opportunity to   [23:17] simplify the whole system and not have eight coins  we could go down to just seven coins by replacing   one and two pence with a single 1.75 coin which  is quite nice and actually adam had an idea for   [23:34] the design of that coin when adam presented  his initial findings at the mass jam weekend   many years ago he showed the original design  for the current coins which has this fantastic   shield pattern you can see all of it on the one  pound coin and then fragments on it of the six   [23:51] other coins of lesser value now since then the one  pound coin has been updated to a different design   but we still have the shield on the other coins  it's a wonderful little thing that often people   [24:03] don't notice and when they do it's a fun easter  egg but adam realized if we took out the one and   two pence coins we even further lose the shield  so if we're going to replace that with a 175   [24:15] coin it needs to fill those two gaps at the same  time and this is what adam designed and presented   with a sufficiently straight face in front of a  room of other recreational mathematicians and i   [24:29] thought this design was so great i asked adam for  his slides which is why i'm showing them to you   now i think it's some of his best artistic work  if i'm being honest i mean look at that look at   that double one 75 coin the lion is roaring that's  excellent but you know no one's going to actually   [24:47] try and make it you know i printed it there it  is i managed to recreate adam's incredible design   i mean you could just see the shield now this  is a 2:1 scale because i tried to print it the   [25:02] exact right size and my 3d modeling abilities are  not good enough yet but that's still a proof of   concept that's a prototype now that's a practical  coin i'll be honest my vote is just dump the one   [25:15] and two pence coins don't replace them simplify  it down to a mere five coins so tidy and other   countries have got a much smaller set of coins for  example the currently united states of america and   [25:32] we have sadly on location matt couldn't make it  but we do have a us correspondent for the channel   rolling hey how's it going i'm raleigh williams  i'm here in the united states of america i'm from   [25:44] the youtube channel climate town check it out  on youtube.com in america we have six coins but   if you think we're using all of them you're out  of your goddamn mind we only have four in normal   circulation two of them we never use including the  half dollar and the honken dollar coin this thing   [26:01] weighs as much as a house we just have it to show  that we're better than everybody so that's how   we do it in america and as far as i'm concerned  that's how everyone should do it all around the   world usa usa usa catch the fever indeed usa  and that actually answers our question about   [26:23] sainsburries because if you have a close look  at the sainsbur selfch checkout that i was using   it's an ncr model plus you might have noticed the  machine in australia also ncr and the company ncr   [26:36] that makes them is an american company the selfch  checkckout machines are designed for american   coinage or at least designed for countries with  fewer coins i don't know why it's six maybe it's   [26:48] the five normal ones and then they've got the  $1 coin as an option but they're definitely not   designed for eight coins so sainsburries they're  not going to pay for a whole new type of machine   [27:00] the uk market is obviously not big enough for  that so what they've done is just gotten rid of   two of the coins they took out 50p and 10p but  are those the best two coins to take out i had   [27:13] a look into it do you want to see do you want to  see a plot of course you want to see a plot i've   got a table here of every pair of coins that could  be removed i've only filled in the ones where like   [27:26] it's a unique pairing of coins and green is good  red is bad and the best one here is if you take   out the pound coin the 100 and you take out the  10p coin so instead of doing 10 and 50 they should   [27:39] have done 10 and 100 because that would give you  an average of 5.41 coins in your change but they   didn't do that they didn't do any of these all  of these are better in fact if they took out   the pound and any of the 2p 5p 10p and 20p it'd  be better than what they've currently got now   [27:56] maybe they felt people wouldn't tolerate there  not being a one pound coin if they didn't take   that out but that's the optimal solution or they  could have taken out the two pound coin and the   10p coin or they could have taken out the 10p coin  and the 2p coin all of those are better instead   [28:16] they took out the 50p and the 10p which is now  like what the seventh best option and i have no   idea why they did that when there are way better  options actually you know what i might i might   [28:31] email them i didn't think to ask i just worked  this out to be honest you know what i'm going to   send them an email and if they give me a sensible  explanation i will put it in the edit right here [28:45] nothing i guess i didn't reply honestly sainsbur  springs so in conclusion i don't know money is   terrible i mean not coins coin i mean money  is made up but uh coins are terrible i mean   [29:00] i haven't used physical money in a very long  time and that's the first time i've gotten   change from a selfch checkckout machine in i  would say about a decade because we don't we   don't need physical money uh anymore and that's  why i'm very pleased to announce matt coin when   [29:16] i know wouldn't that be special if that's what  i was doing no uh hey thanks for watching thanks   for supporting the channel uh by the way i don't  need another one of these in my life so if you   [29:28] would like this or indeed the coins i will uh  sign the coins i'll sign this they're all on   ebay you can pay electronically or post me might  no you can't post me money uh all the money goes   to charity for these thank you to everyone on  patreon who gives me uh real digital money to   [29:45] keep the channel ticking along uh a huge thanks  to adam townsen for doing the maths inspiring   this video helping me put it together and of  course thanks to jeffrey shallot who did the   original what this country needs now is an 18  cent piece i'll link to all of it below thank   [30:00] you for watching um bye be the change you want to  see in the world that's what i should have said [30:12] world h this is not a serious career