Thursday, October 2, 2025
HomeLanguagesPython | sympy.combsimp() method

Python | sympy.combsimp() method

With the help of sympy.combsimp() method, we can simplify combinatorial expressions.

Syntax: combsimp(expression)

Parameter:
expression – It is combinatorial expression which needs to be simplified.

Returns: Returns a simplified mathematical expression corresponding to the input.

Example #1:




# import sympy 
from sympy import * 
  
n = symbols('n', integer = True)
expr = factorial(n)/factorial(n - 3)
print("Expression = {}".format(expr))
   
# Use sympy.combsimp() method 
simple_expr = combsimp(expr)  
      
print("Simplified Expression : {}".format(simple_expr))  


Output:

Expression = factorial(n)/factorial(n - 3)
Simplified Expression : n*(n - 2)*(n - 1)

Example #2:




# import sympy 
from sympy import * 
  
n, k = symbols('n k', integer = True)
expr = binomial(n + 1, k + 1)/binomial(n, k)
print("Expression = {}".format(expr))
   
# Use sympy.combsimp() method 
simple_expr = combsimp(expr)  
      
print("Simplified Expression : {}".format(simple_expr))  


Output:

Expression = binomial(n+1, k+1)/binomial(n, k)
Simplified Expression : (n + 1)/(k + 1)
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32331 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11867 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11926 POSTS0 COMMENTS
Shaida Kate Naidoo
6818 POSTS0 COMMENTS
Ted Musemwa
7079 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS