0% found this document useful (0 votes)
57 views8 pages

1.C. Scipy Tutorial

Scipy fundamentals of book

Uploaded by

processaa2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views8 pages

1.C. Scipy Tutorial

Scipy fundamentals of book

Uploaded by

processaa2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

What is SciPy

The SciPy is an open-source scientific library of Python. It is used to solve the


complex scientific and mathematical problems. It is built on top of the Numpy
extension, which means if we import the SciPy, there is no need to import Numpy.
The Scipy is pronounced as Sigh pi, and it depends on the Numpy, including the
appropriate and fast N-dimension array manipulation.

It provides many user-friendly and effective numerical functions for numerical


integration and optimization.

The SciPy library supports integration, gradient optimization, special functions,


ordinary differential equation solvers, parallel programming tools, and many
more. We can say that SciPy implementation exists in every complex numerical
computation.

The scipy is a data-processing and system-prototyping environment as similar to


MATLAB. It is easy to use and provides great flexibility to scientists and engineers.

History

Python was expanded in the 1990s to include an array type for numerical computing
called numeric. This numeric package was replaced by Numpy (blend of Numeric
and NumArray) in 2006. There was a growing number of extension module and
developers were interested to create a complete environment for scientific and
technical computing.
Travis Oliphant, Eric Jones, and Pearu Peterson merged code they had written and
called the new package SciPy. The newly created package provided a standard
collection of common numerical operation on the top of Numpy.

Why use SciPy?

SciPy contain significant mathematical algorithms that provide easiness to develop


sophisticated and dedicated applications. Being an open-source library, it has a large
community across the world to the development of its additional module, and it is
much beneficial for scientific application and data scientists.

Numpy vs. SciPy

Numpy and SciPy both are used for mathematical and numerical analysis. Numpy is
suitable for basic operations such as sorting, indexing and many more because it
contains array data, whereas SciPy consists of all the numeric data.

Numpy contains many functions that are used to resolve the linear algebra, Fourier
transforms, etc. whereas SciPy library contains full featured version of the linear
algebra module as well many other numerical algorithms.
SciPy Sub - Packages

SciPy has the number of sub-packages for the various scientific computing domains.
The following table is given below:

Sr. Sub-Package Description

1. scipy.cluster Cluster algorithms are used to vector quantization/ Kmeans.

2. scipy.constants It represents physical and mathematical constants.

3. scipy.fftpack It is used for Fourier transform.

4. scipy.integrate Integration routines

5. scipy.interpolation Interpolation

6. scipy.linalg It is used for linear algebra routine.

7. scipy.io It is used for data input and output.

8. scipy.ndimage It is used for the n-dimension image.

9. scipy.odr Orthogonal distance regression.

10. scipy.optimize It is used for optimization.

11. scipy.signal It is used in signal processing.

12. scipy.sparse Sparse matrices and associated routines.

13. scipy.spatial Spatial data structures and algorithms.

14. scipy.special Special Function.


15. scipy.stats Statistics.

16. scipy.weaves It is a tool for writing.

SciPy Constant

The scipy.constant package is available with a wide range of constants, which is


used extensively in the scientific field. There are various physical, mathematical
constants and units that we can import the required constants and use them as per
needed.

List of Mathematical constant

The scipy.constant provides the following list of mathematical constants.

Sr. No. Constants Description

1. pi pi

2. golden Golden ratio

Consider the following example of scipy.constant. Here we compare the 'pi' value by importing
different modules.

#Import pi constant from the scipy


from scipy.constants import pi
#Import pi from math package
from math import pi
#Comparing these two pi value
print("sciPy - pi Value = %.18f"%scipy.constants.pi)
print("math - pi Value = %.18f"%math.pi)

Output:

The above code will give the following output. As we can observe that both values are same.

sciPy - pi Value = 3.141592653589793116


math - pi Value = 3.141592653589793116

Physical Constants

The scipy.constant package provides the number of physical constants. The most
commonly used physical constants are the following:

Sr. No. Physical Constants Description

1. c Speed of light in vaccum

2. speed_of_light Speed of light in vaccum

3. G Standard acceleration of gravity

4. G Newton Constant of gravitation

5. E Elementry charge

6. R Molar gas constant

7. Alpha Fine-structure constant

8. N_A Avagadro constant


9. K Boltzmann constant

10 Sigma Stefan-Boltzmann constant σ

11. m_e Electron mass

12. m_p Proton mass

13. m_n Neutron Mass

14. H Plank Constant

15. Plank constant Plank constant h

Other important Constant

It is difficult to remember all units; the few essential constants are listed below:

Sr. No. Units Value

1. Mass

Gram One gram in Kilogram.

Grain One grain in Kilogram.

Pound One Pound in Kilogram.

Ounce One Ounce in Kilogram.

automic_mass Atomics mass constant in Kilogram.


2. Time

Minute One minute in seconds.

Hour One hour in seconds.

Day One day in seconds.

Year One year in seconds.

3. Length

Inch One inch in meters.

Foot One foot in meters.

Yard One yard in meters.

Pt One point in meters.

Micron One Micron in meters.

4. Pressure

Atm The standard atmosphere in pascals.

Atmosphere The standard atmosphere in pascals.

Bar One bar in Pascals.

Torr One torr(mmHg) in pascals.

5. Area

Hectare One hectare in square meters.

Acre One acre in square meters.


6. Speed

Kmh Kilometer per hour in meter per second.

Mph Miles per hour in meter per second.

Mach One Match in meter per second.

The scipy.constant provides the find() function, which returns a list of physical_constant keys
containing a given string.

Consider the following example:

1. from scipy.constants import find, physical_constants


2. find('boltzmann')

Output:

['Boltzmann constant',
'Boltzmann constant in Hz/K',
'Boltzmann constant in eV/K',
'Boltzmann constant in inverse meters per kelvin',
'Stefan-Boltzmann constant']

You might also like