Skip to content

umcconnell/archimedes-pi

Repository files navigation

archimedes-pi

Approximate pi with Archimedes' method using polygons.

Table of Contents

About

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 π:

Approximation strategy

By starting off with a hexagon and successively doubling the amount of edges, one can approach π through the circumference of the polygon:

Approximation Visualization

From the figure above one can deduce this relation between sn and s2n:

Approximation Formula

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

You will need python3 and pip3 installed on your machine. You can install it from the official website https://www.python.org/.

Running

To run the program, just type:

python3 main.py

Initial setup

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!

Distributing

Installing

To get started, activate the virtual environment:

source venv/bin/activate

Install the packages from requirements.txt:

pip3 install -r requirements.txt

Installing additional packages

After activating the virtual environment, install your package(s)

pip3 install <package>

Then freeze your packages

pip3 freeze > requirements.txt

Contributing

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.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

Ulysse McConnell - umcconnell

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

See also

Acknowledgments