Python | sympy.powsimp() method

With the help of sympy.powsimp() method, we can simplify mathematical expressions using laws of indices involving powers.

Syntax: powsimp(expression)

Parameters:
expression – It is the mathematical expression which needs to be simplified.



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

Example #1:
In this example we can see that by using sympy.powsimp() method, we can simplify any mathematical expression using laws of indices involving powers.

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 * x**b
  
print("Before Simplification : {}".format(expr))
    
# Use sympy.powsimp() method
smpl = powsimp(expr) 
    
print("After Simplification : {}".format(smpl)) 

chevron_right


Output:

Before Simplification : x**a*x**b
After Simplification : x**(a + 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 + b))*(x**(-a + b)))
  
print("Before Simplification : {}".format(expr))
    
# Use sympy.powsimp() method
smpl = powsimp(expr) 
    
print("After Simplification : {}".format(smpl)) 

chevron_right


Output:

Before Simplification : x**(-a + b)*x**(2*a + b)
After Simplification : x**(a + 2*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.