Approximate pi with Archimedes' method using polygons.
3.14159265358979323846264338327950...
The famous number π pops up just about anywhere in math and physics. It has intrigued mathematicians for thousands of years.
Yet, already around 250 BC the greek mathematician Archimedes developed a simple but ingenious algorithm to approximate π:
By starting off with a hexagon and successively doubling the amount of edges, one can approach π through the circumference of the polygon:
From the figure above one can deduce this relation between sn and s2n:
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You will need python3 and pip3 installed on your machine. You can install it from the official website https://www.python.org/.
To run the program, just type:
python3 main.py
A step by step series of examples that tell you how to get a virtual python environment running:
Clone the git repository
git clone https://github.com/umcconnell/archimedes-pi.git
And navigate into the folder
cd archimedes-pi/
Then create your virtual environment
python3 -m venv venv
Finally, start the virtual environment
source venv/bin/activate
To exit the virtual environment run
deactivate
Happy coding!
To get started, activate the virtual environment:
source venv/bin/activate
Install the packages from requirements.txt
:
pip3 install -r requirements.txt
After activating the virtual environment, install your package(s)
pip3 install <package>
Then freeze your packages
pip3 freeze > requirements.txt
Please read CONTRIBUTING.md and CODE_OF_CONDUCT.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
Ulysse McConnell - umcconnell
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details.
- https://itech.fgcu.edu/faculty/clindsey/mhf4404/Archimedes/Archimedes.html
- https://www.geogebra.org/m/xqXNW5TE
- https://en.wikipedia.org/wiki/Pi
- https://introcs.cs.princeton.edu/java/data/pi-10million.txt : Verification file (shortened to 1 Million digits)
- https://en.wikipedia.org/wiki/Pi : Information on the history of pi