Friday, September 19, 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
32301 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6665 POSTS0 COMMENTS
Nicole Veronica
11840 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11898 POSTS0 COMMENTS
Shaida Kate Naidoo
6781 POSTS0 COMMENTS
Ted Musemwa
7056 POSTS0 COMMENTS
Thapelo Manthata
6739 POSTS0 COMMENTS
Umr Jansen
6744 POSTS0 COMMENTS