Friday, October 10, 2025
HomeLanguagesPython | sympy.expand_pow_exp() method

Python | sympy.expand_pow_exp() method

With the help of sympy.expand_pow_exp() method, we can expand mathematical expression using following identity – 

 x(a+b) = xa.xb

Syntax: expand_pow_exp(expression) 
Parameters: 
expression – It is the mathematical expression which needs to be expanded.
Returns: Returns an expanded mathematical expression corresponding to the input expression. 

Example #1: 
In this example we can see that by using sympy.expand_pow_exp() method, we can expand a mathematical expression in terms of power. 

Python3




# import sympy
from sympy import *
 
x, a, b = symbols('x a b')
expr = x**(a + b)
 
print("Before Expansion : {}".format(expr))
   
# Use sympy.expand_pow_exp() method
smpl = expand_pow_exp(expr)
   
print("After Expansion : {}".format(smpl))


Output: 

Before Expansion : x**(a + b)
After Expansion : x**a*x**b

Example #2: 

Python3




# import sympy
from sympy import *
 
x, a, b = symbols('x a b')
expr = x**(2 * a + 3 * b)
 
print("Before Expansion : {}".format(expr))
   
# Use sympy.expand_pow_exp() method
smpl = expand_pow_exp(expr)
   
print("After Expansion : {}".format(smpl))


Output: 

Before Expansion : x**(2*a + 3*b)
After Expansion : x**(2*a)*x**(3*b) 
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32349 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6715 POSTS0 COMMENTS
Nicole Veronica
11878 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6837 POSTS0 COMMENTS
Ted Musemwa
7097 POSTS0 COMMENTS
Thapelo Manthata
6792 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS