I wrote a parallel C++ version and ran this on my Uni's computing cluster across 1000 cores with 5*10^14 sample points in total (took just under 8 hours) and I only got the first 6 digits right. Looks like it doesn't scale as well as you thought :D
>"Hi and welcome to numberphile" >camera zooms in on the fase of some sperglord already covered in sweat >"Today we are going to talk about the number five" >sperglord smiles the smile of a thousand suns >drops of sweat pouring from his forehead >he writes the number five on a paper >"The amazing thing about this number is that it is a part of you" >camera zooms in on his hand that is soaked in sweat and shaking uncontrolably >"As you can see my hand contains five fingers" >a tear falls from his eye >"I would not even know what to do with myself if not for five" >looks at the camera like he is seeing god >tears of joy raining down his cheeks >In a shaky voice he says: >"Without five I couldn't even count to six!" >begins to cry
Thanks for this Andrew. As someone learning Python its great to see it's very casual usages, and the lines as thought out in real time. Numerical integration would be great.
Depends on the general length of the program you do but from an performance point of view, an for loop is much better. Also great video man but your coding style made me cringe a bit :))
As every point lies in a square, there shouldn't be an if else statement, coz the coordinates get added to square coordinates if they are not in a circle. But all the points do lie in the square, well the output would be right still as you tool float(N) at last computation.
Stupidest thing I've ever seen. Non deterministicly approaches pi in 2*10^n multiplications where n is each digit of precision. Archimedes did it better 1000s of years ago.
Using the Monte Carlo Method for numerical integration would seem like a really awesome video to make. I've seen it used for the Brachistochrone problem when I was doing an experimental physics project in MatLab a couple years back.
This is awesome andrew. I dont even know anything about coding, but i enjoy math, and you make it easy to understand whats going on with your work. Excellent job, man.
You can also get the root of the sum of 6/x^2 and you will get to pi at infinity (or pretty close with a very high number) or this pattern [ (-1)^(x+1)/2x-1 ]
I think generating points in a grid like you had shown in the beginning and than counting them would be more accurate. Also, using only a quarter circle is 4 times faster but has the same precision. Then again, you could write a simple program to integrate sqrt(1-x^2) by divideing it into small rectangles. This could be a part two of this wideo, since it is very useful to see how numerical integration works. You can also better understand the definition of a Riemann integral by this example.
*draws circle
"This is a square"
It's an approximation!
Parker square!
Subduralempyema the new sinx=x
I wrote a parallel C++ version and ran this on my Uni's computing cluster across 1000 cores with 5*10^14 sample points in total (took just under 8 hours) and I only got the first 6 digits right. Looks like it doesn't scale as well as you thought :D
1:46 we can stop here, that's a good estimation
How I approximate pi in Python:
import numpy as np
print(np.pi)
But sure, I suppose a Monte Carlo approach works too :D
"how to estimate pi"
Say the word "three"
Job done
I increased N to be around 100000000000000000000000000000 and my computer crashed.
>"Hi and welcome to numberphile"
>camera zooms in on the fase of some sperglord already covered in sweat
>"Today we are going to talk about the number five"
>sperglord smiles the smile of a thousand suns
>drops of sweat pouring from his forehead
>he writes the number five on a paper
>"The amazing thing about this number is that it is a part of you"
>camera zooms in on his hand that is soaked in sweat and shaking uncontrolably
>"As you can see my hand contains five fingers"
>a tear falls from his eye
>"I would not even know what to do with myself if not for five"
>looks at the camera like he is seeing god
>tears of joy raining down his cheeks
>In a shaky voice he says:
>"Without five I couldn't even count to six!"
>begins to cry
Based and gay
lol i saw seen this meme a while ago. thank you for reminding me of it.
One of the first things I did when learning how to code in python was approximating pi, its a good exercise! Great Video!
Thanks for this Andrew. As someone learning Python its great to see it's very casual usages, and the lines as thought out in real time. Numerical integration would be great.
Awesome! Good luck with python!
First thought: Monte Carlo?
3:50 Monte Carlo!
same!
I think just use Ramanujan or any other fundamental series approx formulaes and will give digits upto ones will.
That was a real Parker Square
Why couldn't you just use a for-loop?
Also, could you do a vid implementing monte-carlo in python?
for loop, while loop, doesn't matter. And I'm thinking about it
Andrew Dotson ye but using a while loop there is _filthy_
@@XanderGouws Exactly my thoughts
Depends on the general length of the program you do but from an performance point of view, an for loop is much better. Also great video man but your coding style made me cringe a bit :))
As every point lies in a square, there shouldn't be an if else statement, coz the coordinates get added to square coordinates if they are not in a circle. But all the points do lie in the square, well the output would be right still as you tool float(N) at last computation.
God this mans beard is perfect
Tl Dw answer is 3
If this is a square then pi equals to 4.
Now i am know how engineers think.
Hey just wondering what packages would you recommend installing for these types of things in Jupyter
Can't go wrong with numpy, scipy, sympy, and matplotlib. But I also think those come with anaconda.
Stupidest thing I've ever seen. Non deterministicly approaches pi in 2*10^n multiplications where n is each digit of precision. Archimedes did it better 1000s of years ago.
Using the Monte Carlo Method for numerical integration would seem like a really awesome video to make. I've seen it used for the Brachistochrone problem when I was doing an experimental physics project in MatLab a couple years back.
This video is pointless. Everyone knows π = 3.
First
Great Video!! more videos like these please
When did you start learning Python?
Wow only a year ago now that I think about it.
This is awesome andrew. I dont even know anything about coding, but i enjoy math, and you make it easy to understand whats going on with your work. Excellent job, man.
Means a lot! THank you!
"..... Cool!"
Cool! Helped me a lot in Numerical Methods at college, thanks. I'm from Brazil!
is there a book that covers this material. like what "append" means etc? I got "Doing Math With Python" but it seems very basic.
Why throw darts at random? Can't you just spread the darts evenly to get an absolutely converging sequence?
what if I take the random variables range as (0,2) for both x and y??..its not going to give the right value..but i cant understand why
You can also get the root of the sum of 6/x^2 and you will get to pi at infinity (or pretty close with a very high number) or this pattern [ (-1)^(x+1)/2x-1 ]
Literally did the same project about a year ago. Lent itself to a some statistic analysis to improve the approximation. Good stuff though.
God bless you
14:55 CMBR???
thanks :D
I’ve got another way that’s a lot simpler. print(3)
I think an easier way wouldve been to use the series for arctanx and have it iterate n amount of times to give an approximation
What about using various infinite series representations of pi?
I think generating points in a grid like you had shown in the beginning and than counting them would be more accurate. Also, using only a quarter circle is 4 times faster but has the same precision. Then again, you could write a simple program to integrate sqrt(1-x^2) by divideing it into small rectangles. This could be a part two of this wideo, since it is very useful to see how numerical integration works. You can also better understand the definition of a Riemann integral by this example.
Great
Great video man, I'm looking foward to learn python, i only know how to code on Java a little, python looks very different but the kind I like.
Video start:
This is a square.
Close video.
Please, for the love of God, shave that beard. Great video.