Friday, September 26, 2025
HomeLanguagesPython | sympy.expand_func() method

Python | sympy.expand_func() method

With the help of sympy.expand_func() method, we can expand special functions in terms of some mathematical identities.

Syntax: expand_func(expression)

Parameter:
expression – It is mathematical expression which is to expanded.

Returns: Returns a mathematical expression corresponding to the input in terms of some mathematical identities.

Example #1:




# import sympy 
from sympy import * 
  
x = symbols('x')
expr = gamma(x + 3)
print("Expression = {}".format(expr))
   
# Use sympy.expand_func() method 
expand_expr = expand_func(expr)  
      
print("Expanded Expression : {}".format(expand_expr))  


Output:

Expression = gamma(x + 3)
Expanded Expression : x*(x + 1)*(x + 2)*gamma(x)

Example #2:




# import sympy 
from sympy import * 
  
x = symbols('x')
expr = binomial(x, 3)
print("Expression = {}".format(expr))
   
# Use sympy.expand_func() method 
expand_expr = expand_func(expr)  
      
print("Expanded Expression : {}".format(expand_expr))  


Output:

Expression = binomial(x, 3)
Expanded Expression : x*(x - 2)*(x - 1)/6
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32320 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6683 POSTS0 COMMENTS
Nicole Veronica
11854 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11910 POSTS0 COMMENTS
Shaida Kate Naidoo
6795 POSTS0 COMMENTS
Ted Musemwa
7071 POSTS0 COMMENTS
Thapelo Manthata
6755 POSTS0 COMMENTS
Umr Jansen
6762 POSTS0 COMMENTS