Open In App

Mathematical Functions in Python | Set 4 (Special Functions and Constants)

Last Updated : 29 Jul, 2016
Improve
Improve
Like Article
Like
Save
Share
Report

Some of the mathematical functions are discussed in below set 1, set 2 and set 3
Mathematical Functions in Python | Set 1 (Numeric Functions)
Mathematical Functions in Python | Set 2 (Logarithmic and Power Functions)
Mathematical Functions in Python | Set 3 (Trigonometric and Angular Functions)

Special Functions and constants are discussed in this article.

1. gamma() :- This function is used to return the gamma function of the argument.




# Python code to demonstrate the working of
# gamma()
   
# importing "math" for mathematical operations
import math
  
a = 4
  
# returning the gamma() of 4
print ("The gamma() of 4 is : ", end="")
print (math.gamma(a))


Output:

The gamma() of 4 is : 6.0

2. pi :- This is an inbuilt constant that outputs the value of pi(3.141592).

3. e :- This is an inbuilt constant that outputs the value of e(2.718281).




# Python code to demonstrate the working of
# const. pi and e
   
# importing "math" for mathematical operations
import math
  
# returning the value of const. pi
print ("The value of const. pi is : ", end="")
print (math.pi)
  
# returning the value of const. e
print ("The value of const. e is : ", end="")
print (math.e)


Output:

The value of const. pi is : 3.141592653589793
The value of const. e is : 2.718281828459045

4. inf :- This is a positive floating point infinity constant. -inf is used to denote the negative floating point infinity. This constant is defined in python 3.5 and above.

5. isinf() :- This function is used to check whether the value is an infinity or not.

6. nan :- This constant denotes “Not a number” in python. This constant is defined in python 3.5 and above.

7. isnan() :- This function returns true if the number is “nan” else returns false.




# Python code to demonstrate the working of
# inf, nan, isinf(), isnan()
   
# importing "math" for mathematical operations
import math
  
# checking if number is nan
if (math.isnan(math.nan)):
       print ("The number is nan")
else : print ("The number is not nan")
  
# checking if number is positive infinity
if (math.isinf(math.inf)):
       print ("The number is positive infinity")
else : print ("The number is not positive infinity")


Output:

The number is nan
The number is positive infinity


Similar Reads

Mathematical Functions in Python | Set 2 (Logarithmic and Power Functions)
Numeric functions are discussed in set 1 below Mathematical Functions in Python | Set 1 ( Numeric Functions) Logarithmic and power functions are discussed in this set. 1. exp(a) :- This function returns the value of e raised to the power a (e**a) . 2. log(a, b) :- This function returns the logarithmic value of a with base b. If base is not mentione
3 min read
Mathematical Functions in Python | Set 3 (Trigonometric and Angular Functions)
Some of the mathematical functions are discussed in below set 1 and set 2 Mathematical Functions in Python | Set 1 (Numeric Functions) Mathematical Functions in Python | Set 2 (Logarithmic and Power Functions) Trigonometric and angular functions are discussed in this article. 1. sin() :- This function returns the sine of value passed as argument. T
3 min read
Mathematical Functions in Python | Set 1 (Numeric Functions)
In python a number of mathematical operations can be performed with ease by importing a module named "math" which defines various functions which makes our tasks easier. 1. ceil() :- This function returns the smallest integral value greater than the number. If number is already integer, same number is returned. 2. floor() :- This function returns t
3 min read
Complex Numbers in Python | Set 2 (Important Functions and Constants)
Introduction to python complex numbers: Complex Numbers in Python | Set 1 (Introduction) Some more important functions and constants are discussed in this article. Operations on complex numbers : 1. exp() :- This function returns the exponent of the complex number mentioned in its argument. 2. log(x,b) :- This function returns the logarithmic value
4 min read
Constants of Maths in Python
Math module is a standard in-built module in Python that can be used for performing the mathematical tasks. The math module has a set of methods and constants. Note: For more information, refer to Math-library-functions 1. Python math.e constant: The math.e constant returns the Euler's number: 2.71828182846. Syntax: math.e Returns: Return a float v
2 min read
SciPy - Constants
Scipy stands for Scientific Python and in any Scientific/Mathematical calculation, we often need universal constants to carry out tasks, one famous example is calculating the Area of a circle = 'pi*r*r' where PI = 3.14... or a more complicated one like finding forcegravity = G*M*m ⁄ (distance)2 where G = gravitational constant. In all such scenario
3 min read
Python | Mathematical Median of Cumulative Records
Sometimes, while working with Python tuple list, we can have a problem in which we need to find the median of tuple values in the list. This problem has the possible application in many domains including mathematics. Let’s discuss certain ways in which this task can be performed. Method #1 : Using loops + "~" operator This task can be performed in
8 min read
Plot Mathematical Expressions in Python using Matplotlib
For plotting equations we will use two modules Matplotlib.pyplot and Numpy. This module helps you to organize your Python code logically. Numpy Numpy is a core library used in Python for scientific computing. This Python library supports you for a large, multidimensional array object, various derived objects like matrices and masked arrays, and ass
5 min read
Evaluate the Mathematical Expressions using Tkinter in Python
This article focuses on the evaluation of mathematical expression using the Tkinter and math packages in Python. Tkinter: Python Tkinter is a GUI programming package or built-in package. Tkinter provides the Tk GUI toolkit with a potent object-oriented interface. Python with Tkinter is the fastest and easiest way to create GUI applications. Creatin
2 min read
Special functions in SciPy
In this article, we are going to see about special functions in Scipy. The special functions in scipy are used to perform mathematical operations on the given data. Special function in scipy is a module available in scipy package. Inside this special function, the available methods are: cbrt - which gives the cube root of the given numbercomb - giv
5 min read
Article Tags :
Practice Tags :