And here I was thinking that redoing Day Seven’s Pi function took up my entire day. What on earth can I do with that leftover code? Hm… I was entertained by the Gregory-Leibniz Series and how it was more accurate the more iterations it made, so I wanted to have a little function to look at how close the output get to Pi when the number of iterations increases.
While playing with my code, I learned that toFixed goes out only to 20. How did I miss that, and, more importantly, WHAT IS THE POINT!? I wanted to take Pi out further. I don’t like to be limited with pie or Pi. Other than hardcoding the first 100 decimal places, how would I do it?
I looked at Leibniz formula:
I kept increasing i. The more iterations, the more accurate. See my problem there? If I just do i=5000, then it doesn’t even come out to 3.14159, the digits most people remember. When I’d take it out to i=1000000000, it was more accurate, but the program was slower. And I still couldn’t get it to show more than 20 decimal places. I downloaded some libraries to help (bigdecimal, decimal), but I am still stymied.
I learned plenty, but I also learned that I’ll let the computer limit the user and change the system. I also added validation codes. I might know what numbers to enter, but I have to remember to code for weenies out there.
A lot learned. I’m sorry that I can’t do the Leibniz version. That was fun. I’ve kept it in the code but commented out for when I’m alone at night and want to nibble on German pi while ogling this sex machine: