
- SciPy - Home
- SciPy - Introduction
- SciPy - Environment Setup
- SciPy - Basic Functionality
- SciPy - Relationship with NumPy
- SciPy Clusters
- SciPy - Clusters
- SciPy - Hierarchical Clustering
- SciPy - K-means Clustering
- SciPy - Distance Metrics
- SciPy Constants
- SciPy - Constants
- SciPy - Mathematical Constants
- SciPy - Physical Constants
- SciPy - Unit Conversion
- SciPy - Astronomical Constants
- SciPy - Fourier Transforms
- SciPy - FFTpack
- SciPy - Discrete Fourier Transform (DFT)
- SciPy - Fast Fourier Transform (FFT)
- SciPy Integration Equations
- SciPy - Integrate Module
- SciPy - Single Integration
- SciPy - Double Integration
- SciPy - Triple Integration
- SciPy - Multiple Integration
- SciPy Differential Equations
- SciPy - Differential Equations
- SciPy - Integration of Stochastic Differential Equations
- SciPy - Integration of Ordinary Differential Equations
- SciPy - Discontinuous Functions
- SciPy - Oscillatory Functions
- SciPy - Partial Differential Equations
- SciPy Interpolation
- SciPy - Interpolate
- SciPy - Linear 1-D Interpolation
- SciPy - Polynomial 1-D Interpolation
- SciPy - Spline 1-D Interpolation
- SciPy - Grid Data Multi-Dimensional Interpolation
- SciPy - RBF Multi-Dimensional Interpolation
- SciPy - Polynomial & Spline Interpolation
- SciPy Curve Fitting
- SciPy - Curve Fitting
- SciPy - Linear Curve Fitting
- SciPy - Non-Linear Curve Fitting
- SciPy - Input & Output
- SciPy - Input & Output
- SciPy - Reading & Writing Files
- SciPy - Working with Different File Formats
- SciPy - Efficient Data Storage with HDF5
- SciPy - Data Serialization
- SciPy Linear Algebra
- SciPy - Linalg
- SciPy - Matrix Creation & Basic Operations
- SciPy - Matrix LU Decomposition
- SciPy - Matrix QU Decomposition
- SciPy - Singular Value Decomposition
- SciPy - Cholesky Decomposition
- SciPy - Solving Linear Systems
- SciPy - Eigenvalues & Eigenvectors
- SciPy Image Processing
- SciPy - Ndimage
- SciPy - Reading & Writing Images
- SciPy - Image Transformation
- SciPy - Filtering & Edge Detection
- SciPy - Top Hat Filters
- SciPy - Morphological Filters
- SciPy - Low Pass Filters
- SciPy - High Pass Filters
- SciPy - Bilateral Filter
- SciPy - Median Filter
- SciPy - Non - Linear Filters in Image Processing
- SciPy - High Boost Filter
- SciPy - Laplacian Filter
- SciPy - Morphological Operations
- SciPy - Image Segmentation
- SciPy - Thresholding in Image Segmentation
- SciPy - Region-Based Segmentation
- SciPy - Connected Component Labeling
- SciPy Optimize
- SciPy - Optimize
- SciPy - Special Matrices & Functions
- SciPy - Unconstrained Optimization
- SciPy - Constrained Optimization
- SciPy - Matrix Norms
- SciPy - Sparse Matrix
- SciPy - Frobenius Norm
- SciPy - Spectral Norm
- SciPy Condition Numbers
- SciPy - Condition Numbers
- SciPy - Linear Least Squares
- SciPy - Non-Linear Least Squares
- SciPy - Finding Roots of Scalar Functions
- SciPy - Finding Roots of Multivariate Functions
- SciPy - Signal Processing
- SciPy - Signal Filtering & Smoothing
- SciPy - Short-Time Fourier Transform
- SciPy - Wavelet Transform
- SciPy - Continuous Wavelet Transform
- SciPy - Discrete Wavelet Transform
- SciPy - Wavelet Packet Transform
- SciPy - Multi-Resolution Analysis
- SciPy - Stationary Wavelet Transform
- SciPy - Statistical Functions
- SciPy - Stats
- SciPy - Descriptive Statistics
- SciPy - Continuous Probability Distributions
- SciPy - Discrete Probability Distributions
- SciPy - Statistical Tests & Inference
- SciPy - Generating Random Samples
- SciPy - Kaplan-Meier Estimator Survival Analysis
- SciPy - Cox Proportional Hazards Model Survival Analysis
- SciPy Spatial Data
- SciPy - Spatial
- SciPy - Special Functions
- SciPy - Special Package
- SciPy Advanced Topics
- SciPy - CSGraph
- SciPy - ODR
- SciPy Useful Resources
- SciPy - Reference
- SciPy - Quick Guide
- SciPy - Cheatsheet
- SciPy - Useful Resources
- SciPy - Discussion
SciPy - Constants
What are Scipy Constants?
The scipy.constants is a module within the SciPy library that provides a comprehensive set of physical constants and unit conversions. These constants are essential for scientific computations across various fields such as physics, astronomy, chemistry and engineering.
The module standardizes the values of fundamental physical quantities by making it easier for scientists and engineers to perform accurate and consistent calculations.
Before getting into detail of sciPy constants, let us compare the pi value by considering the following example −
import scipy.constants as constants import math # Print values of pi from SciPy and math modules print("SciPy - pi = %.16f" % constants.pi) print("Math - pi = %.16f" % math.pi)
When we execute the above code both the packages gives the output as below −
SciPy - pi = 3.1415926535897931 Math - pi = 3.1415926535897931
Types of Scipy Constants
In the scipy.constants module the constants are categorized into several types in which each serving different purposes across scientific disciplines. Heres a detailed overview of the types of constants available −
Physical Constants
In SciPy Physical Constants are predefined values for fundamental physical quantities that are used across various scientific and engineering disciplines. These constants are included in the scipy.constants module and are critical for calculations and simulations in physics, chemistry and engineering.
Following are the key physical constants available in the module scipy.constants −
Constant | Description | Value |
---|---|---|
c | Speed of light in vacuum | 299,792,458 m/s |
speed_of_light | Speed of light in vacuum | 299,792,458 m/s |
h | Planck constant | 6.62607015 1034 Js |
Planck | Planck constant | 6.62607015 1034 Js |
G | Newtons gravitational constant | 6.67430 1011 mkg1s2 |
e | Elementary charge | 1.602176634 1019 C |
R | Molar gas constant | 8.314 J/(molK) |
Avogadro | Avogadro constant | 6.02214076 1023 mol1 |
k | Boltzmann constant | 1.380649 1023 J/K |
electron_mass (or m_e) | Electron mass | 9.10938356 1031 kg |
proton_mass (or m_p) | Proton mass | 1.672621923 1027 kg |
neutron_mass (or m_n) | Neutron mass | 1.675 1027 kg |
Astronomical Constants
Astronomical constants are fundamental values used in astronomy and astrophysics to describe and quantify various properties of celestial objects and their interactions. These constants are essential for calculations involving orbital dynamics, celestial mechanics and the general behavior of astronomical systems.
Following are the few Astronomical constants available in scipy.constants module −
Constant | Description | Value |
---|---|---|
AU | Astronomical Unit | 149,597,870.7 km |
Light-year | Distance light travels in a year | 9.4607 1012 km |
Parsec | Distance at which one astronomical unit subtends an angle of one arc second | 3.0857 1013 km |
Solar Mass | Mass of the Sun | 1.989 1030 kg |
Solar Radius | Radius of the Sun | 6.963 108 km |
Jupiter Mass | Mass of Jupiter | 1.898 1027 kg |
Jupiter Radius | Radius of Jupiter | 6.9911 107 m |
Earth Mass | Mass of Earth | 5.972 1024 kg |
Earth Radius | Radius of Earth | 6,371 km |
Mean Distance Earth-Moon | Average distance from Earth to Moon | 384,400 km |
Mean Distance Earth-Sun | Average distance from Earth to Sun (AU) | 149,597,870.7 km |
Mathematical Constants
Mathematical constants are specific well-defined numbers that arise in various mathematical contexts. These constants are fundamental to many areas of mathematics, science and engineering.
Below is a list of some important mathematical constants, their definitions and their significance:
Constant | Description | Value | Description |
---|---|---|---|
Pi | 3.141592653589793 | Ratio of the circumference of a circle to its diameter. Appears in geometry, trigonometry, and calculus. | |
Euler's Number | e | 2.718281828459045 | Base of the natural logarithm. Important in calculus, growth models, and complex analysis. |
Golden Ratio | or | 1.618033988749895 | Solution to = + 1. Appears in art, architecture, and nature. |
Square Root of 2 | 2 | 1.414213562373095 | Length of the diagonal of a unit square. Appears in geometry and trigonometry. |
Square Root of 3 | 3 | 1.732050807568877 | Length of the diagonal of a unit cube. Used in geometry and trigonometry. |
Natural Logarithm of 2 | ln(2) | 0.693147180559945 | Logarithm base e of 2. Important in information theory and exponential growth/decay models. |
Catalan's Constant | G | 0.915965594177219 | Appears in combinatorial mathematics, specifically in problems related to lattice paths. |
Apry's Constant | (3) | 1.202056903159594 | Value of the Riemann zeta function at 3. Important in number theory and mathematical analysis. |
The Square of e | e | 7.389056098930649 | Exponential function of e. Useful in various exponential growth models. |
The Logarithm of 10 | log(10) | 1.0 | Base 10 logarithm of 10. Often used in scientific notation and logarithmic scales. |
The Logarithm of 2 | log(2) | 0.301029995663981 | Base 10 logarithm of 2. Used in information theory and computer science. |
Euler-Mascheroni Constant | 0.577215664901532 | Appears in number theory and the study of harmonic series. | |
Feigenbaum Constant | 4.669201609102990 | Appears in the study of chaotic systems and bifurcations. | |
Khinchin's Constant | K | 2.685452001065306 | Appears in the study of continued fractions. |
Glaisher-Kinkelin Constant | A | 1.282427129100622 | Appears in combinatorial mathematics and number theory. |
Madhava-Leibniz Constant | M | 0.946083070367183 | Appears in the series expansion of . |
Unit Conversion Constants
Unit conversion constants are values used to convert measurements from one unit to another. These constants are crucial in scientific, engineering and everyday calculations to ensure consistent and accurate conversions between different units of measurement. Below is a list of common unit conversion constants and their descriptions.
Conversion | From Unit | To Unit | Constant Value | Description |
---|---|---|---|---|
Length | Meter | Kilometer | 0.001 | 1 meter is 0.001 kilometers. |
Length | Meter | Centimeter | 100 | 1 meter is 100 centimeters. |
Length | Meter | Millimeter | 1000 | 1 meter is 1000 millimeters. |
Length | Inch | Centimeter | 2.54 | 1 inch is 2.54 centimeters. |
Length | Foot | Meter | 0.3048 | 1 foot is 0.3048 meters. |
Length | Yard | Meter | 0.9144 | 1 yard is 0.9144 meters. |
Area | Square Meter | Square Kilometer | 1e-6 | 1 square meter is 1e-6 square kilometers. |
Area | Square Meter | Square Centimeter | 1e4 | 1 square meter is 10,000 square centimeters. |
Volume | Liter | Cubic Meter | 0.001 | 1 liter is 0.001 cubic meters. |
Volume | Gallon (US) | Liter | 3.78541 | 1 US gallon is approximately 3.78541 liters. |
Volume | Milliliter | Cubic Centimeter | 1 | 1 milliliter is 1 cubic centimeter. |
Mass | Gram | Kilogram | 0.001 | 1 gram is 0.001 kilograms. |
Mass | Pound | Kilogram | 0.453592 | 1 pound is approximately 0.453592 kilograms. |
Mass | Ounce | Gram | 28.3495 | 1 ounce is approximately 28.3495 grams. |
Temperature | Celsius | Fahrenheit | F = (C 9/5) + 32 | Formula to convert Celsius to Fahrenheit. |
Temperature | Fahrenheit | Celsius | C = (F - 32) 5/9 | Formula to convert Fahrenheit to Celsius. |
Temperature | Kelvin | Celsius | C = K - 273.15 | 0 Kelvin is -273.15C. |
Temperature | Celsius | Kelvin | K = C + 273.15 | 0C is 273.15 Kelvin. |
Energy | Joule | Calorie | 0.239006 | 1 joule is approximately 0.239006 calories. |
Energy | Calorie | Joule | 4.184 | 1 calorie is 4.184 joules. |
Energy | Electronvolt | Joule | 1.60218e-19 | 1 electronvolt is 1.60218e-19 joules. |
Pressure | Pascal | Bar | 1e-5 | 1 Pascal is 1e-5 bars. |
Pressure | Atmosphere | Pascal | 101325 | 1 atmosphere is 101,325 Pascals. |
Speed | Kilometer per Hour | Meter per Second | 0.277778 | 1 km/h is approximately 0.277778 m/s. |
Speed | Mile per Hour | Meter per Second | 0.44704 | 1 mph is approximately 0.44704 m/s. |
List of Constants in SciPy
Here we have listed few constants available in scipy, but if we want to get all the constants available in scipy.constansts module below code can be executed −
import scipy from scipy import constants print(dir(scipy.constants))
Following are the all available constant methods in scipy.constants module −
['Avogadro', 'Boltzmann', 'Btu', 'Btu_IT', 'Btu_th', 'ConstantWarning', 'G', 'Julian_year', 'N_A', 'Planck', 'R', 'Rydberg', 'Stefan_Boltzmann', 'Wien', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_codata', '_constants', '_obsolete_constants', 'acre', 'alpha', 'angstrom', 'arcmin', 'arcminute', 'arcsec', 'arcsecond', 'astronomical_unit', 'atm', 'atmosphere', 'atomic_mass', 'atto', 'au', 'bar', 'barrel', 'bbl', 'blob', 'c', 'calorie', 'calorie_IT', 'calorie_th', 'carat', 'centi', 'codata', 'constants', 'convert_temperature', 'day', 'deci', 'degree', 'degree_Fahrenheit', 'deka', 'dyn', 'dyne', 'e', 'eV', 'electron_mass', 'electron_volt', 'elementary_charge', 'epsilon_0', 'erg', 'exa', 'exbi', 'femto', 'fermi', 'find', 'fine_structure', 'fluid_ounce', 'fluid_ounce_US', 'fluid_ounce_imp', 'foot', 'g', 'gallon', 'gallon_US', 'gallon_imp', 'gas_constant', 'gibi', 'giga', 'golden', 'golden_ratio', 'grain', 'gram', 'gravitational_constant', 'h', 'hbar', 'hectare', 'hecto', 'horsepower', 'hour', 'hp', 'inch', 'k', 'kgf', 'kibi', 'kilo', 'kilogram_force', 'kmh', 'knot', 'lambda2nu', 'lb', 'lbf', 'light_year', 'liter', 'litre', 'long_ton', 'm_e', 'm_n', 'm_p', 'm_u', 'mach', 'mebi', 'mega', 'metric_ton', 'micro', 'micron', 'mil', 'mile', 'milli', 'minute', 'mmHg', 'mph', 'mu_0', 'nano', 'nautical_mile', 'neutron_mass', 'nu2lambda', 'ounce', 'oz', 'parsec', 'pebi', 'peta', 'physical_constants', 'pi', 'pico', 'point', 'pound', 'pound_force', 'precision', 'proton_mass', 'psi', 'pt', 'quecto', 'quetta', 'ronna', 'ronto', 'short_ton', 'sigma', 'slinch', 'slug', 'speed_of_light', 'speed_of_sound', 'stone', 'survey_foot', 'survey_mile', 'tebi', 'tera', 'test', 'ton_TNT', 'torr', 'troy_ounce', 'troy_pound', 'u', 'unit', 'value', 'week', 'yard', 'year', 'yobi', 'yocto', 'yotta', 'zebi', 'zepto', 'zero_Celsius', 'zetta']