neozhaoliang/pywonderland
A tour in the wonderland of math with python.
repo name | neozhaoliang/pywonderland |
repo link | https://github.com/neozhaoliang/pywonderland |
homepage | |
language | Python |
size (curr.) | 10921 kB |
stars (curr.) | 3730 |
created | 2016-11-08 |
license | MIT License |
A Tour in the Wonderland of Math with Python
A collection of python scripts for drawing beautiful figures and animating interesting algorithms in mathematics.
About this repo
The purpose of this project is to show the beauty of math with python. It consists of several independent sub-projects. The topics are chosen largely due to my personal taste:
- They must produce appealing results.
- There must be some non-trivial math behind them.
- The code should be as simple as possible.
I’ll use only popular python libs and build all math stuff by hand (tools like sage
, sympy
, mathemetica
will not be used here). Also I only maintain the code for python >= 3.5
.
The website for the docs is still under construction and will be released soon.
A few examples:
How to use
Each subdirectory in /src/
is a single program (except that glslhelpers
is a helper module for running glsl programs and misc
is a collection of independent scripts), any file named main.py
, run_*.py
, example_*.py
is an executable script that gives some output.
List of algorithms
Here is a list of some algorithms implemented in this project:
- Domino shuffling algorithm
- Hopcroft’s DFA minimization algorithm
- Lempel–Ziv–Welch compression algorithm
- Propp-Wilson’s coupling from the past algorithm
- Todd-Coxeter coset enumeration algorithm
- Wilson’s uniform spanning tree algorithm
- Casselman’s minimal roots algorithm
- Encoding and decoding algorithms for Gray code
Dependencies
The recommended way to install all dependencies is simply running the script install_dependencies.sh
.
Or you can install the python libs by pip:
pip install -r requirements.txt
A few exceptions are: cairocffi
also requires libffi-dev
and pygraphviz
also requires libgraphviz-dev
:
sudo apt-get install libffi-dev libgraphviz-dev
Open source softwares:
python3-tk
(for file dialog)ImageMagick
(for making gif animations)FFmpeg
(for saving animations to video files)POV-Ray
(for generating high quality raytracing results)graphviz
(for drawing automata of Coxeter groups)
They can all be installed via command-line:
sudo apt-get install python3-tk imagemagick ffmpeg povray graphviz
In the scripts these softwares are called in command line by povray
, ffmpeg
, convert
, etc. For Windows users you should add the directories contain these .exe files to the system Path
environment variables. For example on Windows the default location of POV-Ray’s exe file is C:\Program Files\POV-Ray\v3.7\bin\pvengine64.exe
, so you should add C:\Program Files\POV-Ray\v3.7\bin
to system Path
and rename pvengine64.exe
to povray.exe
, then you can run the scripts without any changes and everything works fine.
Thanks
I have learned a lot from the following people:
License
see the LICENSE file.