Open In App

Python | sympy.powsimp() method

Last Updated : 18 Apr, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
With the help of sympy.powsimp() method, we can simplify mathematical expressions using laws of indices involving powers. Properties : 1) x**a*x**b = x**(a+b) 2) x**a*y**a = (xy)**a
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. Python3
# 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)) 
Output:
Before Simplification : x**a*x**b
After Simplification : x**(a + b)
Example #2: Python3
# 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)) 
Output:
Before Simplification : x**(-a + b)*x**(2*a + b)
After Simplification : x**(a + 2*b)

Article Tags :
Practice Tags :

Similar Reads