Wednesday, October 1, 2025
HomeLanguagesPython | sympy.gamma() method

Python | sympy.gamma() method

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)
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32330 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11867 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11926 POSTS0 COMMENTS
Shaida Kate Naidoo
6815 POSTS0 COMMENTS
Ted Musemwa
7078 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6774 POSTS0 COMMENTS