Using Python as a math shell
Python can be used as a MATLAB-like shell for math and stuff.
The following components are needed (in order of decreasing importance):
- IPython
- NumPy
- Matplotlib
- SciPy
- SymPy
IPython makes the Python shell behave more like tools such as MATLAB.
Creating IPython profile for math
We need to set up an IPython profile that automatically imports the aforementioned math-related libraries.
First, create a new IPython profile:
$ ipython profile create math
Then, add a startup script to this profile. Create a Python file in the startup directory, which is found at ~/.ipython/profile_math/startup
In this file, import all the necessary math libraries. Here's an example:
- 0-init.py
import numpy as np import scipy import sympy import matplotlib.pyplot as plt
Running profile
To run this profile, run the following command:
ipython --profile=math
Create bash alias
In order to not have to run that command every time, you can create a bash alias. Add this line to ~/.bashrc
:
alias matpy-shell="ipython --profile=math"