Open In App

Python | sympy.powdenest() method

With the help of sympy.powdenest() method, we can simplify the powers of mathematical expression by using identity i.e (x^a)^b=x^ab.

Syntax : sympy.powdenest()
Return : Return the simplified mathematical expression using identity.



Example #1 :
In this example, we can see that by using sympy.powdenest() method, we are able to simplify the powers of mathematical expression using identity i.e (x^a)^b=x^ab.




# import sympy
from sympy import * 
  
x, y = symbols('x y')
gfg_exp = (x**2)**3
   
# Use sympy.powdenest() method
fact = powdenest(gfg_exp)
   
print(fact)

Output :

x**6



Example #2 :




# import sympy
from sympy import * 
  
x, y, z, a, b = symbols('x y z a b')
gfg_exp = (x**(a + b))**2
   
# Use sympy.powdenest() method
fact = powdenest(gfg_exp)
   
print(fact)

Output :

x**(2*a + 2*b)

Article Tags :