Skip to content
Related Articles

Related Articles

Improve Article

Python | sympy.gamma() method

  • Last Updated : 07 Jul, 2019

With the help of sympy.gamma() method, we can find the gamma function in SymPy. gamma(z) represents \Gamma(z) = \int_0^\infty t^{z - 1}e^{-t}\, dt, which for positive integer z is the same as (z - 1)!.

Syntax: gamma(Z)

Parameters:
Z – It is the input value to the gamma function.

Returns: Returns the gamma function result of the input value.

Example #1:






# import sympy 
from sympy import * 
  
Z = 5
print("Z = {}".format(Z))
   
# Use sympy.gamma() method 
gamma_Z = gamma(Z)  
      
print("gamma(Z) : {}".format(gamma_Z))  

Output:

Z = 5
gamma(Z) : 24

Example #2:




# import sympy 
from sympy import * 
  
X = symbols('x')
print("X = {}".format(X))
   
# Use sympy.gamma() method 
gamma_X = gamma(X)  
      
print("gamma(X) : {}".format(gamma_X))  

Output:

X = x
gamma(X) : gamma(x)

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :