Introduction
Scientific computing broadly means computations carried out for scientific or engineering needs. This mostly includes processing of large arrays or matrices, plotting of functions, solving equations, performing mathematical transforms etc very fast while keeping programming hassles at a minimum.
Requirements of Scientific Computing
The language for scientific computing
- should be Interpreted
- should be modular
- should have easy routines for array, matrix and vectors
- should have a publication quality plotting library
Python for Scientific Computing
Python is an interpreted, modular language that is suitable for scientific computing. Modules such as numpy, scipy etc provide many scientific computing tools. The module matpplotlib alias pylab provides publication quality plotting libraries. Python 2.7 and Python 3 are available in all major Linux distros and can be installed as bundle such as anaconda in Windows. An enhanced Python shell ipython is very helpful and has more functionality than MATLAB and IDL command lines.Installation of scipy, matplotlib and Ipython
The three modules are implemted in apt -based systems such as Ubuntu, Debian etc as
sudo apt-get install python-scipy python-matplotlib ipython ipython3
The modules are available in anaconda for Windows.
Working
- Take a terminal in Linux and type ipython and the interactive Python shell launches
- Everything in the modules are imported as
- from scipy import *
- from pylab import *
- help(scipy)
- help(pylab)
Data Types in Python
Python is an object oriented language and everything in Python is an object. The various data types are listed in Table 1.
| No. | Data Type | Description |
| 1 | Numbers | The numbers can be integers, float, fractions or complex. |
| 2 | Boolean | Can be True or False |
| 3 | String | Sequence of unicode characters |
| 4 | List | Sequence of ordered homogenous values |
| 5 | Tuples | Sequence of heterogenous values |
| 6 | Bytes, Bytearray | These are binary buffers that represent bytes (numbers 0 through 255), often helpful in image processing. |
| 7 | Sets | Set is an unordered collection with no duplicate elements. |
What You Learned
- You understood the requirements of scientific computing
- You understood the use of Python for scientific computing and its data types
- You learned the use of scipy and pylab and the syntax for importing them.
Comments
Post a Comment