Python | sympy.powsimp() method
Last Updated :
18 Apr, 2020
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.
from sympy import *
x, a, b = symbols( 'x a b' )
expr = x * * a * x * * b
print ( "Before Simplification : {}" . format (expr))
smpl = powsimp(expr)
print ( "After Simplification : {}" . format (smpl))
|
Output:
Before Simplification : x**a*x**b
After Simplification : x**(a + b)
Example #2:
from sympy import *
x, a, b = symbols( 'x a b' )
expr = ((x * * ( 2 * a + b)) * (x * * ( - a + b)))
print ( "Before Simplification : {}" . format (expr))
smpl = powsimp(expr)
print ( "After Simplification : {}" . format (smpl))
|
Output:
Before Simplification : x**(-a + b)*x**(2*a + b)
After Simplification : x**(a + 2*b)
Share your thoughts in the comments
Please Login to comment...