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 expended 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.

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)) 

chevron_right


Output:

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

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)) 

chevron_right


Output:

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


My Personal Notes arrow_drop_up

Coder Machine Learner Social Activist Vocalist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.