I’ve found that the best way to learn difficult mathematical concepts is to simply play around. Just play! Imagine you’re a kid again, messing with a new toy, breaking it in. In terms of math, sometimes this means taking out the scratch paper and pencil to write out any equations, formulas, knowns, unknowns, etc. with the general objective of gaining insight. Other times it means booting up Python, Matlab or some other scripting language to crunch numbers and display graphs.
Regardless of the method, it’s important to avoid getting bogged down with irrelavent details. This is especially true when trying to learn via the scripting route. Fortunately, the global Python community understands this concept quite well. With tools like IPython, SciPy, matplotlib, pandas, and more, trying out new mathematical concepts on the computer is an absolute pleasure.
Recently, I’ve begun doing my math “play time” using Jupyter (part of the IPython project). This post is a very quick summary about getting up and running with Jupyter and some of the more useful math-related Python packages. Although these programs are easy enough to install by themselves, I would recommend creating a conda environment to make installation and the subsequent management a breeze.
conda update conda
During the installation process, you might have been triggered to modify your PATH. If you’re like me and you said “No”, then you will need to temporarily update your PATH every time you open a new terminal:
Of course, this can get annoying really quick. A better solution is to write a “source” file called conda.src and save it in a convenient location. The contents would be your export statement:
# execute with `source *.src` export PATH=/your/path/to/anaconda/bin:$PATH
Then, every time you open a new terminal, just run:
Easier to remember and type, right? Okay, now that’s out of the way. Let’s create a new conda environment and install the necessary Python packages for studying math! First, we will create an environment called math that uses Python 3.4. Then, we activate the environment and install a bunch of cool Python packages:
conda create -n math python=3.4 source activate math conda install pandas numexpr bottleneck scipy matplotlib statsmodels ipython jupyter
Test your new environment by invoking Python. It should tell you that you’re running version 3.4:
Note that you can exit the math environment at any time by calling
To boot up Jupyter, simply create or navigate to any directory in which you’d like to create your notebooks and type:
At this point, we’ve got IPython and Jupyter installed, along with many of the more useful Python packages for mathematical exploration. Please view this IPython Overview to catch a quick glimpse of the possibilities.