Tuesday, November 26, 2024
Google search engine
HomeLanguagesPython | sympy.powsimp() method

Python | sympy.powsimp() method

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.




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




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

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments