Python-based ecosystem of open-source software for mathematics, science, and engineering
The project was split up into:
see http://ipython.readthedocs.io/en/stable/interactive/index.html for a complete list
Documentation
import math
math.sqrt?
Docstring: sqrt(x) Return the square root of x. Type: builtin_function_or_method
Profiling
%timeit math.sqrt(2)
The slowest run took 23.18 times longer than the fastest. This could mean that an intermediate result is being cached. 1000000 loops, best of 3: 259 ns per loop
from math import sqrt
%timeit sqrt(2)
The slowest run took 24.61 times longer than the fastest. This could mean that an intermediate result is being cached. 10000000 loops, best of 3: 179 ns per loop
%timeit 2**0.5
The slowest run took 76.18 times longer than the fastest. This could mean that an intermediate result is being cached. 10000000 loops, best of 3: 24.8 ns per loop
Debugging
%pdb
a = math.sqrt(-1)
print(a)
Automatic pdb calling has been turned ON
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-6-4c17f9ae18c9> in <module>() 1 get_ipython().magic('pdb') ----> 2 a = math.sqrt(-1) 3 print(a) ValueError: math domain error
> <ipython-input-6-4c17f9ae18c9>(2)<module>() 1 get_ipython().magic('pdb') ----> 2 a = math.sqrt(-1) 3 print(a) ipdb> c
Plotting
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
plt.plot(np.arange(10), np.sqrt(np.arange(10)))
[<matplotlib.lines.Line2D at 0x7fb78a68bc50>]
Execute Shell Commands
!cat /etc/passwd | head -n 2
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin