Friday, February 6, 2026
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
32491 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6862 POSTS0 COMMENTS
Nicole Veronica
11987 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12075 POSTS0 COMMENTS
Shaida Kate Naidoo
6995 POSTS0 COMMENTS
Ted Musemwa
7237 POSTS0 COMMENTS
Thapelo Manthata
6947 POSTS0 COMMENTS
Umr Jansen
6933 POSTS0 COMMENTS