In [4]:
import numpy as np
n = 5
x = np.arange(n)
y = np.zeros(n)
for i in range(n):
y[i] = x[i]*x[i]
z = x*x
print(x)
print(y)
print(z)
In [5]:
import matplotlib.pylab as plt
plt.plot(x,y)
plt.plot(x,z)
plt.show()
When you run this notebook it will pop up a simple plot. You can save this notebook (.ipynb file) as a python script and run it from the unix command line as follows:
python mymath.py
or if you edit this file and as first line add
#! /usr/bin/env python
and make this script executable
chmod +x mymath.py
you can then run it as follows:
./mymath.py
In [ ]: