 I respectfully acknowledge that I'm standing on the unceded traditional territory of the Comox and Qualic and First Nations. I thank them for the use of their lands and I want to express my sorrow for the victims of the Canadian residential school system. Now March 14th is Pi Day. Why? Well because Pi is often expressed as 3.14 and 3.14 is March 14th. So there you go Pi Day. Did you know that Jay actually has a primitive that will give you Pi and that primitive is this. That is Pi and in modetically it will return a value for Pi. That's pretty neat to start with. Now what's really neat is today we're going to learn how to do all the digits or a lot of digits of Pi and it's some some really seriously neat stuff that you can do with Jay well to start with. When I take Pi and I put say 10 there I've multiplied Pi by 10. Great. So if I decide to add a zero I multiply by 100. Well you sort of see where this is going. If I add three more zeros look at that I've got six digits of Pi just like that. Now could I get more digits of Pi like how many digits of Pi does the Pi monadic verb give me. Well to start with let's try something here and I'm going to add a couple more and see what it gives me here. Oh look at that it converts automatically over to float. Well that's a problem but Jay actually a really cool thing special combinations of of primitives. If I do this and and this part here that's the floor so whatever fraction I give it it's going to take the integer below it. If I combine the floor here with Pi I will not lose any of the details of this number. So let's just try that out. Look at that. So I've gained all these extra digits here. I got up to three point I gained three extra digits just because this part of it and what's happening here is actually Pi added to the to the floor will keep in the in the calculations will keep from any of the precision being lost in floats. So if I was doing any combination of calculations or whatever and I was doing that when I was multiplying by Pi it's going to retain that as integers. It's keeping that information for me which is really cool. Now we're going to go on to the next thing. I don't want to have to keep writing all these extra zeros here so I'm going to create a verb that's a little nicer than that. So and the way I'm going to create this verb is I'm going to take this and I will do at and I'm going to do parentheses and I'm going to put a fork in here. So what a fork does and this particular fork has a noun and then it's got a center verb which is going to be to the power of and it's going to have a right time which is going to take one off whatever number I feed it. So because it's a fork it's going to say for instance I do this I'll give it 10. So what's happening here is 10 is going to be decremented by 1 to make it 9. It'll be 10 to the power 9 and then when that's all completed 10 to the power 9 is going to get fed into Pi so it's Pi times 10 to the power 9 and then the floor of that and because this combination won't lose any of the detail I've actually picked up this extra digit. What's kind of cool we're almost there. I won't tell you we're all the way there because we're almost there there's one last trick here. So if I go now to 19 you're saying oh that's great look at all the digits I got all the digits of Pi wonderful. If I go to 20 we're back to float. So what's going on here well before I even get to using Pi and floor I'm doing this calculation here and this is giving me a float 10 to the power of 20 is returned as a float. So before I can even retain anything I'm losing that that control. How do I get around that? Well there are a couple ways. I could use a verb that's called precision or extended I think it's called which is x colon and that's a bit messy but what's a lot easier is I can specify any noun I want any noun that's a number as being extended form and as soon as this is an extended form that means this power raised will be an extended form and so what's sent over to Pi will be an extended form and there you go suddenly I've got all these extra digits. So that's pretty cool for Pi Day you can say J has just got this super simple way of delivering Pi for you it's a single monadic verb zero dot that's Pi and whatever you put in you're going to get Pi back and with this little extra bit we're doing in here we can do digits of Pi so let's see just for fun let's try 120. So there you go there's 120 digits of Pi right there so all the neat things that you can do with J on this Pi Day now as an extra little benefit in the notes below I will have a link to the J Playground and the J Playground is a new thing that's been developed by Joe Bogner and Hatte and what it will do is it actually will run J on the browser which is pretty cool because you don't need to download J or anything so if you click on the show notes and this is the one extra thing that they've put in is I can save this verb already being declared now what it'll do is it'll show up in a black area and you'll need to run it to put the verb in but that's good because you'll be able to see exactly what the verb is before you before you run it when you run it it will run the verb and it will actually also give you access to the verb so you can go in declare your own stuff it's a full working J environment and all you need to do is click on the link and then you can play around with some of this stuff and see how big you go I'll tell you right now though when I went to 100,000 yeah hundreds I tried to do 100,000 digits of Pi and my computer which is a fairly beefy computer it's an iMac Pro when I went to do 100,000 digits of Pi it took a little under three minutes to do so and it'll take up a fair amount of memory too to do so try out some of the numbers before you go into whole hog and I tried a million and basically I gave up and just shut my whole program down because it was you know it was just taking so long to do it and in the case of the browser if you do it in the browser version in the jpeg ground just refresh your browser that clears it up it's just you know it's just like yeah that never happened forget about it anyway I hope you enjoyed this and that's my little gift I suppose for Pi Day March 14th 2022 Lord knows we can we can use some gifts right now can't we okay on to better days